Skip to content

Commit 0f5e897

Browse files
committed
Make mypy execution more reproducible
Related: python/mypy#12664 Related: python/mypy#8823
1 parent ea6dc0c commit 0f5e897

File tree

6 files changed

+15
-10
lines changed

6 files changed

+15
-10
lines changed

.config/requirements-test.txt

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ pytest >= 7.2.2
1010
pytest-mock
1111
pytest-plus >= 0.2 # for PYTEST_REQPASS
1212
pytest-xdist >= 2.1.0
13+
ruamel-yaml-clib # needed for mypy
1314
spdx-tools >= 0.7.1 # Apache
1415
types-jsonschema # IDE support
1516
types-pyyaml # IDE support

.pre-commit-config.yaml

+5-3
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ repos:
125125
types: [file, yaml]
126126
entry: yamllint --strict
127127
- repo: https://github.com/charliermarsh/ruff-pre-commit
128-
rev: "v0.0.263"
128+
rev: "v0.0.264"
129129
hooks:
130130
- id: ruff
131131
args: [--fix, --exit-non-zero-on-fix]
@@ -148,7 +148,8 @@ repos:
148148
- jinja2
149149
- pytest>=7.2.2
150150
- rich>=13.2.0
151-
- ruamel.yaml
151+
- ruamel-yaml>=0.17.22
152+
- ruamel-yaml-clib>=0.2.7
152153
- spdx-tools
153154
- subprocess-tee
154155
- types-PyYAML
@@ -177,7 +178,8 @@ repos:
177178
- pytest>=7.2.2
178179
- pyyaml
179180
- rich>=13.2.0
180-
- ruamel.yaml
181+
- ruamel-yaml>=0.17.22
182+
- ruamel-yaml-clib>=0.2.7
181183
- spdx-tools
182184
- typing_extensions
183185
- wcmatch

pyproject.toml

+2
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ disallow_any_generics = true
107107
# warn_unused_configs = True
108108
# site-packages is here to help vscode mypy integration getting confused
109109
exclude = "(build|dist|test/local-content|site-packages|~/.pyenv|examples/playbooks/collections|plugins/modules)"
110+
# https://github.com/python/mypy/issues/12664
111+
no_incremental = true
110112

111113
[[tool.mypy.overrides]]
112114
module = [

src/ansiblelint/config.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class Options: # pylint: disable=too-many-instance-attributes,too-few-public-me
106106
cache_dir: Path | None = None
107107
colored: bool = True
108108
configured: bool = False
109-
cwd: Path = Path(".") # noqa: RUF009
109+
cwd: Path = Path(".")
110110
display_relative_path: bool = True
111111
exclude_paths: list[str] = field(default_factory=list)
112112
format: str = "brief" # noqa: A003

src/ansiblelint/yaml_utils.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -808,9 +808,9 @@ def __init__(
808808
self.compact_seq_map = True # type: ignore[assignment] # key after dash
809809

810810
# Do not use yaml.indent() as it obscures the purpose of these vars:
811-
self.map_indent = 2 # type: ignore[assignment]
812-
self.sequence_indent = 4 if indent_sequences else 2 # type: ignore[assignment]
813-
self.sequence_dash_offset = self.sequence_indent - 2 # type: ignore[operator]
811+
self.map_indent = 2
812+
self.sequence_indent = 4 if indent_sequences else 2
813+
self.sequence_dash_offset = self.sequence_indent - 2
814814

815815
# If someone doesn't want our FormattedEmitter, they can change it.
816816
self.Emitter = FormattedEmitter

test/test_yaml_utils.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,9 @@ def test_custom_ruamel_yaml_emitter(
189189
"""Test ``ruamel.yaml.YAML.dump()`` sequence formatting and quotes."""
190190
yaml = YAML(typ="rt")
191191
# NB: ruamel.yaml does not have typehints, so mypy complains about everything here.
192-
yaml.explicit_start = True # type: ignore[assignment]
193-
yaml.map_indent = map_indent # type: ignore[assignment]
194-
yaml.sequence_indent = sequence_indent # type: ignore[assignment]
192+
yaml.explicit_start = True
193+
yaml.map_indent = map_indent
194+
yaml.sequence_indent = sequence_indent
195195
yaml.sequence_dash_offset = sequence_dash_offset
196196
if alternate_emitter is not None:
197197
yaml.Emitter = alternate_emitter

0 commit comments

Comments
 (0)