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

Remove decorators named validator and root_validator from B902 checks #459

Merged
merged 1 commit into from
Feb 7, 2024

Conversation

natemcmaster
Copy link
Contributor

@natemcmaster natemcmaster commented Feb 5, 2024

What

This removes methods named validator and root_validator from the B902 check

Why

Fixes #413

Removes false positives for common cases, like using attrs validators

Testing

ran tox and all tests are passing

@natemcmaster natemcmaster marked this pull request as ready for review February 5, 2024 01:19
Copy link
Contributor

@jakkdl jakkdl left a comment

Choose a reason for hiding this comment

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

In hindsight I should've added methods to tests/b902.py with @validator and @root_validator to check that the defaults were properly parsed. You could perhaps add those now and mark them as failing in tests.test_bugbear.test_b902, but /shrug.

If I could approve the test run I would. I know @Zac-HD likes championing for only requiring approval for test runs if first-time contributors are new to github, as opposed to default where all first-time project contributors require approvals.

/path/to/venv/bin/pip install -e .[dev]
/path/to/venv/bin/pip install -e '.[dev]'
Copy link
Contributor

Choose a reason for hiding this comment

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

This is only required in some shells (zsh in particular) afaik, but doesn't hurt in other shells, so seems fine to bundle in what's otherwise an unrelated PR.

Copy link
Collaborator

@cooperlees cooperlees left a comment

Choose a reason for hiding this comment

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

Let's make it so.

@cooperlees cooperlees merged commit 5c3f0bd into PyCQA:main Feb 7, 2024
6 checks passed
@natemcmaster natemcmaster deleted the b902-no-validator branch February 19, 2024 02:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

B902: False positive when using the attrs library
3 participants