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

[flake8-pytest-style] Ambiguous pattern passed to pytest.raises() (PT201) #14966

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

InSyncWithFoo
Copy link
Contributor

Summary

Resolves #13705.

Test Plan

cargo nextest run and cargo insta test.

Copy link
Contributor

github-actions bot commented Dec 14, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+1983 -1 violations, +0 -0 fixes in 16 projects; 39 projects unchanged)

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

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

+ tests/ext/commands/test_base_core.py:49:46: PT201 Pattern passed to `match=` is neither escaped nor raw
+ tests/ext/tasks/test_loops.py:22:45: PT201 Pattern passed to `match=` is neither escaped nor raw
+ tests/ext/tasks/test_loops.py:76:45: PT201 Pattern passed to `match=` is neither escaped nor raw
+ tests/interactions/test_base.py:127:45: PT201 Pattern passed to `match=` is neither escaped nor raw
+ tests/test_embeds.py:386:42: PT201 Pattern passed to `match=` is neither escaped nor raw
+ tests/test_flags.py:339:30: PT201 Pattern passed to `match=` is neither escaped nor raw
+ tests/test_flags.py:355:30: PT201 Pattern passed to `match=` is neither escaped nor raw
+ tests/test_flags.py:371:30: PT201 Pattern passed to `match=` is neither escaped nor raw
+ tests/test_flags.py:387:30: PT201 Pattern passed to `match=` is neither escaped nor raw
+ tests/test_flags.py:96:44: PT201 Pattern passed to `match=` is neither escaped nor raw
... 5 additional changes omitted for project

PlasmaPy/PlasmaPy (+4 -0 violations, +0 -0 fixes)

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

+ tests/particles/test_ionization_state.py:511:23: PT201 Pattern passed to `match=` is neither escaped nor raw
+ tests/particles/test_ionization_state.py:516:48: PT201 Pattern passed to `match=` is neither escaped nor raw
+ tests/particles/test_ionization_state.py:615:49: PT201 Pattern passed to `match=` is neither escaped nor raw
+ tests/particles/test_ionization_state.py:619:49: PT201 Pattern passed to `match=` is neither escaped nor raw

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

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

+ dev/breeze/tests/test_packages.py:94:42: PT201 Pattern passed to `match=` is neither escaped nor raw
+ helm_tests/airflow_core/test_api_server.py:480:54: PT201 Pattern passed to `match=` is neither escaped nor raw
+ kubernetes_tests/test_kubernetes_pod_operator.py:652:48: PT201 Pattern passed to `match=` is neither escaped nor raw
+ providers/tests/airbyte/hooks/test_airbyte.py:125:52: PT201 Pattern passed to `match=` is neither escaped nor raw
+ providers/tests/airbyte/hooks/test_airbyte.py:149:52: PT201 Pattern passed to `match=` is neither escaped nor raw
+ providers/tests/airbyte/hooks/test_airbyte.py:167:52: PT201 Pattern passed to `match=` is neither escaped nor raw
+ providers/tests/airbyte/hooks/test_airbyte.py:179:52: PT201 Pattern passed to `match=` is neither escaped nor raw
+ providers/tests/airbyte/sensors/test_airbyte.py:105:52: PT201 Pattern passed to `match=` is neither escaped nor raw
+ providers/tests/airbyte/sensors/test_airbyte.py:76:52: PT201 Pattern passed to `match=` is neither escaped nor raw
+ providers/tests/alibaba/cloud/operators/test_analyticdb_spark.py:127:46: PT201 Pattern passed to `match=` is neither escaped nor raw
... 297 additional changes omitted for project

apache/superset (+4 -0 violations, +0 -0 fixes)

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

