Skip to content

Commit

Permalink
mypy check everything
Browse files Browse the repository at this point in the history
move the strict enablement to the pyproject.toml so disabling checks
works correctly because `--strict` takes precedence over the file

Checking everything was disabled in 60205b9 due to (seemingly) a bug
  • Loading branch information
Artturin committed Oct 19, 2023
1 parent ff9b250 commit 0184fcd
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ python3.pkgs.buildPythonApplication {
echo -e "\x1b[32m## run ruff\x1b[0m"
ruff .
echo -e "\x1b[32m## run mypy\x1b[0m"
mypy --strict nixpkgs_review
mypy nixpkgs_review
echo -e "\x1b[32m## run nixpkgs-review --help\x1b[0m"
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,13 @@ exclude = '''

[tool.mypy]
python_version = "3.10"
strict = true
warn_redundant_casts = true
disallow_untyped_calls = true
disallow_untyped_defs = true
no_implicit_optional = true
# # Missing type parameters for generic type "CaptureFixture" [type-arg]
disallow_any_generics = false

[[tool.mypy.overrides]]
module = "setuptools.*"
Expand Down
3 changes: 1 addition & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ def nixpkgs() -> Iterator[Nixpkgs]:
yield setup_git(nixpkgs_path)


# pytest.fixture is untyped
@pytest.fixture # type: ignore
@pytest.fixture
def helpers() -> type[Helpers]:
return Helpers
14 changes: 9 additions & 5 deletions tests/test_pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import shutil
import subprocess
from unittest.mock import MagicMock, mock_open, patch
from unittest.mock import MagicMock, Mock, mock_open, patch

import pytest

Expand All @@ -13,14 +13,14 @@


@patch("nixpkgs_review.utils.shutil.which", return_value=None)
def test_default_to_nix_if_nom_not_found(mock_shutil):
def test_default_to_nix_if_nom_not_found(mock_shutil: Mock) -> None:
return_value = nix_nom_tool()
assert return_value == "nix"
mock_shutil.assert_called_once()


@pytest.mark.skipif(not shutil.which("nom"), reason="`nom` not found in PATH")
def test_pr_local_eval(helpers: Helpers, capfd) -> None:
def test_pr_local_eval(helpers: Helpers, capfd: pytest.CaptureFixture) -> None:
with helpers.nixpkgs() as nixpkgs:
with open(nixpkgs.path.joinpath("pkg1.txt"), "w") as f:
f.write("foo")
Expand All @@ -47,7 +47,9 @@ def test_pr_local_eval(helpers: Helpers, capfd) -> None:


@patch("nixpkgs_review.cli.nix_nom_tool", return_value="nix")
def test_pr_local_eval_missing_nom(mock_tool, helpers: Helpers, capfd) -> None:
def test_pr_local_eval_missing_nom(
mock_tool: Mock, helpers: Helpers, capfd: pytest.CaptureFixture
) -> None:
with helpers.nixpkgs() as nixpkgs:
with open(nixpkgs.path.joinpath("pkg1.txt"), "w") as f:
f.write("foo")
Expand All @@ -74,7 +76,9 @@ def test_pr_local_eval_missing_nom(mock_tool, helpers: Helpers, capfd) -> None:
assert "$ nix build" in captured.out


def test_pr_local_eval_without_nom(helpers: Helpers, capfd) -> None:
def test_pr_local_eval_without_nom(
helpers: Helpers, capfd: pytest.CaptureFixture
) -> None:
with helpers.nixpkgs() as nixpkgs:
with open(nixpkgs.path.joinpath("pkg1.txt"), "w") as f:
f.write("foo")
Expand Down
6 changes: 4 additions & 2 deletions tests/test_wip.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


@pytest.mark.skipif(not shutil.which("nom"), reason="`nom` not found in PATH")
def test_wip_command(helpers: Helpers, capfd) -> None:
def test_wip_command(helpers: Helpers, capfd: pytest.CaptureFixture) -> None:
with helpers.nixpkgs() as nixpkgs:
with open(nixpkgs.path.joinpath("pkg1.txt"), "w") as f:
f.write("foo")
Expand All @@ -24,7 +24,9 @@ def test_wip_command(helpers: Helpers, capfd) -> None:
assert "$ nom build" in captured.out


def test_wip_command_without_nom(helpers: Helpers, capfd) -> None:
def test_wip_command_without_nom(
helpers: Helpers, capfd: pytest.CaptureFixture
) -> None:
with helpers.nixpkgs() as nixpkgs:
with open(nixpkgs.path.joinpath("pkg1.txt"), "w") as f:
f.write("foo")
Expand Down

0 comments on commit 0184fcd

Please sign in to comment.