Skip to content
This repository was archived by the owner on Feb 17, 2021. It is now read-only.

Commit eacbe7e

Browse files
author
staticdev
committed
Strict mypy
1 parent 716fd4b commit eacbe7e

4 files changed

Lines changed: 47 additions & 14 deletions

File tree

mypy.ini

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,35 @@
11
[mypy]
2+
check_untyped_defs = True
3+
disallow_any_generics = True
4+
disallow_incomplete_defs = True
5+
disallow_subclassing_any = True
6+
disallow_untyped_calls = True
7+
disallow_untyped_decorators = True
8+
disallow_untyped_defs = True
9+
no_implicit_optional = True
10+
no_implicit_reexport = True
11+
pretty = True
12+
show_column_numbers = True
13+
show_error_codes = True
14+
show_error_context = True
15+
strict_equality = True
16+
warn_redundant_casts = True
17+
warn_return_any = True
18+
warn_unreachable = True
19+
warn_unused_configs = True
20+
warn_unused_ignores = True
221

3-
[mypy-tomlkit.*,pytest,pytest_mock,_pytest.*]
22+
[mypy-tests.*]
23+
disallow_untyped_decorators = False
24+
25+
[mypy-pytest]
26+
ignore_missing_imports = True
27+
28+
[mypy-_pytest.*]
29+
ignore_missing_imports = True
30+
31+
[mypy-pytest_mock]
32+
ignore_missing_imports = True
33+
34+
[mypy-tomlkit.*]
435
ignore_missing_imports = True

src/toml_validator/py.typed

Whitespace-only changes.

tests/test_main.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Test cases for the __main__ module."""
2+
from typing import Any
23
from unittest.mock import Mock
34

45
import pytest
@@ -15,28 +16,28 @@ def runner() -> CliRunner:
1516

1617

1718
@pytest.fixture
18-
def mock_validation_validate_extension(mocker: MockFixture) -> Mock:
19+
def mock_validation_validate_extension(mocker: MockFixture) -> Any:
1920
"""Fixture for mocking validation.validate_extension."""
2021
return mocker.patch("toml_validator.validation.validate_extension")
2122

2223

2324
@pytest.fixture
24-
def mock_validation_validate_toml_no_error(mocker: MockFixture) -> Mock:
25+
def mock_validation_validate_toml_no_error(mocker: MockFixture) -> Any:
2526
"""Fixture for mocking validation.validate_toml with no errors."""
2627
mock = mocker.patch("toml_validator.validation.validate_toml")
2728
mock.return_value = ""
2829
return mock
2930

3031

3132
@pytest.fixture
32-
def mock_validation_validate_toml_with_error(mocker: MockFixture) -> Mock:
33+
def mock_validation_validate_toml_with_error(mocker: MockFixture) -> Any:
3334
"""Fixture for mocking validation.validate_toml with error."""
3435
mock = mocker.patch("toml_validator.validation.validate_toml")
3536
mock.return_value = "|some error description|"
3637
return mock
3738

3839

39-
def test_main_without_argument(runner: CliRunner):
40+
def test_main_without_argument(runner: CliRunner) -> None:
4041
"""It exits with a status code of 2."""
4142
result = runner.invoke(__main__.main)
4243
assert result.exit_code == 2
@@ -46,7 +47,7 @@ def test_main_with_argument_success(
4647
runner: CliRunner,
4748
mock_validation_validate_extension: Mock,
4849
mock_validation_validate_toml_no_error: Mock,
49-
):
50+
) -> None:
5051
"""It exits with a status code of zero."""
5152
with runner.isolated_filesystem():
5253
with open("file.toml", "w") as f:
@@ -63,7 +64,7 @@ def test_main_with_argument_fail(
6364
runner: CliRunner,
6465
mock_validation_validate_extension: Mock,
6566
mock_validation_validate_toml_with_error: Mock,
66-
):
67+
) -> None:
6768
"""It outputs error."""
6869
with runner.isolated_filesystem():
6970
with open("file.toml", "w") as f:
@@ -77,7 +78,7 @@ def test_main_with_argument_fail(
7778

7879

7980
@pytest.mark.e2e
80-
def test_main_without_arguments_in_production_env(runner: CliRunner):
81+
def test_main_without_arguments_in_production_env(runner: CliRunner) -> None:
8182
"""It exits with a status code of 2 (e2e)."""
8283
result = runner.invoke(__main__.main)
8384
assert result.exit_code == 2

tests/test_validation.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Test cases for the validation module."""
2+
from typing import Any
23
from unittest.mock import Mock
34

45
import pytest
@@ -9,27 +10,27 @@
910

1011

1112
@pytest.fixture
12-
def mock_tomlkit_parse(mocker: MockFixture) -> Mock:
13+
def mock_tomlkit_parse(mocker: MockFixture) -> Any:
1314
"""Fixture for mocking tomlkit.parse."""
1415
return mocker.patch("tomlkit.parse")
1516

1617

1718
@pytest.fixture
18-
def mock_tomlkit_parse_exception(mocker: MockFixture) -> Mock:
19+
def mock_tomlkit_parse_exception(mocker: MockFixture) -> Any:
1920
"""Fixture for mocking tomlkit.parse."""
2021
mock = mocker.patch("tomlkit.parse")
2122
mock.side_effect = TOMLKitError("|some tomlkit error|")
2223
return mock
2324

2425

2526
@pytest.fixture
26-
def mock_open_valid_file(mocker: MockFixture) -> Mock:
27+
def mock_open_valid_file(mocker: MockFixture) -> Any:
2728
"""Fixture for mocking build-in open for valid TOML file."""
2829
return mocker.patch("builtins.open", mocker.mock_open(read_data="[x]\na = 3"))
2930

3031

3132
@pytest.fixture
32-
def mock_open_invalid_file(mocker: MockFixture) -> Mock:
33+
def mock_open_invalid_file(mocker: MockFixture) -> Any:
3334
"""Fixture for mocking build-in open for valid TOML file."""
3435
return mocker.patch(
3536
"builtins.open", mocker.mock_open(read_data="[x]\na = 3\n[x]\na = 3")
@@ -62,12 +63,12 @@ def test_validate_toml_with_error(
6263

6364

6465
@pytest.mark.e2e
65-
def test_validate_toml_no_error_production(mock_open_valid_file) -> None:
66+
def test_validate_toml_no_error_production(mock_open_valid_file: Mock) -> None:
6667
"""It returns no errors when valid TOML (e2e)."""
6768
assert validation.validate_toml("file.toml") == ""
6869

6970

7071
@pytest.mark.e2e
71-
def test_validate_toml_with_error_production(mock_open_invalid_file) -> None:
72+
def test_validate_toml_with_error_production(mock_open_invalid_file: Mock) -> None:
7273
"""It returns errors when invalid TOML (e2e)."""
7374
assert validation.validate_toml("file.toml") == 'Key "x" already exists.'

0 commit comments

Comments
 (0)