-
-
Notifications
You must be signed in to change notification settings - Fork 45
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
Add type hints (finally) #178
Conversation
src/interrogate/badge_gen.py
Outdated
DEFAULT_FILENAME = "interrogate_badge" | ||
COLORS = { | ||
|
||
NumberType = int | float |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This causes CI to fail as int | float
is actually executed at runtime (since it's not an annotation). In this case you still have to use the <3.10 syntax:
NumberType = int | float | |
NumberType = Union[int, float] |
Or, better yet, don't introduce this type alias at all and simply use int | float
everywhere (it's just one more character 😉)
src/interrogate/visit.py
Outdated
DocumentableFunc = ast.AsyncFunctionDef | ast.FunctionDef | ||
DocumentableFuncOrClass = DocumentableFunc | ast.ClassDef | ||
DocumentableNode = DocumentableFuncOrClass | ast.Module |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much for your review @trag1c - I am so behind on keeping up with the changes in typing 🙈
src/interrogate/config.py
Outdated
import configparser | ||
import os | ||
import pathlib | ||
import re | ||
|
||
from typing import Any, Sequence |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typing.Sequence
and the like are deprecated as part of PEP 585, so it'd be better to use collections.abc.Sequence
for annotations
src/interrogate/cli.py
Outdated
def main( | ||
paths: Optional[List[str]], | ||
verbose: int, | ||
quiet: bool, | ||
fail_under: Union[int, float], | ||
exclude: Tuple[str], | ||
ignore_init_method: bool, | ||
ignore_init_module: bool, | ||
ignore_magic: bool, | ||
ignore_module: bool, | ||
ignore_nested_classes: bool, | ||
ignore_nested_functions: bool, | ||
ignore_overloaded_functions: bool, | ||
ignore_private: bool, | ||
ignore_property_decorators: bool, | ||
ignore_setters: bool, | ||
ignore_semiprivate: bool, | ||
ignore_regex: Optional[List[re.Pattern[str]]], | ||
ext: Tuple[str], | ||
whitelist_regex: Optional[List[re.Pattern[str]]], | ||
style: str, | ||
output: Optional[str], | ||
color: bool, | ||
omit_covered_files: bool, | ||
generate_badge: Optional[str], | ||
badge_format: Optional[str], | ||
badge_style: Optional[str], | ||
config: Optional[str], | ||
) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious: does click
require these to be <3.9 annotations?
for more information, see https://pre-commit.ci
Initial pass at type hinting - I probably didn't do everything correctly, but mypy passes 😅