Skip to content

Commit d666502

Browse files
authored
chore: re-enable ruff warnings (python-semantic-release#961)
* ci: remove `--diff` flag from ruff check Having the `--diff` flag in `ruff check` seems to suppress failures from happening in CI * style: ignore or resolve ruff warnings
1 parent c54ec86 commit d666502

18 files changed

Lines changed: 27 additions & 24 deletions

File tree

.github/workflows/main.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ jobs:
7777
run: |
7878
python -m ruff check . \
7979
--config pyproject.toml \
80-
--diff \
8180
--output-format=full \
8281
--exit-non-zero-on-fix
8382

.github/workflows/pr.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ jobs:
7373
- name: ruff
7474
run: |
7575
python -m ruff check . \
76-
--diff \
7776
--output-format=full \
7877
--exit-non-zero-on-fix
7978

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,8 @@ ignore = [
222222
"DTZ",
223223
# flake8-errmsg
224224
"EM",
225+
# Some todos and some examples; leave this disabled for now
226+
"ERA001",
225227
# don't compare types, use isinstance()
226228
# sometimes using type(x) == y is deliberately chosen to exclude
227229
# subclasses

semantic_release/cli/commands/cli_context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def _init_runtime_ctx(self) -> RuntimeContext:
5858

5959
try:
6060
if was_conf_file_user_provided and not conf_file_exists:
61-
raise FileNotFoundError(
61+
raise FileNotFoundError( # noqa: TRY301
6262
f"File {self.global_opts.config_file} does not exist"
6363
)
6464

semantic_release/cli/commands/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ def version( # noqa: C901
551551
check=True,
552552
env=dict(
553553
filter(
554-
lambda k_v: k_v[1] is not None, # type: ignore
554+
lambda k_v: k_v[1] is not None, # type: ignore # noqa: PGH003
555555
{
556556
# Common values
557557
"PATH": os.getenv("PATH", ""),

semantic_release/cli/config.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,12 @@ def resolve_env_vars(cls, val: Any) -> str | None:
145145
@model_validator(mode="after")
146146
def set_default_token(self) -> Self:
147147
# Set the default token name for the given VCS when no user input is given
148-
if not self.token and self.type in _known_hvcs:
149-
if env_token := self._get_default_token():
150-
self.token = env_token
148+
if self.token:
149+
return self
150+
if self.type not in _known_hvcs:
151+
return self
152+
if env_token := self._get_default_token():
153+
self.token = env_token
151154
return self
152155

153156
def _get_default_token(self) -> str | None:
@@ -406,7 +409,7 @@ def apply_log_masking(self, masker: MaskingFilter) -> MaskingFilter:
406409
return masker
407410

408411
@classmethod
409-
def from_raw_config(
412+
def from_raw_config( # noqa: C901
410413
cls, raw: RawConfig, global_cli_options: GlobalCommandLineOptions
411414
) -> RuntimeContext:
412415
##

semantic_release/commit_parser/_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def __init__(self, options: _OPTS | None = None) -> None:
7777
# @staticmethod
7878
# @abstractmethod
7979
def get_default_options(self) -> _OPTS:
80-
return self.parser_options() # type: ignore
80+
return self.parser_options() # type: ignore # noqa: PGH003
8181

8282
@abstractmethod
8383
def parse(self, commit: Commit) -> _TT: ...

semantic_release/hvcs/bitbucket.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def __init__(
5959
hvcs_api_domain: str | None = None,
6060
token: str | None = None,
6161
allow_insecure: bool = False,
62-
**kwargs: Any,
62+
**kwargs: Any, # noqa: ARG002
6363
) -> None:
6464
super().__init__(remote_url)
6565
self.token = token

semantic_release/hvcs/gitea.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def __init__(
4343
hvcs_domain: str | None = None,
4444
token: str | None = None,
4545
allow_insecure: bool = False,
46-
**kwargs: Any,
46+
**_kwargs: Any,
4747
) -> None:
4848
super().__init__(remote_url)
4949
self.token = token

semantic_release/hvcs/github.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def __init__(
8989
hvcs_api_domain: str | None = None,
9090
token: str | None = None,
9191
allow_insecure: bool = False,
92-
**kwargs: Any,
92+
**_kwargs: Any,
9393
) -> None:
9494
super().__init__(remote_url)
9595
self.token = token

0 commit comments

Comments
 (0)