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

Translate more banned import config to ruff #57283

Merged
merged 2 commits into from
Feb 13, 2024

Conversation

tqa236
Copy link
Contributor

@tqa236 tqa236 commented Feb 6, 2024

Translate some config in unwanted-patterns-in-tests to ruff. I think the main selling point of ruff here is just the ease of implementing new rules, like the currently unenabled pytest.warns one.

The major difference is that unwanted-patterns-in-tests is currently only enabled in pandas/tests while with this implementation, TID251 will be enabled globally.

There are several approaches we can explore to reconcile the 2 behaviors.

  • Keep it globally enabled for rule where the number of errors is low (and keep using pygrep) for the rest
  • Use hierarchical configuration (I think pandas doesn't use it at the moment, so this will be a fairly big change)

There's an open issue to track the progress of flat configuration, which allows us to keep all rules within 1 config file, but there's not much progress lately.

@simonjayhawkins simonjayhawkins added the Code Style Code style, linting, code_checks label Feb 7, 2024
"pytest.xfail".msg = "Use pytest.mark.xfail instead of pytest.xfail"
"conftest".msg = "No direct imports from conftest"
"numpy.testing".msg = "Do not use numpy.testing"
# "numpy.array_equal".msg = "Do not use numpy.array_equal" # Used in pandas/core
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we just ignore it's usage in pandas/core?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK, We can only ignore TID251 as a whole, we can't just ignore enforcing this rule for numpy.array_equal in pandas/core

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha. Can we remove some of the old checks that are covered by this section?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's done in the latest commit, you can take a look.

@mroeschke mroeschke added this to the 3.0 milestone Feb 13, 2024
@mroeschke mroeschke merged commit cdec74a into pandas-dev:main Feb 13, 2024
48 checks passed
@mroeschke
Copy link
Member

Thanks @tqa236

@tqa236 tqa236 deleted the use-ruff-for-banned-import branch March 17, 2024 07:53
pmhatre1 pushed a commit to pmhatre1/pandas-pmhatre1 that referenced this pull request May 7, 2024
* Translate more banned import config to ruff

* Remove redundant rules
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code Style Code style, linting, code_checks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants