Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore: re-enable ruff warnings#961

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion.github/workflows/main.yml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -77,7 +77,6 @@ jobs:
run: |
python -m ruff check . \
--config pyproject.toml \
--diff \
--output-format=full \
--exit-non-zero-on-fix

Expand Down
1 change: 0 additions & 1 deletion.github/workflows/pr.yml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -73,7 +73,6 @@ jobs:
- name: ruff
run: |
python -m ruff check . \
--diff \
--output-format=full \
--exit-non-zero-on-fix

Expand Down
2 changes: 2 additions & 0 deletionspyproject.toml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -222,6 +222,8 @@ ignore = [
"DTZ",
# flake8-errmsg
"EM",
# Some todos and some examples; leave this disabled for now
"ERA001",
# don't compare types, use isinstance()
# sometimes using type(x) == y is deliberately chosen to exclude
# subclasses
Expand Down
2 changes: 1 addition & 1 deletionsemantic_release/cli/commands/cli_context.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -58,7 +58,7 @@ def _init_runtime_ctx(self) -> RuntimeContext:

try:
if was_conf_file_user_provided and not conf_file_exists:
raise FileNotFoundError(
raise FileNotFoundError( # noqa: TRY301
f"File {self.global_opts.config_file} does not exist"
)

Expand Down
2 changes: 1 addition & 1 deletionsemantic_release/cli/commands/version.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -551,7 +551,7 @@ def version( # noqa: C901
check=True,
env=dict(
filter(
lambdak_v:k_v[1]isnotNone,# type: ignore
lambdak_v:k_v[1]isnotNone,# type: ignore # noqa: PGH003
{
# Common values
"PATH":os.getenv("PATH",""),
Expand Down
11 changes: 7 additions & 4 deletionssemantic_release/cli/config.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -145,9 +145,12 @@ def resolve_env_vars(cls, val: Any) -> str | None:
@model_validator(mode="after")
def set_default_token(self) -> Self:
# Set the default token name for the given VCS when no user input is given
if not self.token and self.type in _known_hvcs:
if env_token := self._get_default_token():
self.token = env_token
if self.token:
return self
if self.type not in _known_hvcs:
return self
if env_token := self._get_default_token():
self.token = env_token
return self

def _get_default_token(self) -> str | None:
Expand DownExpand Up@@ -406,7 +409,7 @@ def apply_log_masking(self, masker: MaskingFilter) -> MaskingFilter:
return masker

@classmethod
def from_raw_config(
def from_raw_config( # noqa: C901
cls, raw: RawConfig, global_cli_options: GlobalCommandLineOptions
) -> RuntimeContext:
##
Expand Down
2 changes: 1 addition & 1 deletionsemantic_release/commit_parser/_base.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -77,7 +77,7 @@ def __init__(self, options: _OPTS | None = None) -> None:
# @staticmethod
# @abstractmethod
defget_default_options(self)->_OPTS:
returnself.parser_options()# type: ignore
returnself.parser_options()# type: ignore # noqa: PGH003

@abstractmethod
defparse(self,commit:Commit)->_TT: ...
2 changes: 1 addition & 1 deletionsemantic_release/hvcs/bitbucket.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -59,7 +59,7 @@ def __init__(
hvcs_api_domain:str|None=None,
token:str|None=None,
allow_insecure:bool=False,
**kwargs:Any,
**kwargs:Any,# noqa: ARG002
)->None:
super().__init__(remote_url)
self.token=token
Expand Down
2 changes: 1 addition & 1 deletionsemantic_release/hvcs/gitea.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -43,7 +43,7 @@ def __init__(
hvcs_domain:str|None=None,
token:str|None=None,
allow_insecure:bool=False,
**kwargs:Any,
**_kwargs:Any,
)->None:
super().__init__(remote_url)
self.token=token
Expand Down
2 changes: 1 addition & 1 deletionsemantic_release/hvcs/github.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -89,7 +89,7 @@ def __init__(
hvcs_api_domain:str|None=None,
token:str|None=None,
allow_insecure:bool=False,
**kwargs:Any,
**_kwargs:Any,
)->None:
super().__init__(remote_url)
self.token=token
Expand Down
2 changes: 1 addition & 1 deletionsemantic_release/hvcs/gitlab.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -48,7 +48,7 @@ def __init__(
hvcs_domain:str|None=None,
token:str|None=None,
allow_insecure:bool=False,
**kwargs:Any,
**_kwargs:Any,
)->None:
super().__init__(remote_url)
self.token=token
Expand Down
2 changes: 1 addition & 1 deletionsemantic_release/hvcs/remote_hvcs_base.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -34,7 +34,7 @@ class RemoteHvcsBase(HvcsBase, metaclass=ABCMeta):

DEFAULT_ENV_TOKEN_NAME="HVCS_TOKEN"# noqa: S105

def__init__(self,remote_url:str,*args:Any,**kwargs:Any)->None:
def__init__(self,remote_url:str,*_args:Any,**_kwargs:Any)->None:
super().__init__(remote_url)
self._hvcs_domain:Url|None=None
self._api_url:Url|None=None
Expand Down
2 changes: 1 addition & 1 deletionsemantic_release/version/algorithm.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -431,7 +431,7 @@ def next_version(
)
level_bump=max(parsed_levels,default=LevelBump.NO_RELEASE)
log.info("The type of the next release release is: %s",level_bump)
iflevel_bumpisLevelBump.NO_RELEASE:
iflevel_bumpisLevelBump.NO_RELEASE:# noqa: SIM102
iflatest_version.major!=0orallow_zero_version:
log.info("No release will be made")
returnlatest_version
Expand Down
4 changes: 2 additions & 2 deletionstests/command_line/conftest.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,7 +9,7 @@
from click.testing import CliRunner
from requests_mock import ANY

from semantic_release.cli import config asCliConfigModule
from semantic_release.cli import config ascli_config_module
from semantic_release.cli.config import (
GlobalCommandLineOptions,
RawConfig,
Expand DownExpand Up@@ -57,7 +57,7 @@ def mocked_git_push(monkeypatch: MonkeyPatch) -> MagicMock:
"""Mock the `Repo.git.push()` method in `semantic_release.cli.main`."""
mocked_push = MagicMock()
cls = prepare_mocked_git_command_wrapper_type(push=mocked_push)
monkeypatch.setattr(CliConfigModule.Repo, "GitCommandWrapperType", cls)
monkeypatch.setattr(cli_config_module.Repo, "GitCommandWrapperType", cls)
return mocked_push


Expand Down
2 changes: 1 addition & 1 deletiontests/command_line/test_changelog.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -60,7 +60,7 @@
fromtests.fixtures.example_projectimportExProjectDir,UseReleaseNotesTemplateFn


changelog_subcmd=changelog.nameorchangelog.__name__# type: ignore
changelog_subcmd=changelog.nameorchangelog.__name__# type: ignore # noqa: PGH003


@pytest.mark.parametrize(
Expand Down
4 changes: 2 additions & 2 deletionstests/conftest.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,7 @@
fromtypingimportTYPE_CHECKING

importpytest
fromgitimportCommit
fromgitimportCommit,Repo

fromtests.fixturesimport*
fromtests.utilimportremove_dir_tree
Expand DownExpand Up@@ -57,7 +57,7 @@ def _netrc_file(machine: str) -> _TemporaryFileWrapper[str]:
exception=None
try:
yield_netrc_file
exceptExceptionaserr:
exceptExceptionaserr:# noqa: BLE001
exception=err
finally:
forcontext_managerinentered_context_managers:
Expand Down
2 changes: 1 addition & 1 deletiontests/unit/semantic_release/hvcs/test_gitlab.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -609,7 +609,7 @@ def test_create_or_update_release_when_create_fails_and_update_fails(
)

# Execute in mocked environment expecting a GitlabUpdateError to be raised
withcreate_release_patch,edit_release_notes_patch,get_release_by_id_patch:
withcreate_release_patch,edit_release_notes_patch,get_release_by_id_patch:# noqa: SIM117
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

What is this about... seems like aruff bug. gahh i hate using <1.0 released software.

Copy link
ContributorAuthor

@wyardleywyardleyJun 18, 2024
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

It's the nestedwith; the alternative they suggest is to dowith A() as a, B() as b:, but of course that would look pretty messy here, since the first line is 3 separate items....

https://docs.astral.sh/ruff/rules/multiple-with-statements/

If the raises could be a decorator, maybe that would look better, but I think just ignoring it is probably fine here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Well the doc doesn't consider this situation for creation of the context manger is multiple lines and prior to the with statement.

Yes, ignore is fine here.

withpytest.raises(gitlab.GitlabUpdateError):
default_gl_client.create_or_update_release(
A_GOOD_TAG,RELEASE_NOTES,prerelease
Expand Down
6 changes: 3 additions & 3 deletionstests/util.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,7 +12,7 @@

from semantic_release.changelog.context import make_changelog_context
from semantic_release.changelog.release_history import ReleaseHistory
from semantic_release.cli import config ascliConfigModule
from semantic_release.cli import config ascli_config_module
from semantic_release.commit_parser._base import CommitParser, ParserOptions
from semantic_release.commit_parser.token import ParsedCommit, ParseResult
from semantic_release.enums import LevelBump
Expand All@@ -37,7 +37,7 @@

_R = TypeVar("_R")

GitCommandWrapperType: TypeAlias =cliConfigModule.Repo.GitCommandWrapperType
GitCommandWrapperType: TypeAlias =cli_config_module.Repo.GitCommandWrapperType


def copy_dir_tree(src_dir: Path | str, dst_dir: Path | str) -> None:
Expand DownExpand Up@@ -162,7 +162,7 @@ def prepare_mocked_git_command_wrapper_type(
>>> mocked_push.assert_called_once()
"""

class MockGitCommandWrapperType(cliConfigModule.Repo.GitCommandWrapperType):
class MockGitCommandWrapperType(cli_config_module.Repo.GitCommandWrapperType):
def __getattr__(self, name: str) -> Any:
try:
return object.__getattribute__(self, f"mocked_{name}")
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp