-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
STYLE: enable ruff TCH on some file #51835
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
STYLE: enable ruff TCH on some file #51835
Conversation
@@ -1,3 +1,4 @@ | |||
# ruff: noqa: TCH004 |
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.
same as #51812
pandas/tests/extension/date/array.py
Outdated
from pandas._typing import Dtype # noqa: TCH001 | ||
from pandas._typing import PositionalIndexer # noqa: TCH001 |
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.
if add TYPE_CHECKING
, will cause import error, in pandas/tests/io/json/test_json_table_schema_ext_dtype.py
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.
any idea why? would it work to add from __future__ import annotations
at the top of this file?
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.
Based on the pytest failures, adding a future import to pandas/tests/extension/date/array.py
should fix this. (Wasn't there a script to enforce that all files have future imports?)
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.
It seems like there have been a lot of changes to the type annotations, and I can't determine whether they will have a significant impact or not.
Edit: if we add a script to enforce all files have future imports, the type annotation maybe change a lot too.
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.
It seems like there have been a lot of changes to the type annotations, and I can't determine whether they will have a significant impact or not.
Edit: if we add a script to enforce all files have future imports, the type annotation maybe change a lot too.
I searched for some information and found that these type annotation changes might be due to a new annotation feature introduced in a newer version of Python. It seems that this change does not have a significant impact, except for compatibility with older versions of Python.
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.
the check excludes test files (though perhaps it should include them?)
pandas/.pre-commit-config.yaml
Lines 402 to 413 in f7f0df1
- id: future-annotations | |
name: import annotations from __future__ | |
entry: 'from __future__ import annotations' | |
language: pygrep | |
args: [--negate] | |
files: ^pandas/ | |
types: [python] | |
exclude: | | |
(?x) | |
/(__init__\.py)|(api\.py)|(_version\.py)|(testing\.py)|(conftest\.py)$ | |
|/tests/ | |
|/_testing/ |
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.
the check excludes test files (though perhaps it should include them?)
pandas/.pre-commit-config.yaml
Lines 402 to 413 in f7f0df1
- id: future-annotations name: import annotations from __future__ entry: 'from __future__ import annotations' language: pygrep args: [--negate] files: ^pandas/ types: [python] exclude: | (?x) /(__init__\.py)|(api\.py)|(_version\.py)|(testing\.py)|(conftest\.py)$ |/tests/ |/_testing/
Sorry for the late reply. If necessary, I can open a pr and manually or automatically add 'from future import annotations'.
thanks for your pr, looks like there's some errors https://github.com/pandas-dev/pandas/actions/runs/4362414904/jobs/7627283459 |
This was because of a careless mistake and should be fine now |
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 @luke396 ! not many left, we're getting there
xref #51740, to fix