Skip to content

Commit 02a8c9c

Browse files
committed
style: add additional lint groups (ICN, ISC, N, RET, RSE)
1 parent 625f549 commit 02a8c9c

File tree

10 files changed

+17
-14
lines changed

10 files changed

+17
-14
lines changed

copier/errors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class ExtensionNotFoundError(UserMessageError):
7272
"""Extensions listed in the configuration could not be loaded."""
7373

7474

75-
class CopierAnswersInterrupt(CopierError, KeyboardInterrupt):
75+
class CopierAnswersInterruptError(CopierError, KeyboardInterrupt):
7676
"""CopierAnswersInterrupt is raised during interactive question prompts.
7777
7878
It typically follows a KeyboardInterrupt (i.e. ctrl-c) and provides an

copier/jinja_ext.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class YieldExtension(Extension):
6060
```
6161
""" # noqa: E501
6262

63-
tags = {"yield"}
63+
tags = {"yield"} # noqa: RUF012
6464

6565
environment: YieldEnvironment
6666

copier/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
from questionary import unsafe_prompt
4040

4141
from .errors import (
42-
CopierAnswersInterrupt,
42+
CopierAnswersInterruptError,
4343
ExtensionNotFoundError,
4444
UnsafeTemplateError,
4545
UserMessageError,
@@ -561,7 +561,7 @@ def _ask(self) -> None: # noqa: C901
561561
answers={question.var_name: question.get_default()},
562562
)[question.var_name]
563563
except KeyboardInterrupt as err:
564-
raise CopierAnswersInterrupt(
564+
raise CopierAnswersInterruptError(
565565
self.answers, question, self.template
566566
) from err
567567
self.answers.user[var_name] = new_answer

copier/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def from_file(cls, settings_path: Path | None = None) -> Settings:
3939
if settings_path.is_file():
4040
data = yaml.safe_load(settings_path.read_text())
4141
return cls.model_validate(data)
42-
elif env_path:
42+
if env_path:
4343
warnings.warn(
4444
f"Settings file not found at {env_path}", MissingSettingsWarning
4545
)

copier/template.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ def _raw_config(self) -> AnyByStrDict:
260260
]
261261
if len(conf_paths) > 1:
262262
raise MultipleConfigFilesError(conf_paths)
263-
elif len(conf_paths) == 1:
263+
if len(conf_paths) == 1:
264264
return load_template_config(conf_paths[0])
265265
return {}
266266

copier/tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def cast_to_bool(value: Any) -> bool:
131131
lower = value.lower()
132132
if lower in {"y", "yes", "t", "true", "on"}:
133133
return True
134-
elif lower in {"n", "no", "f", "false", "off", "~", "null", "none"}:
134+
if lower in {"n", "no", "f", "false", "off", "~", "null", "none"}:
135135
return False
136136
# Assume nothing
137137
return bool(value)

copier/user_data.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,7 @@ def get_default(self) -> Any:
263263
result = self.render_value(
264264
self.settings.defaults.get(self.var_name, self.default)
265265
)
266-
result = self.cast_answer(result)
267-
return result
266+
return self.cast_answer(result)
268267

269268
def get_default_rendered(self) -> bool | str | Choice | None | MissingType:
270269
"""Get default answer rendered for the questionary lib.

pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,15 @@ extend-select = [
118118
"FLY",
119119
"FURB",
120120
"I",
121+
"ICN",
122+
"ISC",
123+
"N",
121124
"PERF",
122125
"PIE",
123126
"PGH",
124127
"PTH",
128+
"RET",
129+
"RSE",
125130
"RUF",
126131
"SIM",
127132
"UP",

tests/conftest.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,5 +89,4 @@ def config_path(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Iterator[Pat
8989
@pytest.fixture
9090
def settings_path(config_path: Path) -> Path:
9191
config_path.mkdir()
92-
settings_path = config_path / "settings.yml"
93-
return settings_path
92+
return config_path / "settings.yml"

tests/test_interrupts.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import pytest
44

55
from copier import Worker
6-
from copier.errors import CopierAnswersInterrupt
6+
from copier.errors import CopierAnswersInterruptError
77

88
from .helpers import build_file_tree
99

@@ -14,7 +14,7 @@
1414
# We override the prompt method from questionary to raise this
1515
# exception and expect our surrounding machinery to re-raise
1616
# it as a CopierAnswersInterrupt.
17-
CopierAnswersInterrupt(Mock(), Mock(), Mock()),
17+
CopierAnswersInterruptError(Mock(), Mock(), Mock()),
1818
KeyboardInterrupt,
1919
],
2020
)
@@ -66,7 +66,7 @@ def test_multiple_questions_interrupt(tmp_path_factory: pytest.TempPathFactory)
6666
KeyboardInterrupt,
6767
],
6868
):
69-
with pytest.raises(CopierAnswersInterrupt) as err:
69+
with pytest.raises(CopierAnswersInterruptError) as err:
7070
worker.run_copy()
7171
assert err.value.answers.user == {
7272
"question1": "foobar",

0 commit comments

Comments
 (0)