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

Annotate and make attrs-strict PEP 561 compatible #24

Closed
keiclone opened this issue Nov 18, 2019 · 10 comments
Closed

Annotate and make attrs-strict PEP 561 compatible #24

keiclone opened this issue Nov 18, 2019 · 10 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@keiclone
Copy link
Contributor

Is your feature request related to a problem? Please describe.
attrs-strict is great because it adds runtime type validation to my attrs classes, but it'd be great if it could play nice with my static type checkers as well.

Describe the solution you'd like
Annotate all the functions and add py.typed to setup.py per PEP 561

Describe alternatives you've considered
A quick way to incorporate attrs-strict in my projects would be to add some stubs for it to MYPYPATH. Might as well contribute the effort back.

@gaborbernat gaborbernat added enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed labels Nov 19, 2019
@erikseulean
Copy link
Contributor

This looks like a good idea; if you'd like to implement it yourself @keiclone I can assign this to you.

@keiclone
Copy link
Contributor Author

Sure thing, I can take this.

@erikseulean
Copy link
Contributor

Great, I assigned this to you.

@erikseulean
Copy link
Contributor

@keiclone any updates on this ?

@keiclone
Copy link
Contributor Author

keiclone commented Dec 30, 2019 via email

@keiclone
Copy link
Contributor Author

keiclone commented Jan 6, 2020

working on this right now. looking at the README and tox.ini, it seems up to this point, we have been supporting python 2.7. Note that afaik, proceeding with this may break backwards compatibility with 2.7, since the annotations will affect function signatures.

One alternative would be to proceed in the same fashion as attrs and create a .pyi stub file for every module we have. There are some drawbacks with this approach:

  • it will be an extra bit of mental load to make sure each change keeps the stub files up to date and in sync with the code
  • I think it will also require some duplicate efforts in order to have CI enforce that each function is annotated moving forward (involving python2 compliant annotations, but feel free to correct me here)
  • doing things the way attrs does can be a very involved process

On the other hand, breaking backwards compatibility means we would no longer be completely in sync with the version support of the original attrs library. Maybe that's not a priority for us? Maybe we can say the last release that supports Python 2.7 is version 0.0.4?

We could also do some middle ground solution like only annotating some functions to mitigate the drawbacks of keeping 2.7 compatibility.

Since the current year is now 2020 and python 2.7 is officially deprecated, are we okay with dropping support for it now? Or do we wish to support it as long as attrs does?

@gaborbernat
Copy link
Contributor

gaborbernat commented Jan 6, 2020

Since the current year is now 2020 and python 2.7 is officially deprecated

CPython 2.7 might be no longer maintained, but PyPy 2.7 is still supported (that website is a bit lying as it really should be https://cpythonclock.org/ 🤷‍♂ ). So the real question is do we want to drop that platform? I'm not 100% sure on that.

@alexchamberlain
Copy link

Personally, for a library like this, I'd vote against removing 2.7 support unless absolutely necessary or because the upstream package (attrs) removes it.

@erikseulean
Copy link
Contributor

I'd prefer to keep the 2.7 support longer, that being said I'd say this should be parked until we drop the 2.7 support ?

@erikseulean
Copy link
Contributor

Done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants