Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing type annotations in documentation #124

Open
titusz opened this issue Jul 2, 2024 · 4 comments
Open

Fix missing type annotations in documentation #124

titusz opened this issue Jul 2, 2024 · 4 comments

Comments

@titusz
Copy link
Member

titusz commented Jul 2, 2024

mkdocstrings does not seem to support PEP 484 type comments

@pawamoy
Copy link

pawamoy commented Jul 2, 2024

Hi! We definitely support type hints :) don't hesitate to open issues with minimal reproducible examples in our bug tracker ^^

@pawamoy
Copy link

pawamoy commented Jul 2, 2024

Ah, sorry, I read type hints instead of type comments. We don't support comments indeed.

@titusz
Copy link
Member Author

titusz commented Jul 3, 2024

What I like about PEP 484 type comments for function annotations is that they can make many function signatures much more readable. For example:

def process_data(raw_data: List[Dict[str, str]], config: Optional[Dict[str, str]] = None) -> List[int]:
    """Process raw data according to config."""
    pass

becomes:

def process_data(raw_data, config=None):
    # type: (List[Dict[str, str]], Optional[Dict[str, str]]) -> List[int]
    """Process raw data according to config."""
    pass

And type comment based function annotations are well supported by mypy and IDEs like PyCharm.
@pawamoy Do you think that would be something to consider to support with griffe?

@pawamoy
Copy link

pawamoy commented Jul 3, 2024

Fortunately, ast can parse type comments, so we can consider supporting them. Not a priority though since we have type annotations. Could be an Insiders feature :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants