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

Improve .pyi files support #1268

Open
sobolevn opened this issue Mar 19, 2020 · 5 comments
Open

Improve .pyi files support #1268

sobolevn opened this issue Mar 19, 2020 · 5 comments
Labels
documentation Docs related task feature New feature or request level:advanced Needs a lot of care

Comments

@sobolevn
Copy link
Member

Currently, we have a lot of rules that are not very aligned with .pyi files.

Here are some of them:

  • ... usage as a placeholder
  • complexity rules like number of arguments, methods, etc (we cannot control things like it in annotations)

And probably others as well.

What we need to do here is ignoring this violations when filename has .pyi extension.
And better docs about this case.

Related: https://github.com/dry-python/returns/blob/master/setup.cfg#L50

@sobolevn sobolevn added feature New feature or request documentation Docs related task level:advanced Needs a lot of care labels Mar 19, 2020
@sobolevn sobolevn added this to the Version 0.14 aka python3.8 milestone Mar 19, 2020
@sobolevn sobolevn self-assigned this Mar 19, 2020
@sobolevn
Copy link
Member Author

@sobolevn
Copy link
Member Author

We should also allow almost any names in .pyi files. We cannot control it either.

@sobolevn
Copy link
Member Author

Also ignoring:

  • WPS605, because methods can have 0 arguments in stubs
  • WPS604, because all magic methods can be used in stubs
  • WPS602, because @staticmethod can be used in stubs
  • WPS600, because classes can subtype builtins in stubs
  • WPS431, because there can be nested classes
  • WPS428, because we use ... in stubs
  • WPS412, because __init__.py can have logic
  • WPS410, because we should allow different metadata variables
  • WPS113, because mypy requires as imports for pubic API

Complexity rules (I still need to look through all of them):

  • WPS235, because we cannot control the number of imports
  • WPS215, because we cannot control the number of base classes

We also need a --external-stubs config flag to enable this mode.
Otherwise, we are still writing our own stubs. That have a limited set of silenced violations.

@sobolevn sobolevn modified the milestones: Version 0.14 aka python3.8, Version 0.15 Mar 19, 2020
@sobolevn
Copy link
Member Author

This is way too big for 0.14.

@maltevesper
Copy link

WPS211 is another complexity rule to consider for ignoring, It should already trigger on the actual implementation in the .py file.

Would it make sense to ignore WPS211 (too many args) and WPS428 (Ellipsis as unused code) on @overload stubs in .py files too?
The logic for WPS211 is that it is already caught in the actual implementation, warning in other places requires cluttering #noqa comments through the file if one has a valid exception.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Docs related task feature New feature or request level:advanced Needs a lot of care
Projects
None yet
Development

No branches or pull requests

2 participants