Skip to content

Commit a226508

Browse files
authored
Merge pull request #308 from input-output-hk/add_pyrefly_checker
feat(lint): add pyrefly and update linting configs
2 parents 457224b + 5e33288 commit a226508

File tree

5 files changed

+33
-5
lines changed

5 files changed

+33
-5
lines changed

.pre-commit-config.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ repos:
2828
- id: markdownlint
2929
- repo: local
3030
hooks:
31+
- id: pyrefly
32+
name: pyrefly
33+
entry: pyrefly
34+
args: [ check, --remove-unused-ignores ]
35+
pass_filenames: false
36+
language: system
37+
types: [python]
3138
- id: mypy
3239
name: mypy
3340
entry: mypy

cardano_clusterlib/clusterlib_klass.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def __init__(
4747
slots_offset: int | None = None,
4848
socket_path: itp.FileType = "",
4949
command_era: str = consts.CommandEras.LATEST,
50-
):
50+
) -> None:
5151
try:
5252
self.command_era = getattr(consts.CommandEras, command_era.upper())
5353
except AttributeError as excp:
@@ -59,6 +59,7 @@ def __init__(
5959
self.confirm_blocks = consts.CONFIRM_BLOCKS_NUM
6060
self._rand_str = helpers.get_rand_str(4)
6161
self._cli_log = ""
62+
# pyrefly: ignore # missing-attribute
6263
self.era_in_use = (
6364
consts.Eras.__members__.get(command_era.upper()) or consts.Eras["DEFAULT"]
6465
).name.lower()
@@ -100,6 +101,7 @@ def __init__(
100101
# Conway+ era
101102
self.conway_genesis_json: pl.Path | None = None
102103
self.conway_genesis: dict = {}
104+
# pyrefly: ignore # bad-specialization, bad-argument-type, not-a-type
103105
if consts.Eras[self.era_in_use.upper()].value >= consts.Eras.CONWAY.value:
104106
# Conway genesis
105107
self.conway_genesis_json = clusterlib_helpers._find_conway_genesis_json(
@@ -276,6 +278,7 @@ def cli(
276278
if retcode == 0:
277279
break
278280

281+
# pyrefly: ignore # missing-attribute
279282
stderr_dec = stderr.decode()
280283
err_msg = (
281284
f"An error occurred running a CLI command `{cmd_str}` on path "
@@ -289,6 +292,7 @@ def cli(
289292
else:
290293
raise exceptions.CLIError(err_msg)
291294

295+
# pyrefly: ignore # bad-argument-type
292296
return structs.CLIOut(stdout or b"", stderr or b"")
293297

294298
def refresh_pparams_file(self) -> None:

cardano_clusterlib/txtools.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,6 +1428,7 @@ def get_proposal_file_argname(era_in_use: str = "") -> str:
14281428
"""Return the name of the proposal file argument."""
14291429
proposal_file_argname = (
14301430
"--proposal-file"
1431+
# pyrefly: ignore # bad-specialization, bad-argument-type, not-a-type
14311432
if (consts.Eras[era_in_use.upper()].value >= consts.Eras.CONWAY.value)
14321433
else "--update-proposal-file"
14331434
)

pyproject.toml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,12 @@ force_single_line = true
4343
line-length = 100
4444

4545
[tool.ruff.lint]
46-
select = ["ARG", "B", "C4", "C90", "D", "DTZ", "E", "EM", "F", "FURB", "I001", "ISC", "N", "PERF", "PIE", "PL", "PLE", "PLR", "PLW", "PT", "PTH", "Q", "RET", "RSE", "RUF", "SIM", "TRY", "UP", "W", "YTT"]
46+
select = ["ANN", "ARG", "B", "C4", "C90", "D", "DTZ", "E", "EM", "F", "FURB", "I001", "ISC", "N", "PERF", "PIE", "PL", "PLE", "PLR", "PLW", "PT", "PTH", "Q", "RET", "RSE", "RUF", "SIM", "TRY", "UP", "W", "YTT"]
4747
ignore = ["D10", "D203", "D212", "D213", "D214", "D215", "D404", "D405", "D406", "D407", "D408", "D409", "D410", "D411", "D413", "ISC001", "PLR0912", "PLR0913", "PLR0915", "PT001", "PT007", "PT012", "PT018", "PT023", "PTH123", "RET504", "TRY002", "TRY301", "UP006", "UP007", "UP035"]
4848

49+
[tool.ruff.lint.per-file-ignores]
50+
"docs/**.py" = ["ANN"]
51+
4952
[tool.ruff.lint.isort]
5053
force-single-line = true
5154

@@ -56,6 +59,18 @@ ignore_missing_imports = true
5659
follow_imports = "normal"
5760
no_implicit_optional = true
5861
allow_untyped_globals = false
59-
allow_untyped_defs = false
6062
warn_unused_configs = true
6163
warn_return_any = true
64+
65+
[tool.pyrefly]
66+
project_includes = ["cardano_clusterlib"]
67+
ignore_errors_in_generated_code = true
68+
use_untyped_imports = true
69+
ignore_missing_source = true
70+
71+
[[tool.pyrefly.sub_config]]
72+
matches = "cardano_clusterlib/clusterlib_klass.py"
73+
74+
# Ignore the bad-argument-type errors for Self@ClusterLib, that are reported only for LSP
75+
[tool.pyrefly.sub_config.errors]
76+
bad-argument-type = false

requirements-dev.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
-e . --config-settings editable_mode=compat
22

33
# linting
4-
mypy
5-
pre-commit
4+
mypy~=1.15.0
5+
pyrefly~=0.17.0
6+
pre-commit~=4.2.0
67

78
build
89
virtualenv

0 commit comments

Comments
 (0)