Skip to content

Commit

Permalink
ENH: remove excludes from Pyright config (#510)
Browse files Browse the repository at this point in the history
  • Loading branch information
redeboer authored Jan 29, 2025
1 parent cf86841 commit 3d8b979
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 26 deletions.
10 changes: 0 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,6 @@ ignore_missing_imports = true
module = ["nbformat.*"]

[tool.pyright]
exclude = [
"**/.git",
"**/.ipynb_checkpoints",
"**/.mypy_cache",
"**/.pytest_cache",
"**/.tox",
"**/.venv/",
"**/__pycache__",
"**/_build",
]
reportArgumentType = false
reportGeneralTypeIssues = false
reportIncompatibleMethodOverride = false
Expand Down
2 changes: 1 addition & 1 deletion src/compwa_policy/check_dev_files/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def main(argv: Sequence[str] | None = None) -> int: # noqa: PLR0915
)
do(mypy.main)
do(pyproject.main, excluded_python_versions, no_pypi=args.no_pypi)
do(pyright.main, package_manager, precommit_config)
do(pyright.main, precommit_config)
do(pytest.main)
do(pyupgrade.main, precommit_config, args.no_ruff)
if not args.no_ruff:
Expand Down
23 changes: 8 additions & 15 deletions src/compwa_policy/check_dev_files/pyright.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@
from compwa_policy.utilities.toml import to_toml_array

if TYPE_CHECKING:
from compwa_policy.check_dev_files.conda import PackageManagerChoice
from compwa_policy.utilities.precommit import ModifiablePrecommit


def main(package_manager: PackageManagerChoice, precommit: ModifiablePrecommit) -> None:
def main(precommit: ModifiablePrecommit) -> None:
with ModifiablePyproject.load() as pyproject:
_merge_config_into_pyproject(pyproject)
_update_precommit(precommit, pyproject)
_update_excludes(package_manager, pyproject)
_remove_excludes(pyproject)
_update_settings(pyproject)


Expand Down Expand Up @@ -66,21 +65,15 @@ def _update_precommit(precommit: ModifiablePrecommit, pyproject: Pyproject) -> N
precommit.update_single_hook_repo(repo)


def _update_excludes(
package_manager: PackageManagerChoice, pyproject: ModifiablePyproject
) -> None:
def _remove_excludes(pyproject: ModifiablePyproject) -> None:
if not __has_pyright(pyproject):
return
pyright_settings = pyproject.get_table("tool.pyright")
existing_excludes = pyright_settings.get("exclude", [])
expected_excludes = set(existing_excludes)
if "uv" in package_manager:
expected_excludes.add("**/.venv/")
expected_excludes_list = sorted(expected_excludes)
if existing_excludes != expected_excludes_list:
pyright_settings["exclude"] = to_toml_array(expected_excludes_list)
msg = "Updated pyright excludes"
pyproject.changelog.append(msg)
if "exclude" not in pyright_settings:
return
del pyright_settings["exclude"]
msg = "Removed pyright excludes"
pyproject.changelog.append(msg)


def _update_settings(pyproject: ModifiablePyproject) -> None:
Expand Down

0 comments on commit 3d8b979

Please sign in to comment.