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

Add handling for rules that are both deprecated and redirected #9714

Closed
wants to merge 9 commits into from

Conversation

zanieb
Copy link
Member

@zanieb zanieb commented Jan 30, 2024

Follow up to #9689 adds tooling for warning on rules that are deprecated because we replaced them with another rule.

Previously we would display no warnings for deprecated redirected rules because the redirect took place before the warnings could be displayed.

As with the other changes, this is immediately used for testing. Deprecates all of the PGH rules and adds redirects where relevant.

Closes #8931

@zanieb zanieb mentioned this pull request Jan 30, 2024
Copy link

codspeed-hq bot commented Jan 30, 2024

CodSpeed Performance Report

Merging #9714 will not alter performance

Comparing zb/pygrep (b75864c) with release/0.2.0 (435d025)

Summary

✅ 30 untouched benchmarks

(PygrepHooks, "005") => (RuleGroup::Stable, rules::pygrep_hooks::rules::InvalidMockAccess),
(PygrepHooks, "001") => (RuleGroup::Deprecated, rules::pygrep_hooks::rules::Eval),
(PygrepHooks, "002") => (RuleGroup::Deprecated, rules::pygrep_hooks::rules::DeprecatedLogWarn),
(PygrepHooks, "003") => (RuleGroup::Deprecated, rules::pygrep_hooks::rules::BlanketTypeIgnore),
Copy link
Member

Choose a reason for hiding this comment

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

Should we deprecate these despite not having replacements for them?

Copy link
Member

Choose a reason for hiding this comment

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

I dislike the category but the specific rules seem... ok.

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought we had decided that already in #8931? I guess I don't see any problems with these other rules though?

Copy link
Member

Choose a reason for hiding this comment

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

I still want to deprecate the category since it's unfocused, but I think we'd need to find new homes for the others. I'd vote just deprecate the two for now.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay works for me

Copy link
Member

@charliermarsh charliermarsh left a comment

Choose a reason for hiding this comment

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

Really slick!

@zanieb
Copy link
Member Author

zanieb commented Jan 30, 2024

Eh we have a problem here where redirected rules are being treated as stable when in preview... I need to investigate further.

Copy link
Contributor

ruff-ecosystem results

Linter (stable)

ℹ️ ecosystem check detected linter changes. (+27 -1 violations, +0 -0 fixes in 4 projects; 1 project error; 38 projects unchanged)

DisnakeDev/disnake (+1 -0 violations, +0 -0 fixes)

+ disnake/utils.py:1161:21: PGH001 No builtin `eval()` allowed

demisto/content (+0 -1 violations, +0 -0 fixes)

- Packs/Malwr/Integrations/Malwr/Malwr.py:96:18: PGH001 No builtin `eval()` allowed

ibis-project/ibis (+2 -0 violations, +0 -0 fixes)

+ ibis/common/typing.py:206:12: PGH001 No builtin `eval()` allowed
+ ibis/common/typing.py:206:69: RUF100 Unused `noqa` directive (non-enabled: `S307`)

pandas-dev/pandas (+24 -0 violations, +0 -0 fixes)

+ pandas/tests/computation/test_eval.py:1110:15: PGH001 No builtin `eval()` allowed
+ pandas/tests/computation/test_eval.py:1126:15: PGH001 No builtin `eval()` allowed
+ pandas/tests/computation/test_eval.py:298:28: PGH001 No builtin `eval()` allowed
+ pandas/tests/computation/test_eval.py:760:36: PGH001 No builtin `eval()` allowed
+ pandas/tests/frame/methods/test_sample.py:174:47: PGH001 No builtin `eval()` allowed
+ pandas/tests/frame/methods/test_sample.py:175:66: PGH001 No builtin `eval()` allowed
+ pandas/tests/frame/test_query_eval.py:117:20: PGH001 No builtin `eval()` allowed
+ pandas/tests/frame/test_query_eval.py:120:18: PGH001 No builtin `eval()` allowed
+ pandas/tests/indexes/base_class/test_formats.py:16:15: PGH001 No builtin `eval()` allowed
+ pandas/tests/indexes/categorical/test_category.py:203:31: PGH001 No builtin `eval()` allowed
+ pandas/tests/indexes/multi/test_formats.py:64:9: PGH001 No builtin `eval()` allowed
+ pandas/tests/indexes/numeric/test_numeric.py:37:31: PGH001 No builtin `eval()` allowed
+ pandas/tests/indexes/ranges/test_range.py:398:31: PGH001 No builtin `eval()` allowed
+ pandas/tests/indexes/ranges/test_range.py:63:18: PGH001 No builtin `eval()` allowed
+ pandas/tests/indexes/ranges/test_range.py:71:18: PGH001 No builtin `eval()` allowed
+ pandas/tests/indexes/test_old_base.py:239:31: PGH001 No builtin `eval()` allowed
+ pandas/tests/scalar/timestamp/test_constructors.py:664:26: PGH001 No builtin `eval()` allowed
+ pandas/tests/scalar/timestamp/test_constructors.py:672:26: PGH001 No builtin `eval()` allowed
+ pandas/tests/scalar/timestamp/test_constructors.py:681:26: PGH001 No builtin `eval()` allowed
+ pandas/tests/scalar/timestamp/test_constructors.py:689:26: PGH001 No builtin `eval()` allowed
+ pandas/tests/scalar/timestamp/test_formats.py:110:29: PGH001 No builtin `eval()` allowed
+ pandas/tests/scalar/timestamp/test_formats.py:116:27: PGH001 No builtin `eval()` allowed
+ pandas/tests/scalar/timestamp/test_formats.py:126:40: PGH001 No builtin `eval()` allowed
+ pandas/tests/scalar/timestamp/test_formats.py:163:20: PGH001 No builtin `eval()` allowed

sphinx-doc/sphinx (error)

warning: The `show-source` option has been deprecated in favor of `output-format`'s "full" and "concise" variants. Please update your configuration to use `output-format = <full|concise>` instead.
ruff failed
  Cause: Selection of unstable rules without the `--preview` flag is not allowed. Enable preview or remove selection of:
	- FURB131
	- FURB113
	- FURB132

Changes by rule (2 rules affected)

code total + violation - violation + fix - fix
PGH001 27 26 1 0 0
RUF100 1 1 0 0 0

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+1 -34464 violations, +0 -0 fixes in 6 projects; 4 project errors; 33 projects unchanged)

