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

add typehints with mypy #58

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

add typehints with mypy #58

wants to merge 9 commits into from

Conversation

rwadman
Copy link

@rwadman rwadman commented Apr 10, 2022

Hello!
We're using flatten-dict in a typed context at work, so I created some stubs for it the other day. Felt like it could be nice to share them with you, but I think it's much easier to maintain typehints if they're written inline with the code, so I spent some time this weekend writing that up.

Had to upgrade black to avoid some broken import, and did my best to configure static type checking with mypy.

Don't know if you're interested at all, so feel free to ignore, but here you have it :)

@rwadman
Copy link
Author

rwadman commented Apr 10, 2022

Noticed now that I forgot to add the type checking to CI, will see if I can figure that out...

@ianlini
Copy link
Owner

ianlini commented Apr 12, 2022

Thanks. I'm very interested in mypy, but didn't have time to learn it. I will spend some time understanding this PR.

@ianlini
Copy link
Owner

ianlini commented Apr 12, 2022

Are you using the comments because we are still supporting Python 2.7? I think it's time to remove it so that we can use the type annotation.

@rwadman
Copy link
Author

rwadman commented Apr 13, 2022

Nice! Yes, the type comments are there to support python < 3.5, which (I think) is the first version with support for proper annotations.

Which python versions we should support is your call I feel. If your certain about dropping 2.7 (and probably also anything else before 3.5) I could update the PR to move away from the type comment style.
It would also simplify the tox setup a bit since we would then be able to typecheck for each version of python with the tox environment for that version (to typecheck for python 2.7 you have to run mypy in python >3.5).

@ianlini
Copy link
Owner

ianlini commented Apr 14, 2022

Yes, please drop Python 2.7.

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

Successfully merging this pull request may close these issues.

2 participants