Skip to content

Commit

Permalink
fix(lint): correct linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
bernardcooke53 committed Jan 3, 2024
1 parent 6835fca commit c9556b0
Show file tree
Hide file tree
Showing 9 changed files with 673 additions and 663 deletions.
1,294 changes: 647 additions & 647 deletions CHANGELOG.md

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions semantic_release/cli/commands/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,13 +371,13 @@ def version( # noqa: C901

elif commit_changes:
# TODO: in future this loop should be 1 line:
# repo.index.add(all_paths_to_add, force=False)
# repo.index.add(all_paths_to_add, force=False) # noqa: ERA001
# but since 'force' is deliberally ineffective (as in docstring) in gitpython 3.1.18
# we have to do manually add each filepath, and catch the exception if it is an ignored file
for updated_path in all_paths_to_add:
try:
repo.git.add(updated_path)
except GitCommandError:
except GitCommandError: # noqa: PERF203
log.warning("Failed to add path (%s) to index", updated_path)

rh = ReleaseHistory.from_git_history(
Expand Down Expand Up @@ -445,13 +445,13 @@ def version( # noqa: C901
elif commit_changes:
# Anything changed here should be staged.
# TODO: in future this loop should be 1 line:
# repo.index.add(updated_paths, force=False)
# repo.index.add(updated_paths, force=False) # noqa: ERA001
# but since 'force' is deliberally ineffective (as in docstring) in gitpython 3.1.18
# we have to do manually add each filepath, and catch the exception if it is an ignored file
for updated_path in updated_paths:
try:
repo.git.add(updated_path)
except GitCommandError:
except GitCommandError: # noqa: PERF203
log.warning("Failed to add path (%s) to index", updated_path)

def custom_git_environment() -> ContextManager[None]:
Expand Down
2 changes: 1 addition & 1 deletion semantic_release/cli/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class RemoteConfig(BaseModel):
ignore_token_for_push: bool = False

@model_validator(mode="after")
def set_default_token(self) -> "RemoteConfig":
def set_default_token(self) -> RemoteConfig:
# 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:
default_token_name = _known_hvcs[self.type].DEFAULT_ENV_TOKEN_NAME
Expand Down
2 changes: 1 addition & 1 deletion semantic_release/hvcs/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class HvcsBase:
checking for NotImplemented around every method call.
"""

DEFAULT_ENV_TOKEN_NAME = "HVCS_TOKEN"
DEFAULT_ENV_TOKEN_NAME = "HVCS_TOKEN" # noqa: S105

def __init__(
self,
Expand Down
2 changes: 1 addition & 1 deletion semantic_release/hvcs/gitea.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Gitea(HvcsBase):
DEFAULT_DOMAIN = "gitea.com"
DEFAULT_API_PATH = "/api/v1"
DEFAULT_API_DOMAIN = f"{DEFAULT_DOMAIN}{DEFAULT_API_PATH}"
DEFAULT_ENV_TOKEN_NAME = "GITEA_TOKEN"
DEFAULT_ENV_TOKEN_NAME = "GITEA_TOKEN" # noqa: S105

# pylint: disable=super-init-not-called
def __init__(
Expand Down
2 changes: 1 addition & 1 deletion semantic_release/hvcs/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Github(HvcsBase):
DEFAULT_DOMAIN = "github.com"
DEFAULT_API_DOMAIN = "api.github.com"
DEFAULT_UPLOAD_DOMAIN = "uploads.github.com"
DEFAULT_ENV_TOKEN_NAME = "GH_TOKEN"
DEFAULT_ENV_TOKEN_NAME = "GH_TOKEN" # noqa: S105

def __init__(
self,
Expand Down
2 changes: 1 addition & 1 deletion semantic_release/hvcs/gitlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Gitlab(HvcsBase):
API domain
"""

DEFAULT_ENV_TOKEN_NAME = "GITLAB_TOKEN"
DEFAULT_ENV_TOKEN_NAME = "GITLAB_TOKEN" # noqa: S105
# purposefully not CI_JOB_TOKEN as it is not a personal access token,
# It is missing the permission to push to the repository, but has all others (releases, packages, etc.)

Expand Down
22 changes: 16 additions & 6 deletions tests/fixtures/example_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@
import pytest
import tomlkit

from semantic_release.commit_parser import *
from semantic_release.hvcs import *
from semantic_release.commit_parser import (
AngularCommitParser,
EmojiCommitParser,
ScipyCommitParser,
TagCommitParser,
)
from semantic_release.hvcs import Gitea, Github, Gitlab

from tests.const import (
EXAMPLE_CHANGELOG_MD_CONTENT,
Expand All @@ -24,6 +29,9 @@
if TYPE_CHECKING:
from typing import Any, Protocol

from semantic_release.commit_parser import CommitParser
from semantic_release.hvcs import HvcsBase

ExProjectDir = Path

class UpdatePyprojectTomlFn(Protocol):
Expand All @@ -40,18 +48,20 @@ def __call__(self) -> type[CommitParser]:


@pytest.fixture
def change_to_tmp_dir(tmp_path: Path) -> Generator[None, None, None]:
def change_to_tmp_dir(tmp_path: Path) -> Generator[Path, None, None]:
cwd = os.getcwd()
os.chdir(str(tmp_path.resolve()))
try:
yield
yield Path(os.getcwd())
finally:
os.chdir(cwd)


@pytest.fixture
def example_project(change_to_tmp_dir: None) -> ExProjectDir:
tmp_path = Path.cwd()
def example_project(
change_to_tmp_dir: Path, # noqa: U100 # must be given as an argument
) -> ExProjectDir:
tmp_path = change_to_tmp_dir
src_dir = tmp_path / "src"
src_dir.mkdir()
example_dir = src_dir / EXAMPLE_PROJECT_NAME
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/semantic_release/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


@pytest.mark.parametrize(
("url", "expected"),
"url, expected",
[
(
"http://git.mycompany.com/username/myproject.git",
Expand Down

0 comments on commit c9556b0

Please sign in to comment.