apache/airflow (+0 -23410 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --output-format concise --preview --select ALL

- airflow/__init__.py:59:67: PGH003 Use specific rule codes when ignoring type issues
- airflow/api/__init__.py:46:9: TRY200 Use `raise from` to specify exception cause
- airflow/api/auth/backend/kerberos_auth.py:55:85: PGH003 Use specific rule codes when ignoring type issues
- airflow/api/auth/backend/kerberos_auth.py:73:18: ANN101 Missing type annotation for `self` in method
- airflow/api/client/api_client.py:27:18: ANN101 Missing type annotation for `self` in method
- airflow/api/client/api_client.py:33:21: ANN101 Missing type annotation for `self` in method
- airflow/api/client/api_client.py:45:20: ANN101 Missing type annotation for `self` in method
- airflow/api/client/api_client.py:52:18: ANN101 Missing type annotation for `self` in method
- airflow/api/client/api_client.py:59:19: ANN101 Missing type annotation for `self` in method
... 22044 additional changes omitted for rule ANN101
- airflow/api/client/local_client.py:80:13: TRY200 Use `raise from` to specify exception cause
- airflow/api/common/experimental/delete_dag.py:23:46: PGH004 Use specific rule codes when using `noqa`
- airflow/api/common/experimental/get_code.py:41:9: TRY200 Use `raise from` to specify exception cause
- airflow/api/common/experimental/mark_tasks.py:23:46: PGH004 Use specific rule codes when using `noqa`
- airflow/api/common/experimental/pool.py:65:9: TRY200 Use `raise from` to specify exception cause
- airflow/api/common/experimental/trigger_dag.py:23:47: PGH004 Use specific rule codes when using `noqa`
- airflow/api_connexion/endpoints/connection_endpoint.py:131:9: TRY200 Use `raise from` to specify exception cause
- airflow/api_connexion/endpoints/connection_endpoint.py:164:9: TRY200 Use `raise from` to specify exception cause
... 357 additional changes omitted for rule TRY200
- airflow/api_connexion/schemas/dag_schema.py:107:55: PGH003 Use specific rule codes when ignoring type issues
- airflow/callbacks/callback_requests.py:57:19: ANN102 Missing type annotation for `cls` in classmethod
- airflow/callbacks/callback_requests.py:95:19: ANN102 Missing type annotation for `cls` in classmethod
- airflow/cli/commands/standalone_command.py:51:20: ANN102 Missing type annotation for `cls` in classmethod
- airflow/compat/functools.py:31:40: PGH003 Use specific rule codes when ignoring type issues
- airflow/configuration.py:1592:61: PGH003 Use specific rule codes when ignoring type issues
- airflow/dag_processing/manager.py:1301:93: PGH003 Use specific rule codes when ignoring type issues
... 421 additional changes omitted for rule PGH003
- airflow/dag_processing/manager.py:496:9: ANN102 Missing type annotation for `cls` in classmethod
- airflow/dag_processing/processor.py:420:21: ANN102 Missing type annotation for `cls` in classmethod
- airflow/dag_processing/processor.py:795:21: ANN102 Missing type annotation for `cls` in classmethod
... 478 additional changes omitted for rule ANN102
- airflow/hooks/dbapi.py:25:25: PGH004 Use specific rule codes when using `noqa`
- airflow/hooks/dbapi.py:26:17: PGH004 Use specific rule codes when using `noqa`
- airflow/macros/__init__.py:20:14: PGH004 Use specific rule codes when using `noqa`
... 44 additional changes omitted for rule PGH004
- dev/stats/get_important_pr_candidates.py:131:32: PGH001 No builtin `eval()` allowed
- tests/providers/amazon/aws/executors/ecs/test_ecs_executor.py:1135:16: PGH005 Non-existent mock method: `called_once`
- tests/providers/amazon/aws/operators/test_eks.py:568:9: PGH005 Mock method should be called: `assert_called_once`
... 23377 additional changes omitted for project

bokeh/bokeh (+0 -4146 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --output-format concise --preview --select ALL

- docs/bokeh/docserver.py:99:39: PGH003 Use specific rule codes when ignoring type issues
- examples/output/apis/autoload_static.py:32:20: ANN101 Missing type annotation for `self` in method
- examples/output/apis/autoload_static.py:34:13: ANN101 Missing type annotation for `self` in method
- examples/output/apis/autoload_static.py:41:20: ANN101 Missing type annotation for `self` in method
- examples/output/apis/autoload_static.py:43:13: ANN101 Missing type annotation for `self` in method
- examples/plotting/glyphs.py:8:5: PGH004 Use specific rule codes when using `noqa`
- examples/server/api/tornado_embed.py:15:13: ANN101 Missing type annotation for `self` in method
- examples/server/app/server_auth/auth.py:27:13: ANN101 Missing type annotation for `self` in method
... 4003 additional changes omitted for rule ANN101
- release/util.py:32:38: PGH003 Use specific rule codes when ignoring type issues
- setup.py:159:22: PGH003 Use specific rule codes when ignoring type issues
... 4136 additional changes omitted for project

ibis-project/ibis (+1 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --output-format concise --preview

+ ibis/common/typing.py:206:69: RUF100 Unused `noqa` directive (non-enabled: `S307`)

milvus-io/pymilvus (+0 -1 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --output-format concise --preview

- _version_helper.py:13:50: PGH004 Use specific rule codes when using `noqa`

rotki/rotki (+0 -2 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --output-format concise --preview

- pytestgeventwrapper.py:1:48: PGH004 Use specific rule codes when using `noqa`
- pytestgeventwrapper.py:2:34: PGH004 Use specific rule codes when using `noqa`

zulip/zulip (+0 -6905 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --output-format concise --preview --select ALL

- analytics/lib/counts.py:105:9: ANN101 Missing type annotation for `self` in method
- analytics/lib/counts.py:112:26: ANN101 Missing type annotation for `self` in method
- analytics/lib/counts.py:49:24: ANN101 Missing type annotation for `self` in method
- analytics/lib/counts.py:55:9: ANN101 Missing type annotation for `self` in method
- analytics/lib/counts.py:73:18: ANN101 Missing type annotation for `self` in method
- analytics/lib/counts.py:76:30: ANN101 Missing type annotation for `self` in method
... 6614 additional changes omitted for rule ANN101
- analytics/views/stats.py:156:9: TRY200 Use `raise from` to specify exception cause
- confirmation/models.py:102:9: TRY200 Use `raise from` to specify exception cause
- corporate/lib/registration.py:115:9: TRY200 Use `raise from` to specify exception cause
- corporate/lib/remote_billing_util.py:124:9: TRY200 Use `raise from` to specify exception cause
... 6895 additional changes omitted for project

demisto/content (error)

ruff check --no-cache --exit-zero --output-format concise --preview

warning: The top-level linter settings are deprecated in favour of their counterparts in the `lint` section. Please update the following options in your configuration:
  - 'ignore' -> 'lint.ignore'
  - 'select' -> 'lint.select'
  - 'unfixable' -> 'lint.unfixable'
  - 'per-file-ignores' -> 'lint.per-file-ignores'


ruff failed
  Cause: Selection of deprecated rules is not allowed when preview is enabled. Remove selection of:
	- PGH002 (use `G010` instead)
	- PGH001 (use `S307` instead)

fronzbot/blinkpy (error)

ruff check --no-cache --exit-zero --output-format concise --preview

warning: The top-level linter settings are deprecated in favour of their counterparts in the `lint` section. Please update the following options in your configuration:
  - 'ignore' -> 'lint.ignore'
  - 'select' -> 'lint.select'
  - 'mccabe' -> 'lint.mccabe'
  - 'per-file-ignores' -> 'lint.per-file-ignores'


ruff failed
  Cause: Selection of deprecated rule `TRY200` is not allowed when preview mode is enabled.

python/mypy (error)

ruff check --no-cache --exit-zero --output-format concise --preview

warning: The top-level linter settings are deprecated in favour of their counterparts in the `lint` section. Please update the following options in your configuration:
  - 'ignore' -> 'lint.ignore'
  - 'select' -> 'lint.select'
  - 'unfixable' -> 'lint.unfixable'
  - 'isort' -> 'lint.isort'


ruff failed
  Cause: Selection of deprecated rule `PGH004` is not allowed when preview is enabled.

sphinx-doc/sphinx (error)

ruff check --no-cache --exit-zero --output-format concise --preview

warning: The `show-source` option has been deprecated in favor of `output-format`'s "full" and "concise" variants. Please update your configuration to use `output-format = <full|concise>` instead.
ruff failed
  Cause: Selection of deprecated rule `ANN102` is not allowed when preview mode is enabled.

Changes by rule (8 rules affected)

code total + violation - violation + fix - fix
ANN101 32676 0 32676 0 0
TRY200 636 0 636 0 0
ANN102 612 0 612 0 0
PGH003 444 0 444 0 0
PGH004 55 0 55 0 0
PGH005 40 0 40 0 0
RUF100 1 1 0 0 0
PGH001 1 0 1 0 0

@zanieb zanieb closed this Jan 31, 2024
zanieb added a commit that referenced this pull request Feb 1, 2024
Cherry-picked from #9714 which is
being abandoned for now because we need to invest more into our
redirection infrastructure before it is feasible.

Fixes a bug in the implementation where we improperly included
deprecated rules in `RuleSelector.rules()` when preview is on. Includes
some clean-up of error messages and the implementation.
zanieb added a commit that referenced this pull request Feb 1, 2024
Cherry-picked from #9714 which is
being abandoned for now because we need to invest more into our
redirection infrastructure before it is feasible.

Fixes a bug in the implementation where we improperly included
deprecated rules in `RuleSelector.rules()` when preview is on. Includes
some clean-up of error messages and the implementation.
# Conflicts:
#	crates/ruff/tests/integration_test.rs
zanieb added a commit that referenced this pull request Feb 1, 2024
Follow-up to #9754 and #9689. Alternative to #9714.

Marks `TRY200` as removed and redirects to `B904` instead of marking as
deprecated and suggesting `B904` instead.
zanieb added a commit that referenced this pull request Feb 1, 2024
Follow-up to #9754 and #9689. Alternative to #9714.
Replaces #7506 and #7507
Same ideas as #9755
Part of #8931
zanieb added a commit that referenced this pull request Feb 1, 2024
Cherry-picked from #9714 which is
being abandoned for now because we need to invest more into our
redirection infrastructure before it is feasible.

Fixes a bug in the implementation where we improperly included
deprecated rules in `RuleSelector.rules()` when preview is on. Includes
some clean-up of error messages and the implementation.
# Conflicts:
#	crates/ruff/tests/integration_test.rs
zanieb added a commit that referenced this pull request Feb 1, 2024
Follow-up to #9754 and #9689. Alternative to #9714.

Marks `TRY200` as removed and redirects to `B904` instead of marking as
deprecated and suggesting `B904` instead.
zanieb added a commit that referenced this pull request Feb 1, 2024
Follow-up to #9754 and #9689. Alternative to #9714.
Replaces #7506 and #7507
Same ideas as #9755
Part of #8931
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.

None yet

2 participants