+ tests/integration_tests/db_engine_specs/hive_tests.py:152:49: PT201 Pattern passed to `match=` is neither escaped nor raw
+ tests/integration_tests/db_engine_specs/hive_tests.py:166:49: PT201 Pattern passed to `match=` is neither escaped nor raw
+ tests/unit_tests/pandas_postprocessing/test_contribution.py:44:58: PT201 Pattern passed to `match=` is neither escaped nor raw
+ tests/unit_tests/pandas_postprocessing/test_contribution.py:49:58: PT201 Pattern passed to `match=` is neither escaped nor raw

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

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

+ tests/unit/bokeh/core/test_validation.py:173:42: PT201 Pattern passed to `match=` is neither escaped nor raw
+ tests/unit/bokeh/embed/test_standalone.py:353:46: PT201 Pattern passed to `match=` is neither escaped nor raw
+ tests/unit/bokeh/plotting/test_contour.py:101:46: PT201 Pattern passed to `match=` is neither escaped nor raw
+ tests/unit/bokeh/plotting/test_contour.py:105:46: PT201 Pattern passed to `match=` is neither escaped nor raw
+ tests/unit/bokeh/plotting/test_contour.py:108:46: PT201 Pattern passed to `match=` is neither escaped nor raw
+ tests/unit/bokeh/plotting/test_contour.py:111:46: PT201 Pattern passed to `match=` is neither escaped nor raw
+ tests/unit/bokeh/plotting/test_contour.py:168:46: PT201 Pattern passed to `match=` is neither escaped nor raw
+ tests/unit/bokeh/plotting/test_contour.py:173:46: PT201 Pattern passed to `match=` is neither escaped nor raw
+ tests/unit/bokeh/plotting/test_contour.py:196:46: PT201 Pattern passed to `match=` is neither escaped nor raw
+ tests/unit/bokeh/plotting/test_contour.py:202:46: PT201 Pattern passed to `match=` is neither escaped nor raw
... 2 additional changes omitted for project

freedomofpress/securedrop (+19 -0 violations, +0 -0 fixes)

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

+ securedrop/tests/test_i18n.py:339:42: PT201 Pattern passed to `match=` is neither escaped nor raw
+ securedrop/tests/test_i18n.py:342:42: PT201 Pattern passed to `match=` is neither escaped nor raw
+ securedrop/tests/test_passphrases.py:70:56: PT201 Pattern passed to `match=` is neither escaped nor raw
+ securedrop/tests/test_passphrases.py:75:56: PT201 Pattern passed to `match=` is neither escaped nor raw
+ securedrop/tests/test_passphrases.py:80:56: PT201 Pattern passed to `match=` is neither escaped nor raw
+ securedrop/tests/test_passphrases.py:85:56: PT201 Pattern passed to `match=` is neither escaped nor raw
+ securedrop/tests/test_redwood.py:44:37: PT201 Pattern passed to `match=` is neither escaped nor raw
+ securedrop/tests/test_redwood.py:49:37: PT201 Pattern passed to `match=` is neither escaped nor raw
+ securedrop/tests/test_redwood.py:52:52: PT201 Pattern passed to `match=` is neither escaped nor raw
+ securedrop/tests/test_store.py:119:51: PT201 Pattern passed to `match=` is neither escaped nor raw
... 9 additional changes omitted for project

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

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

