Skip to content

Commit

Permalink
Make mypy execution more reproducible
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea committed May 2, 2023
1 parent ea6dc0c commit 0f5e897
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 10 deletions.
1 change: 1 addition & 0 deletions .config/requirements-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pytest >= 7.2.2
pytest-mock
pytest-plus >= 0.2 # for PYTEST_REQPASS
pytest-xdist >= 2.1.0
ruamel-yaml-clib # needed for mypy
spdx-tools >= 0.7.1 # Apache
types-jsonschema # IDE support
types-pyyaml # IDE support
8 changes: 5 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ repos:
types: [file, yaml]
entry: yamllint --strict
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.0.263"
rev: "v0.0.264"
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand All @@ -148,7 +148,8 @@ repos:
- jinja2
- pytest>=7.2.2
- rich>=13.2.0
- ruamel.yaml
- ruamel-yaml>=0.17.22
- ruamel-yaml-clib>=0.2.7
- spdx-tools
- subprocess-tee
- types-PyYAML
Expand Down Expand Up @@ -177,7 +178,8 @@ repos:
- pytest>=7.2.2
- pyyaml
- rich>=13.2.0
- ruamel.yaml
- ruamel-yaml>=0.17.22
- ruamel-yaml-clib>=0.2.7
- spdx-tools
- typing_extensions
- wcmatch
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ disallow_any_generics = true
# warn_unused_configs = True
# site-packages is here to help vscode mypy integration getting confused
exclude = "(build|dist|test/local-content|site-packages|~/.pyenv|examples/playbooks/collections|plugins/modules)"
# https://github.com/python/mypy/issues/12664
no_incremental = true

[[tool.mypy.overrides]]
module = [
Expand Down
2 changes: 1 addition & 1 deletion src/ansiblelint/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class Options: # pylint: disable=too-many-instance-attributes,too-few-public-me
cache_dir: Path | None = None
colored: bool = True
configured: bool = False
cwd: Path = Path(".") # noqa: RUF009
cwd: Path = Path(".")
display_relative_path: bool = True
exclude_paths: list[str] = field(default_factory=list)
format: str = "brief" # noqa: A003
Expand Down
6 changes: 3 additions & 3 deletions src/ansiblelint/yaml_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -808,9 +808,9 @@ def __init__(
self.compact_seq_map = True # type: ignore[assignment] # key after dash

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

# If someone doesn't want our FormattedEmitter, they can change it.
self.Emitter = FormattedEmitter
Expand Down
6 changes: 3 additions & 3 deletions test/test_yaml_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,9 @@ def test_custom_ruamel_yaml_emitter(
"""Test ``ruamel.yaml.YAML.dump()`` sequence formatting and quotes."""
yaml = YAML(typ="rt")
# NB: ruamel.yaml does not have typehints, so mypy complains about everything here.
yaml.explicit_start = True # type: ignore[assignment]
yaml.map_indent = map_indent # type: ignore[assignment]
yaml.sequence_indent = sequence_indent # type: ignore[assignment]
yaml.explicit_start = True
yaml.map_indent = map_indent
yaml.sequence_indent = sequence_indent
yaml.sequence_dash_offset = sequence_dash_offset
if alternate_emitter is not None:
yaml.Emitter = alternate_emitter
Expand Down

0 comments on commit 0f5e897

Please sign in to comment.