-
Notifications
You must be signed in to change notification settings - Fork 158
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 for the get_unused_code
function and the fields of Item
.
#361
Conversation
Thanks for the PR! I'm a bit reluctant to merge it because type annotations without tests might get outdated quickly when the code changes. Is there a way to test that all type annotations are correct, while ignoring all other typing issues that a tool like Mypy might detect? Could you add such a test? |
@jendrikseipp For sure, I'll work on adding a test to do this. |
@jendrikseipp I've added a test that runs mypy, disabling error codes that mypy complains about at the moment. All of them seem like codes that in general shouldn't be needed to detect wrong type annotations. By the way, before disabling the |
Thanks, I'll have a closer look at this when time allows. |
Hey @jendrikseipp, just following up on this PR. |
0a2f85d
to
5256cd6
Compare
5256cd6
to
1e1cdce
Compare
eceb59e
to
6bc297f
Compare
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 for your persistence :)
tests/test_pytype.py
Outdated
|
||
|
||
@pytest.mark.skipif( | ||
sys.version_info >= (3, 13), reason="Need python < 3.13 for pytype" |
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.
sys.version_info >= (3, 13), reason="Need python < 3.13 for pytype" | |
sys.version_info >= (3, 13), reason="needs Python < 3.13 for pytype" |
…ctor and checking whether the pytype exit code is 0).
Thanks for your work on this! |
No problem, and thank you for your feedback :) |
Description
This PR adds type hints to make it slightly easier for users to use the api. Now for each element from
get_unused_code
, IDEs will display their type asItem
when highlighting over the variable. The same is done for the fields ofItem
, such as makingfilename
's type a Path (removing any potential confusion about whether it's a string).Related Issue
Checklist:
pre-commit run --all-files
to format and lint my code.