-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
TYP: Autotyping #48191
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
TYP: Autotyping #48191
Conversation
@property | ||
# error: Cannot override final attribute "_is_mixed_type" (previously declared | ||
# in base class "NDFrame") | ||
@property # type: ignore[misc] | ||
def _is_mixed_type(self) -> bool: |
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.
NDFrame
declares _is_mixed_type
as final! This method should not exist or the parent method should not be final.
Not sure why mypy didn't find this earlier.
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.
Mypy generally doesn't check unannotated methods. It should probably still check @final
though.
…urrent __new__ methods were called but I think these pickle tests call older __new__ methods which allowed providing multiple positional arguments)
This should be ready from my perspective @mroeschke Can work on integrating autotyping into the CI after its next release. |
.pre-commit-config.yaml
Outdated
@@ -252,3 +252,14 @@ repos: | |||
/(__init__\.py)|(api\.py)|(_version\.py)|(testing\.py)|(conftest\.py)$ | |||
|/tests/ | |||
|/_testing/ | |||
- id: autotyping | |||
name: autotyping | |||
entry: python -m libcst.tool codemod autotyping.AutotypeCommand --safe 1 |
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.
Nit: I would slightly prefer --safe
to be expanded into the actual flags it enables (unless there's not a way to enable all the transformations at once) so it's more obvious what autotyping occurs.
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.
Okay, will change that.
Is it okay to add the .libcst.codemod.yaml
? It is needed. If we don't want to clutter the main folder, I could create scripts/run_autotyping.py
and create this file only temporarily.
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.
Is it okay to add the .libcst.codemod.yaml?
Yeah sure that would be okay!
Thanks @twoertwein! |
* annotate-magics * annotate-imprecise-magics * none-return * scalar-return * pyi files * ignore vendored file * manual changes * ignore pyright in pickle_compat (these errors would be legit if the current __new__ methods were called but I think these pickle tests call older __new__ methods which allowed providing multiple positional arguments) * run autotyping in pre-commit * remove final and expand safe (and add annotate-imprecise-magics)
Running autotyping on pandas https://github.com/JelleZijlstra/autotyping
Would be great to add it to pre-commit but before that many abstractmethods need return type annotations (autotyping let's them return
None
or wait for JelleZijlstra/autotyping#33).closes #46337
xref #47497