pyrefly icon indicating copy to clipboard operation
pyrefly copied to clipboard

Feature Request: Match list of globs in sub-config

Open dougthor42 opened this issue 6 months ago • 1 comments

Summary

It would be really nice if match supported a list of globs to match against within a sub-config

Example:

# disable "implicit-any" for paths that haven't been fixed yet.
[[sub-config]]
matches = [
    "sub/project/tests/file.py",
    "sub/project/foobar/**",
    "src/py/experimental/**",
]

[sub-config.errors]
implicit-any = false

Comparison to MyPy

mypy supports multiple modules within an override table:

# pyproject.toml
[tool.mypy]
strict_optional = true

[[tool.mypy.overrides]]
strict_optional = false
module = [
    # go/keep-sorted start
    "pkg1.auth",  # src/pkg1/auth.py
    "pkg1.backend",
    "pkg1.client",   # but the rest of "package/" uses strict_optional = true
    "pkg2.analysis.adaptive_fitting",
    "pkg2.analysis.adaptive_fitting_test",
    "pkg2.analysis.analog_modeling.analog_bare_finders",
    "pkg2.analysis.analog_modeling.spin_Hamiltonian_conversion",
    # ...
    # ~800 total python modules 😭 
]

In order to do the same thing within pyrefly, it would look like[^1]:

[[tool.pyrefly.sub-config]]
match = "src/pkg1/auth.py"  # pkg1.auth

[tool.pyrefly.sub-config.errors]
implicit-any = false

[[tool.pyrefly.sub-config]]
# a different file, but we can't glob `src/labrad/** because src/pkg1/foo.py
# and many more do use implicit-any
match = "src/pkg1/backend.py"

[tool.pyrefly.sub-config.errors]
implicit-any = false

# repeat ~800 times.

[^1]: Unless I'm missing some option. If so, please LMK!

dougthor42 avatar May 19 '26 18:05 dougthor42

https://github.com/kavix/pyrefly

Support multiple glob patterns in sub-config matches

kavix avatar May 21 '26 10:05 kavix