-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
STYLE: Enable ruff TCH on "pandas/_libs/*" #51794
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
Conversation
pandas/_libs/index.pyi
Outdated
|
||
from pandas._typing import npt | ||
if TYPE_CHECKING: |
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 ruff requires this change within a stub file, please report an issue at ruff. Using TYPE_CHECKING
inside a pyi files doesn't make sense as it is only used by type checkers.
edit: at least ruff 0.0.254 doesn't seem to suggest this change
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.
good point, reported
I'm still seeing it in 0.0.254 though:
(.311venv) marcogorelli@DESKTOP-U8OKFP3:~/pandas-dev$ git diff
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 484107af67..ba57fcb432 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -28,7 +28,7 @@ repos:
types_or: [python, pyi]
additional_dependencies: [black==23.1.0]
- repo: https://github.com/charliermarsh/ruff-pre-commit
- rev: v0.0.253
+ rev: v0.0.254
hooks:
- id: ruff
- repo: https://github.com/jendrikseipp/vulture
diff --git a/pyproject.toml b/pyproject.toml
index 58a70b584c..f2f8ed9093 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -311,7 +311,6 @@ exclude = [
"pandas/tests/*" = ["TCH"]
"pandas/plotting/*" = ["TCH"]
"pandas/util/*" = ["TCH"]
-"pandas/_libs/*" = ["TCH"]
# Keep this one enabled
"pandas/_typing.py" = ["TCH"]
(.311venv) marcogorelli@DESKTOP-U8OKFP3:~/pandas-dev$ pre-commit run ruff -a | grep 'index'
pandas/_libs/index.pyi:1:8: TCH002 Move third-party import `numpy` into a type-checking block
pandas/_libs/index.pyi:3:28: TCH001 Move application import `pandas._typing.npt` into a type-checking block
pandas/_libs/index.pyi:5:20: TCH001 Move application import `pandas.MultiIndex` into a type-checking block
pandas/_libs/index.pyi:6:32: TCH001 Move application import `pandas.core.arrays.ExtensionArray` into a type-checking block
pandas/_libs/window/indexers.pyi:1:8: TCH002 Move third-party import `numpy` into a type-checking block
pandas/_libs/window/indexers.pyi:3:28: TCH001 Move application import `pandas._typing.npt` into a type-checking block
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.
looks like they've fixed it https://github.com/charliermarsh/ruff/pull/3362/files
temporarily marking this PR as 'draft' until the next ruff version comes out, hope that's OK
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.
Or could also have something like
[tool.ruff.per-file-ignores]
"*.pyi" = ["TCH"] # TODO: remove line when using ruff 0.0.255
in pyproject.toml
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.
looks like there's a new ruff version
@v-mcoutinho do you want to update the ruff version please, revert the other changes, and remove pandas/_libs
from pyproject.toml?
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.
I can't seem to find this new version, where are you seeing it exactly? ruff's github page still shows 0.0.254 as the latest version.
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.
ah you're right, sorry, they've fixed it but haven't made a release yet, guess it'll be next week (they used to do daily releases)
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.
They just had a new release
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.
I made the changes, it seems the PR closed when I tried to push but I've opened it again.
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.
LGTM, assuming the CI is green
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.
Nice one, thanks @v-mcoutinho (and @twoertwein of course!)
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.#51740, for