0

I enhanced a class by adding some few methods from another class (Jira's class from atlassian-python package) My class is called JiraExtended.
Original methods from the class display this way: enter image description here enter image description here

The ones I created show this way with lesser info on function parameters for exemple: enter image description here enter image description here

The way I define docstrings is pretty much the same.

def grant_user_permission(self, username : str = None, permissionschemeid : str|int = None, permission : str = "BROWSE_PROJECTS") -> None:
        """
        Grants a permission to a user (username) on a specified Permission Scheme.
        :username: the user's username to grant the permission to, current username if not specified.
        :permissionschemeid: The id of the permission scheme.
        :permission: The permission key to grant, "BROWSE_PROJECTS" if not specified.
        """
        if not permissionschemeid:
            raise Exception("Provide a username and permissionschemeid")
        if not username:
            username : str = self.myself()['name']

        url = self.resource_url(resource = f"permissionscheme/{permissionschemeid}/permission")
        self.post(url, data=json.dumps({"holder": {"type": "user", "parameter": username}, "permission": permission}))

What's the secret so that Pylance guides me correctly?

1

1 Answer 1

0

Ensure that your type annotations are clear and consistent and all necessary imports for type annotations are correctly included.

def grant_user_permission(self, username: str = None, permissionschemeid: str | int = None, permission: str = "BROWSE_PROJECTS") -> None:
    """
    Grants a permission to a user (username) on a specified Permission Scheme.

    :param username: the user's username to grant the permission to, current username if not specified.
    :type username: str, optional
    :param permissionschemeid: The id of the permission scheme.
    :type permissionschemeid: str or int, optional
    :param permission: The permission key to grant, "BROWSE_PROJECTS" if not specified.
    :type permission: str, optional
    :raises Exception: If permissionschemeid is not provided.
    """
    if not permissionschemeid:
        raise Exception("Provide a username and permissionschemeid")
    if not username:
        username: str = self.myself()['name']

    url = self.resource_url(resource=f"permissionscheme/{permissionschemeid}/permission")
    self.post(url, data=json.dumps({"holder": {"type": "user", "parameter": username}, "permission": permission}))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.