ruff icon indicating copy to clipboard operation
ruff copied to clipboard

feat: distinguish * and ** in globs

Open JP-Ellis opened this issue 1 year ago • 2 comments

Summary

Set literal_separator to true for globs.

Motivation

By default, the globset crate matches files as per the .gitignore specifications which results in foo/*.py matching foo/hello.py as well as foo/bar/hello.py.

This commit changes this by setting the literal_separator option to true, which ensures that * and ? never match a path separator.

  • Resolves: #6262

Test Plan

So far, cargo test work, but please advise if you would like me to add new tests specifically for this change (and please point me in the right direction).

JP-Ellis avatar Apr 25 '24 02:04 JP-Ellis

I think I'm cool with changing this but it should probably be considered a breaking change (since files that were ignored will now be unignored).

charliermarsh avatar Apr 25 '24 02:04 charliermarsh

ruff-ecosystem results

Linter (stable)

ℹ️ ecosystem check detected linter changes. (+49511 -66 violations, +0 -0 fixes in 14 projects; 30 projects unchanged)

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

+ examples/interactions/converters.py:52:29: B008 Do not perform function call `commands.Param` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable
+ examples/interactions/injections.py:61:22: B008 Do not perform function call `commands.inject` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable
+ examples/interactions/injections.py:75:22: B008 Do not perform function call `commands.inject` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable
+ examples/interactions/param.py:68:26: B008 Do not perform function call `commands.Param` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable
+ scripts/ci/versiontool.py:64:5: S101 Use of `assert` detected
+ scripts/ci/versiontool.py:78:5: S101 Use of `assert` detected
+ scripts/codemods/base.py:47:13: S101 Use of `assert` detected
+ test_bot/cogs/injections.py:62:41: B008 Do not perform function call `commands.Param` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable
+ tests/ext/commands/test_base_core.py:102:9: S101 Use of `assert` detected
+ tests/ext/commands/test_base_core.py:28:13: S101 Use of `assert` detected
... 115 additional changes omitted for project
apache/airflow (+46555 -0 violations, +0 -0 fixes)

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

+ airflow/example_dags/libs/__init__.py:1:1: D104 Missing docstring in public package
+ airflow/example_dags/libs/helper.py:1:1: D100 Missing docstring in public module
+ airflow/example_dags/libs/helper.py:21:5: D103 Missing docstring in public function
+ airflow/example_dags/plugins/__init__.py:1:1: D104 Missing docstring in public package
+ airflow/example_dags/plugins/decreasing_priority_weight_strategy.py:1:1: D100 Missing docstring in public module
+ airflow/example_dags/plugins/decreasing_priority_weight_strategy.py:32:9: D102 Missing docstring in public method
+ airflow/example_dags/plugins/decreasing_priority_weight_strategy.py:36:7: D101 Missing docstring in public class
+ airflow/example_dags/plugins/event_listener.py:128:5: D200 One-line docstring should fit on one line
+ airflow/example_dags/plugins/event_listener.py:128:5: D212 [*] Multi-line docstring summary should start at the first line
+ airflow/example_dags/plugins/event_listener.py:128:5: D401 First line of docstring should be in imperative mood: "This method is called when dag run state changes to SUCCESS."
+ airflow/example_dags/plugins/event_listener.py:128:5: D404 First word of the docstring should not be "This"
+ airflow/example_dags/plugins/event_listener.py:144:5: D200 One-line docstring should fit on one line
+ airflow/example_dags/plugins/event_listener.py:144:5: D212 [*] Multi-line docstring summary should start at the first line
+ airflow/example_dags/plugins/event_listener.py:144:5: D401 First line of docstring should be in imperative mood: "This method is called when dag run state changes to FAILED."
+ airflow/example_dags/plugins/event_listener.py:144:5: D404 First word of the docstring should not be "This"
+ airflow/example_dags/plugins/event_listener.py:162:5: D200 One-line docstring should fit on one line
+ airflow/example_dags/plugins/event_listener.py:162:5: D212 [*] Multi-line docstring summary should start at the first line
+ airflow/example_dags/plugins/event_listener.py:162:5: D401 First line of docstring should be in imperative mood: "This method is called when dag run state changes to RUNNING."
+ airflow/example_dags/plugins/event_listener.py:162:5: D404 First word of the docstring should not be "This"
+ airflow/example_dags/plugins/event_listener.py:1:1: D100 Missing docstring in public module
+ airflow/example_dags/plugins/event_listener.py:33:5: D205 1 blank line required between summary line and description
+ airflow/example_dags/plugins/event_listener.py:33:5: D212 [*] Multi-line docstring summary should start at the first line
+ airflow/example_dags/plugins/event_listener.py:33:5: D401 First line of docstring should be in imperative mood: "This method is called when task state changes to RUNNING."
+ airflow/example_dags/plugins/event_listener.py:33:5: D404 First word of the docstring should not be "This"
+ airflow/example_dags/plugins/event_listener.py:68:5: D205 1 blank line required between summary line and description
+ airflow/example_dags/plugins/event_listener.py:68:5: D212 [*] Multi-line docstring summary should start at the first line
+ airflow/example_dags/plugins/event_listener.py:68:5: D401 First line of docstring should be in imperative mood: "This method is called when task state changes to SUCCESS."
+ airflow/example_dags/plugins/event_listener.py:68:5: D404 First word of the docstring should not be "This"
+ airflow/example_dags/plugins/event_listener.py:95:5: D205 1 blank line required between summary line and description
+ airflow/example_dags/plugins/event_listener.py:95:5: D212 [*] Multi-line docstring summary should start at the first line
... 1886 additional changes omitted for rule D212
+ airflow/example_dags/plugins/event_listener.py:95:5: D401 First line of docstring should be in imperative mood: "This method is called when task state changes to FAILED."
... 398 additional changes omitted for rule D401
+ airflow/example_dags/plugins/event_listener.py:95:5: D404 First word of the docstring should not be "This"
... 81 additional changes omitted for rule D404
+ airflow/example_dags/plugins/listener_plugin.py:1:1: D100 Missing docstring in public module
+ airflow/example_dags/plugins/listener_plugin.py:24:7: D101 Missing docstring in public class
+ airflow/example_dags/plugins/workday.py:45:7: D101 Missing docstring in public class
+ airflow/example_dags/plugins/workday.py:46:9: D102 Missing docstring in public method
+ airflow/example_dags/plugins/workday.py:60:9: D102 Missing docstring in public method
+ airflow/example_dags/plugins/workday.py:69:9: D102 Missing docstring in public method
+ airflow/example_dags/plugins/workday.py:99:7: D101 Missing docstring in public class
+ airflow/example_dags/subdags/__init__.py:1:1: D104 Missing docstring in public package
+ airflow/providers/arangodb/example_dags/__init__.py:1:1: D104 Missing docstring in public package
+ airflow/providers/arangodb/example_dags/example_arangodb.py:1:1: D100 Missing docstring in public module
+ airflow/providers/google/cloud/example_dags/__init__.py:1:1: D104 Missing docstring in public package
+ airflow/providers/google/cloud/example_dags/example_facebook_ads_to_gcs.py:18:1: D200 One-line docstring should fit on one line
+ airflow/providers/google/cloud/example_dags/example_looker.py:18:1: D205 1 blank line required between summary line and description
+ airflow/providers/google/cloud/example_dags/example_presto_to_gcs.py:18:1: D200 One-line docstring should fit on one line
... 46509 additional changes omitted for project
freedomofpress/securedrop (+208 -0 violations, +0 -0 fixes)

+ securedrop/tests/config_from_2014.py:40:22: S108 Probable insecure usage of temporary file or directory: "/tmp/journalist.pid"
+ securedrop/tests/config_from_2014.py:41:18: S108 Probable insecure usage of temporary file or directory: "/tmp/source.pid"
+ securedrop/tests/config_from_2014.py:70:23: S108 Probable insecure usage of temporary file or directory: "/tmp/securedrop"
+ securedrop/tests/conftest.py:110:37: S108 Probable insecure usage of temporary file or directory: "/tmp/sd-tests/conftest-"
+ securedrop/tests/conftest.py:310:33: S108 Probable insecure usage of temporary file or directory: "/tmp/securedrop_test_worker.pid"
+ securedrop/tests/conftest.py:328:28: S108 Probable insecure usage of temporary file or directory: "/tmp/test_rqworker.log"
... 6 additional changes omitted for rule S108
+ securedrop/tests/functional/app_navigators/journalist_app_nav.py:106:9: S101 Use of `assert` detected
+ securedrop/tests/functional/app_navigators/journalist_app_nav.py:122:9: S101 Use of `assert` detected
+ securedrop/tests/functional/app_navigators/journalist_app_nav.py:148:17: S101 Use of `assert` detected
+ securedrop/tests/functional/app_navigators/journalist_app_nav.py:172:9: S101 Use of `assert` detected
... 198 additional changes omitted for project
ibis-project/ibis (+7 -0 violations, +0 -0 fixes)

+ ibis/backends/tests/base.py:27:5: D205 1 blank line required between summary line and description
+ ibis/backends/tests/base.py:27:5: D212 [*] Multi-line docstring summary should start at the first line
+ ibis/backends/tests/base.py:337:5: D205 1 blank line required between summary line and description
+ ibis/backends/tests/base.py:81:9: D205 1 blank line required between summary line and description
+ ibis/backends/tests/base.py:81:9: D212 [*] Multi-line docstring summary should start at the first line
+ ibis/tests/util.py:25:5: D205 1 blank line required between summary line and description
+ ibis/tests/util.py:25:5: D209 [*] Multi-line docstring closing quotes should be on a separate line
mlflow/mlflow (+388 -4 violations, +0 -0 fixes)

+ dev/proto_to_graphql/autogeneration_utils.py:35:5: T201 `print` found
+ examples/auth/auth.py:56:9: T201 `print` found
+ examples/catboost/train.py:39:1: T201 `print` found
+ examples/databricks/log_runs.py:28:101: E501 Line too long (102 > 100)
+ examples/databricks/log_runs.py:41:5: T201 `print` found
+ examples/databricks/log_runs.py:5:101: E501 Line too long (106 > 100)
+ examples/databricks/multipart.py:138:9: T201 `print` found
+ examples/databricks/multipart.py:143:5: T201 `print` found
... 299 additional changes omitted for rule T201
+ examples/deployments/deployments_server/mistral/example.py:25:101: E501 Line too long (109 > 100)
+ examples/docker/train.py:3:101: E501 Line too long (135 > 100)
... 382 additional changes omitted for project

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

Changes by rule (56 rules affected)

code total + violation - violation + fix - fix
S101 19886 19886 0 0 0
D102 11929 11929 0 0 0
D103 2741 2741 0 0 0
D101 2242 2242 0 0 0
D212 1893 1893 0 0 0
D100 1694 1694 0 0 0
D400 1514 1514 0 0 0
D415 1509 1509 0 0 0
S113 1250 1250 0 0 0
D200 930 930 0 0 0
D205 853 853 0 0 0
D104 693 693 0 0 0
NPY002 476 476 0 0 0
D401 403 403 0 0 0
T201 325 325 0 0 0
D202 247 247 0 0 0
D107 122 122 0 0 0
FLY002 122 122 0 0 0
D404 86 86 0 0 0
S311 80 80 0 0 0
E501 65 65 0 0 0
D105 62 62 0 0 0
RUF012 54 54 0 0 0
D403 47 47 0 0 0
TRY002 37 37 0 0 0
D209 36 36 0 0 0
B028 35 35 0 0 0
A001 33 0 33 0 0
N806 16 16 0 0 0
B018 16 0 16 0 0
TID253 15 15 0 0 0
TID252 15 15 0 0 0
INP001 15 15 0 0 0
N802 15 15 0 0 0
TID251 13 13 0 0 0
S105 13 13 0 0 0
S108 11 11 0 0 0
UP031 11 7 4 0 0
A002 11 0 11 0 0
T203 9 9 0 0 0
RET504 9 9 0 0 0
B011 6 6 0 0 0
N803 6 6 0 0 0
B008 5 5 0 0 0
PERF203 5 5 0 0 0
D407 4 4 0 0 0
D413 3 3 0 0 0
PT018 2 2 0 0 0
D106 2 2 0 0 0
D419 2 2 0 0 0
PIE790 2 2 0 0 0
N812 2 2 0 0 0
E703 2 0 2 0 0
D406 1 1 0 0 0
D412 1 1 0 0 0
RUF018 1 1 0 0 0

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+49879 -93 violations, +0 -0 fixes in 15 projects; 29 projects unchanged)

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

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

+ examples/interactions/converters.py:52:29: B008 Do not perform function call `commands.Param` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable
+ examples/interactions/injections.py:61:22: B008 Do not perform function call `commands.inject` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable
+ examples/interactions/injections.py:75:22: B008 Do not perform function call `commands.inject` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable
+ examples/interactions/param.py:68:26: B008 Do not perform function call `commands.Param` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable
+ scripts/ci/versiontool.py:64:5: S101 Use of `assert` detected
+ scripts/ci/versiontool.py:78:5: S101 Use of `assert` detected
+ scripts/codemods/base.py:47:13: S101 Use of `assert` detected
+ test_bot/cogs/injections.py:62:41: B008 Do not perform function call `commands.Param` in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable
+ tests/ext/commands/test_base_core.py:102:9: S101 Use of `assert` detected
+ tests/ext/commands/test_base_core.py:28:13: S101 Use of `assert` detected
... 115 additional changes omitted for project
apache/airflow (+46555 -0 violations, +0 -0 fixes)

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

+ airflow/example_dags/libs/__init__.py:1:1: D104 Missing docstring in public package
+ airflow/example_dags/libs/helper.py:1:1: D100 Missing docstring in public module
+ airflow/example_dags/libs/helper.py:21:5: D103 Missing docstring in public function
+ airflow/example_dags/plugins/__init__.py:1:1: D104 Missing docstring in public package
+ airflow/example_dags/plugins/decreasing_priority_weight_strategy.py:1:1: D100 Missing docstring in public module
+ airflow/example_dags/plugins/decreasing_priority_weight_strategy.py:32:9: D102 Missing docstring in public method
+ airflow/example_dags/plugins/decreasing_priority_weight_strategy.py:36:7: D101 Missing docstring in public class
+ airflow/example_dags/plugins/event_listener.py:128:5: D200 One-line docstring should fit on one line
+ airflow/example_dags/plugins/event_listener.py:128:5: D212 [*] Multi-line docstring summary should start at the first line
+ airflow/example_dags/plugins/event_listener.py:128:5: D401 First line of docstring should be in imperative mood: "This method is called when dag run state changes to SUCCESS."
+ airflow/example_dags/plugins/event_listener.py:128:5: D404 First word of the docstring should not be "This"
+ airflow/example_dags/plugins/event_listener.py:144:5: D200 One-line docstring should fit on one line
+ airflow/example_dags/plugins/event_listener.py:144:5: D212 [*] Multi-line docstring summary should start at the first line
+ airflow/example_dags/plugins/event_listener.py:144:5: D401 First line of docstring should be in imperative mood: "This method is called when dag run state changes to FAILED."
+ airflow/example_dags/plugins/event_listener.py:144:5: D404 First word of the docstring should not be "This"
+ airflow/example_dags/plugins/event_listener.py:162:5: D200 One-line docstring should fit on one line
+ airflow/example_dags/plugins/event_listener.py:162:5: D212 [*] Multi-line docstring summary should start at the first line
+ airflow/example_dags/plugins/event_listener.py:162:5: D401 First line of docstring should be in imperative mood: "This method is called when dag run state changes to RUNNING."
+ airflow/example_dags/plugins/event_listener.py:162:5: D404 First word of the docstring should not be "This"
+ airflow/example_dags/plugins/event_listener.py:1:1: D100 Missing docstring in public module
+ airflow/example_dags/plugins/event_listener.py:33:5: D205 1 blank line required between summary line and description
+ airflow/example_dags/plugins/event_listener.py:33:5: D212 [*] Multi-line docstring summary should start at the first line
+ airflow/example_dags/plugins/event_listener.py:33:5: D401 First line of docstring should be in imperative mood: "This method is called when task state changes to RUNNING."
+ airflow/example_dags/plugins/event_listener.py:33:5: D404 First word of the docstring should not be "This"
+ airflow/example_dags/plugins/event_listener.py:68:5: D205 1 blank line required between summary line and description
+ airflow/example_dags/plugins/event_listener.py:68:5: D212 [*] Multi-line docstring summary should start at the first line
+ airflow/example_dags/plugins/event_listener.py:68:5: D401 First line of docstring should be in imperative mood: "This method is called when task state changes to SUCCESS."
+ airflow/example_dags/plugins/event_listener.py:68:5: D404 First word of the docstring should not be "This"
+ airflow/example_dags/plugins/event_listener.py:95:5: D205 1 blank line required between summary line and description
+ airflow/example_dags/plugins/event_listener.py:95:5: D212 [*] Multi-line docstring summary should start at the first line
... 1886 additional changes omitted for rule D212
+ airflow/example_dags/plugins/event_listener.py:95:5: D401 First line of docstring should be in imperative mood: "This method is called when task state changes to FAILED."
... 398 additional changes omitted for rule D401
+ airflow/example_dags/plugins/event_listener.py:95:5: D404 First word of the docstring should not be "This"
... 81 additional changes omitted for rule D404
+ airflow/example_dags/plugins/listener_plugin.py:1:1: D100 Missing docstring in public module
+ airflow/example_dags/plugins/listener_plugin.py:24:7: D101 Missing docstring in public class
+ airflow/example_dags/plugins/workday.py:45:7: D101 Missing docstring in public class
+ airflow/example_dags/plugins/workday.py:46:9: D102 Missing docstring in public method
+ airflow/example_dags/plugins/workday.py:60:9: D102 Missing docstring in public method
+ airflow/example_dags/plugins/workday.py:69:9: D102 Missing docstring in public method
+ airflow/example_dags/plugins/workday.py:99:7: D101 Missing docstring in public class
+ airflow/example_dags/subdags/__init__.py:1:1: D104 Missing docstring in public package
+ airflow/providers/arangodb/example_dags/__init__.py:1:1: D104 Missing docstring in public package
+ airflow/providers/arangodb/example_dags/example_arangodb.py:1:1: D100 Missing docstring in public module
+ airflow/providers/google/cloud/example_dags/__init__.py:1:1: D104 Missing docstring in public package
+ airflow/providers/google/cloud/example_dags/example_facebook_ads_to_gcs.py:18:1: D200 One-line docstring should fit on one line
+ airflow/providers/google/cloud/example_dags/example_looker.py:18:1: D205 1 blank line required between summary line and description
+ airflow/providers/google/cloud/example_dags/example_presto_to_gcs.py:18:1: D200 One-line docstring should fit on one line
... 46509 additional changes omitted for project
freedomofpress/securedrop (+208 -0 violations, +0 -0 fixes)

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

+ securedrop/tests/config_from_2014.py:40:22: S108 Probable insecure usage of temporary file or directory: "/tmp/journalist.pid"
+ securedrop/tests/config_from_2014.py:41:18: S108 Probable insecure usage of temporary file or directory: "/tmp/source.pid"
+ securedrop/tests/config_from_2014.py:70:23: S108 Probable insecure usage of temporary file or directory: "/tmp/securedrop"
+ securedrop/tests/conftest.py:110:37: S108 Probable insecure usage of temporary file or directory: "/tmp/sd-tests/conftest-"
+ securedrop/tests/conftest.py:310:33: S108 Probable insecure usage of temporary file or directory: "/tmp/securedrop_test_worker.pid"
+ securedrop/tests/conftest.py:328:28: S108 Probable insecure usage of temporary file or directory: "/tmp/test_rqworker.log"
... 6 additional changes omitted for rule S108
+ securedrop/tests/functional/app_navigators/journalist_app_nav.py:106:9: S101 Use of `assert` detected
+ securedrop/tests/functional/app_navigators/journalist_app_nav.py:122:9: S101 Use of `assert` detected
+ securedrop/tests/functional/app_navigators/journalist_app_nav.py:148:17: S101 Use of `assert` detected
+ securedrop/tests/functional/app_navigators/journalist_app_nav.py:172:9: S101 Use of `assert` detected
... 198 additional changes omitted for project
ibis-project/ibis (+7 -0 violations, +0 -0 fixes)

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

+ ibis/backends/tests/base.py:27:5: D205 1 blank line required between summary line and description
+ ibis/backends/tests/base.py:27:5: D212 [*] Multi-line docstring summary should start at the first line
+ ibis/backends/tests/base.py:337:5: D205 1 blank line required between summary line and description
+ ibis/backends/tests/base.py:81:9: D205 1 blank line required between summary line and description
+ ibis/backends/tests/base.py:81:9: D212 [*] Multi-line docstring summary should start at the first line
+ ibis/tests/util.py:25:5: D205 1 blank line required between summary line and description
+ ibis/tests/util.py:25:5: D209 [*] Multi-line docstring closing quotes should be on a separate line
mlflow/mlflow (+388 -22 violations, +0 -0 fixes)

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

+ dev/proto_to_graphql/autogeneration_utils.py:35:5: T201 `print` found
- docs/source/deep-learning/pytorch/quickstart/pytorch_quickstart.ipynb:cell 29:19:25: E226 [*] Missing whitespace around arithmetic operator
- docs/source/llms/llm-evaluate/notebooks/question-answering-evaluation.ipynb:cell 29:1:1: W391 [*] Extra newline at end of file
- docs/source/llms/llm-evaluate/notebooks/rag-evaluation.ipynb:cell 19:1:1: W391 [*] Extra newline at end of file
- docs/source/llms/openai/notebooks/openai-code-helper.ipynb:cell 28:13:21: C419 Unnecessary list comprehension
- docs/source/llms/rag/notebooks/question-generation-retrieval-evaluation.ipynb:cell 25:6:15: E226 [*] Missing whitespace around arithmetic operator
- docs/source/llms/rag/notebooks/retriever-evaluation-tutorial.ipynb:cell 50:1:1: W391 [*] Extra newline at end of file
- docs/source/llms/transformers/tutorials/text-generation/text-generation.ipynb:cell 18:14:34: E226 [*] Missing whitespace around arithmetic operator
- docs/source/traditional-ml/hyperparameter-tuning-with-child-runs/notebooks/parent-child-runs.ipynb:cell 15:1:1: W391 [*] Extra newline at end of file
- docs/source/traditional-ml/serving-multiple-models-with-pyfunc/notebooks/MME_Tutorial.ipynb:cell 25:1:1: W391 [*] Extra newline at end of file
... 400 additional changes omitted for project

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

Changes by rule (68 rules affected)

code total + violation - violation + fix - fix
S101 19886 19886 0 0 0
D102 11929 11929 0 0 0
D103 2741 2741 0 0 0
D101 2242 2242 0 0 0
D212 1893 1893 0 0 0
D100 1694 1694 0 0 0
D400 1514 1514 0 0 0
D415 1509 1509 0 0 0
S113 1250 1250 0 0 0
D200 930 930 0 0 0
D205 853 853 0 0 0
D104 693 693 0 0 0
NPY002 476 476 0 0 0
D401 403 403 0 0 0
T201 325 325 0 0 0
E241 268 268 0 0 0
D202 247 247 0 0 0
D107 122 122 0 0 0
FLY002 122 122 0 0 0
D404 86 86 0 0 0
S311 80 80 0 0 0
E272 79 79 0 0 0
E501 65 65 0 0 0
D105 62 62 0 0 0
RUF012 54 54 0 0 0
D403 47 47 0 0 0
TRY002 37 37 0 0 0
D209 36 36 0 0 0
B028 35 35 0 0 0
A001 33 0 33 0 0
N806 16 16 0 0 0
B018 16 0 16 0 0
TID253 15 15 0 0 0
TID252 15 15 0 0 0
INP001 15 15 0 0 0
N802 15 15 0 0 0
TID251 13 13 0 0 0
S105 13 13 0 0 0
S108 11 11 0 0 0
UP031 11 7 4 0 0
W391 11 0 11 0 0
A002 11 0 11 0 0
PLW0642 10 5 5 0 0
T203 9 9 0 0 0
RET504 9 9 0 0 0
PLC1901 7 7 0 0 0
RUF003 6 3 3 0 0
B011 6 6 0 0 0
N803 6 6 0 0 0
B008 5 5 0 0 0
PERF203 5 5 0 0 0
D407 4 4 0 0 0
E221 4 4 0 0 0
E226 4 0 4 0 0
D413 3 3 0 0 0
F841 3 2 1 0 0
PT018 2 2 0 0 0
D106 2 2 0 0 0
D419 2 2 0 0 0
PIE790 2 2 0 0 0
N812 2 2 0 0 0
E703 2 0 2 0 0
D406 1 1 0 0 0
D412 1 1 0 0 0
RUF018 1 1 0 0 0
C419 1 0 1 0 0
E266 1 0 1 0 0
E265 1 0 1 0 0

github-actions[bot] avatar Apr 25 '24 03:04 github-actions[bot]

It looks like this is going to cause churn for a lot of projects (based on the ecosystem checks) so we should double-confirm that we want this behavior.

charliermarsh avatar Jun 25 '24 10:06 charliermarsh

While I am open to suggestions for this PR, I do think that it would be good to follow a widely accepted convention such as the gitignore specification. Specifically the following from the specification:

  • An asterisk * matches anything except a slash. The character ? matches any one character except /. The range notation, e.g. [a-zA-Z], can be used to match one of the characters in a range. See fnmatch(3) and the FNM_PATHNAME flag for a more detailed description.

Two consecutive asterisks (**) in patterns matched against full pathname may have special meaning:

  • A leading ** followed by a slash means match in all directories. For example, **/foo matches file or directory foo anywhere, the same as pattern foo. **/foo/bar matches file or directory bar anywhere that is directly under directory foo.
  • A trailing /** matches everything inside. For example, abc/** matches all files inside directory abc, relative to the location of the .gitignore file, with infinite depth.
  • A slash followed by two consecutive asterisks then a slash matches zero or more directories. For example, a/**/b matches a/b, a/x/b, a/x/y/b and so on.
  • Other consecutive asterisks are considered regular asterisks and will match according to the previous rules.