+ pandas/tests/api/test_api.py:397:50: PT201 Pattern passed to `match=` is neither escaped nor raw
+ pandas/tests/apply/test_frame_apply.py:106:19: PT201 Pattern passed to `match=` is neither escaped nor raw
+ pandas/tests/apply/test_frame_apply.py:119:19: PT201 Pattern passed to `match=` is neither escaped nor raw
+ pandas/tests/apply/test_frame_apply.py:812:42: PT201 Pattern passed to `match=` is neither escaped nor raw
+ pandas/tests/apply/test_frame_apply.py:913:42: PT201 Pattern passed to `match=` is neither escaped nor raw
+ pandas/tests/apply/test_frame_apply.py:94:45: PT201 Pattern passed to `match=` is neither escaped nor raw
+ pandas/tests/apply/test_frame_transform.py:129:42: PT201 Pattern passed to `match=` is neither escaped nor raw
+ pandas/tests/apply/test_frame_transform.py:65:42: PT201 Pattern passed to `match=` is neither escaped nor raw
+ pandas/tests/apply/test_numba.py:87:15: PT201 Pattern passed to `match=` is neither escaped nor raw
+ pandas/tests/apply/test_numba.py:97:15: PT201 Pattern passed to `match=` is neither escaped nor raw
+ pandas/tests/arithmetic/test_array_ops.py:19:41: PT201 Pattern passed to `match=` is neither escaped nor raw
+ pandas/tests/arithmetic/test_datetime64.py:317:50: PT201 Pattern passed to `match=` is neither escaped nor raw
+ pandas/tests/arithmetic/test_datetime64.py:328:50: PT201 Pattern passed to `match=` is neither escaped nor raw
+ pandas/tests/arithmetic/test_datetime64.py:342:50: PT201 Pattern passed to `match=` is neither escaped nor raw
+ pandas/tests/arithmetic/test_datetime64.py:352:50: PT201 Pattern passed to `match=` is neither escaped nor raw
+ pandas/tests/arithmetic/test_interval.py:263:46: PT201 Pattern passed to `match=` is neither escaped nor raw
+ pandas/tests/arithmetic/test_timedelta64.py:1558:45: PT201 Pattern passed to `match=` is neither escaped nor raw
+ pandas/tests/arithmetic/test_timedelta64.py:1560:45: PT201 Pattern passed to `match=` is neither escaped nor raw
+ pandas/tests/arithmetic/test_timedelta64.py:1603:45: PT201 Pattern passed to `match=` is neither escaped nor raw
+ pandas/tests/arithmetic/test_timedelta64.py:1960:45: PT201 Pattern passed to `match=` is neither escaped nor raw
+ pandas/tests/arithmetic/test_timedelta64.py:1974:45: PT201 Pattern passed to `match=` is neither escaped nor raw
+ pandas/tests/arithmetic/test_timedelta64.py:696:55: PT201 Pattern passed to `match=` is neither escaped nor raw
+ pandas/tests/arithmetic/test_timedelta64.py:698:55: PT201 Pattern passed to `match=` is neither escaped nor raw
+ pandas/tests/arrays/boolean/test_astype.py:12:42: PT201 Pattern passed to `match=` is neither escaped nor raw
+ pandas/tests/arrays/boolean/test_astype.py:15:42: PT201 Pattern passed to `match=` is neither escaped nor raw
+ pandas/tests/arrays/boolean/test_construction.py:18:41: PT201 Pattern passed to `match=` is neither escaped nor raw
+ pandas/tests/arrays/boolean/test_construction.py:212:42: PT201 Pattern passed to `match=` is neither escaped nor raw
+ pandas/tests/arrays/boolean/test_construction.py:21:41: PT201 Pattern passed to `match=` is neither escaped nor raw
+ pandas/tests/arrays/boolean/test_construction.py:24:41: PT201 Pattern passed to `match=` is neither escaped nor raw
+ pandas/tests/arrays/boolean/test_construction.py:257:42: PT201 Pattern passed to `match=` is neither escaped nor raw
... 1183 additional changes omitted for project

... Truncated remaining completed project reports due to GitHub comment length restrictions

Changes by rule (2 rules affected)

code total + violation - violation + fix - fix
PT201 1982 1982 0 0 0
PLW1514 2 1 1 0 0

@InSyncWithFoo
Copy link
Contributor Author

InSyncWithFoo commented Dec 14, 2024

This is a really noisy rule. I checked some of the new violations; they all seem to be true positives.

The rule currently don't have a fix. Should I add an unsafe "Wrap in re.escape()"?

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.

detect if a regex escape is needed in a pytest match statement
1 participant