To help with the transition, I might suggest two options:

  • An option to migrate configurations from 0.4 to 0.5. In most cases, it would suffice to replace all * to ** (though I suspect there will be edge cases).
  • Add a flag to opt in/out of the new way, allowing both behaviours temporarily.

Having said that, this would make the PR significantly more difficult for something which I suspect most developers will straightforwardly understand and adapt.

JP-Ellis avatar Jun 25 '24 11:06 JP-Ellis

I'm generally in favor of changing our semantics to match gitignore because it is a well-understood format and it makes copying patterns from gitignore to the ruff settings easier. It should also fix https://github.com/astral-sh/ruff/issues/8267

My main concern is that Ruff isn't fully compliant to gitignore even after this change. It still has the following inherited flake8/black behavior:

We have kind of a weird thing going on, which I think I followed from Flake8 or Black. When given a pattern like foo*.py, we match against both the basename and the absolute path (when testing to exclude a given file or directory). source

I think we should remove this behavior as well.

Having said that, I don't think it's feasible for us to ship this at the moment considering the amount of churn it creates. I think we need a way to ease migration for users by using a cargo like editions concept or provididing a migration tool that automatically rewrites/upgrades the configuration

Edit: My biggest concern isn't the churn of users getting spammed with lint-errors for files that are no longer ignored. I'm worried about the silent exclusion of files that no longer match the include patterns.

MichaReiser avatar Jun 25 '24 11:06 MichaReiser

I'll close this PR because there's no clear path of what needs to be done to merge it. We can continue the discussion in the linked issue.

MichaReiser avatar Jun 26 '24 08:06 MichaReiser