diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d28a324c..a9397bcf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,8 +5,9 @@ repos: - id: trailing-whitespace - id: check-yaml - id: debug-statements + - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.3.4 + rev: v0.9.1 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix, --show-fixes] diff --git a/pyproject.toml b/pyproject.toml index ba539651..acb04a3b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -118,7 +118,6 @@ version = { attr = "_own_version_helper.version"} [tool.ruff] src = ["src"] -fix = true lint.select = ["E", "F", "B", "UP", "YTT", "C", "DTZ", "PYI", "PT", "I", "FURB", "RUF"] lint.ignore = ["B028"] lint.preview = true diff --git a/src/setuptools_scm/_integration/setuptools.py b/src/setuptools_scm/_integration/setuptools.py index 3ed48470..55ca1660 100644 --- a/src/setuptools_scm/_integration/setuptools.py +++ b/src/setuptools_scm/_integration/setuptools.py @@ -82,9 +82,9 @@ def version_keyword( assert isinstance(value, dict), "version_keyword expects a dict or True" overrides = value - assert ( - "dist_name" not in overrides - ), "dist_name may not be specified in the setup keyword " + assert "dist_name" not in overrides, ( + "dist_name may not be specified in the setup keyword " + ) dist_name: str | None = dist.metadata.name _log_hookstart("version_keyword", dist) diff --git a/src/setuptools_scm/git.py b/src/setuptools_scm/git.py index 7eccf198..246df477 100644 --- a/src/setuptools_scm/git.py +++ b/src/setuptools_scm/git.py @@ -145,12 +145,12 @@ def fetch_shallow(self) -> None: run_git(["fetch", "--unshallow"], self.path, check=True, timeout=240) def node(self) -> str | None: - _unsafe_short_node = operator.itemgetter(slice(7)) + unsafe_short_node = operator.itemgetter(slice(7)) return run_git( ["rev-parse", "--verify", "--quiet", "HEAD"], self.path ).parse_success( - parse=_unsafe_short_node, + parse=unsafe_short_node, ) def count_all_nodes(self) -> int: @@ -250,7 +250,7 @@ def parse_describe(output: str) -> ScmVersion: def _git_parse_inner( config: Configuration, wd: GitWorkdir | hg_git.GitWorkdirHgClient, - pre_parse: None | (Callable[[GitWorkdir | hg_git.GitWorkdirHgClient], None]) = None, + pre_parse: (Callable[[GitWorkdir | hg_git.GitWorkdirHgClient], None]) | None = None, describe_command: _t.CMD_TYPE | None = None, ) -> ScmVersion: if pre_parse: diff --git a/src/setuptools_scm/integration.py b/src/setuptools_scm/integration.py index 48874e38..b15d74a6 100644 --- a/src/setuptools_scm/integration.py +++ b/src/setuptools_scm/integration.py @@ -10,7 +10,7 @@ log = logging.getLogger(__name__) -def data_from_mime(path: _t.PathT, content: None | str = None) -> dict[str, str]: +def data_from_mime(path: _t.PathT, content: str | None = None) -> dict[str, str]: """return a mapping from mime/pseudo-mime content :param path: path to the mime file :param content: content of the mime file, if None, read from path diff --git a/src/setuptools_scm/version.py b/src/setuptools_scm/version.py index 43d23e54..ef36be4f 100644 --- a/src/setuptools_scm/version.py +++ b/src/setuptools_scm/version.py @@ -381,8 +381,7 @@ def guess_next_date_ver( if tag_date > head_date and match is not None: # warn on future times warnings.warn( - f"your previous tag ({tag_date})" - f" is ahead your node date ({head_date})" + f"your previous tag ({tag_date}) is ahead your node date ({head_date})" ) patch = 0 next_version = "{node_date:{date_fmt}}.{patch}".format( diff --git a/testing/conftest.py b/testing/conftest.py index d1c96ed3..09b69c1a 100644 --- a/testing/conftest.py +++ b/testing/conftest.py @@ -79,14 +79,14 @@ def debug_mode() -> Iterator[DebugMode]: yield debug_mode -@pytest.fixture() +@pytest.fixture def wd(tmp_path: Path) -> WorkDir: target_wd = tmp_path.resolve() / "wd" target_wd.mkdir() return WorkDir(target_wd) -@pytest.fixture() +@pytest.fixture def repositories_hg_git(tmp_path: Path) -> tuple[WorkDir, WorkDir]: tmp_path = tmp_path.resolve() path_git = tmp_path / "repo_git" diff --git a/testing/test_file_finder.py b/testing/test_file_finder.py index 5af94fcf..cc1a08fd 100644 --- a/testing/test_file_finder.py +++ b/testing/test_file_finder.py @@ -212,7 +212,7 @@ def test_symlink_not_in_scm_while_target_is(inwd: WorkDir) -> None: @pytest.mark.issue(587) -@pytest.mark.skip_commit() +@pytest.mark.skip_commit def test_not_commited(inwd: WorkDir) -> None: assert find_files() == [] diff --git a/testing/test_functions.py b/testing/test_functions.py index 5f394b0b..d6c4e711 100644 --- a/testing/test_functions.py +++ b/testing/test_functions.py @@ -81,7 +81,7 @@ def test_dump_version_doesnt_bail_on_value_error(tmp_path: Path) -> None: write_to = "VERSION" version = str(VERSIONS["exact"].tag) scm_version = meta(VERSIONS["exact"].tag, config=c) - with pytest.raises(ValueError, match="^bad file format:"): + with pytest.raises(ValueError, match=r"^bad file format:"): dump_version(tmp_path, version, write_to, scm_version=scm_version) diff --git a/testing/test_git.py b/testing/test_git.py index 661dcb76..9186b1a6 100644 --- a/testing/test_git.py +++ b/testing/test_git.py @@ -307,7 +307,7 @@ def test_git_worktree_support(wd: WorkDir, tmp_path: Path) -> None: assert str(worktree) in res.stdout -@pytest.fixture() +@pytest.fixture def shallow_wd(wd: WorkDir, tmp_path: Path) -> Path: wd.commit_testfile() wd.commit_testfile() @@ -515,7 +515,7 @@ def test_git_getdate_git_2_45_0_plus( assert git_wd.get_head_date() == date(2024, 4, 30) -@pytest.fixture() +@pytest.fixture def signed_commit_wd(monkeypatch: pytest.MonkeyPatch, wd: WorkDir) -> WorkDir: if not has_command("gpg", args=["--version"], warn=False): pytest.skip("gpg executable not found") diff --git a/testing/test_integration.py b/testing/test_integration.py index 86c8cbee..ba1cdb67 100644 --- a/testing/test_integration.py +++ b/testing/test_integration.py @@ -23,7 +23,7 @@ c = Configuration() -@pytest.fixture() +@pytest.fixture def wd(wd: WorkDir) -> WorkDir: wd("git init") wd("git config user.email test@example.com") @@ -34,7 +34,7 @@ def wd(wd: WorkDir) -> WorkDir: def test_pyproject_support(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None: - if sys.version_info <= (3, 10): + if sys.version_info < (3, 11): pytest.importorskip("tomli") monkeypatch.delenv("SETUPTOOLS_SCM_DEBUG") pkg = tmp_path / "package" @@ -97,7 +97,7 @@ def test_pyproject_support(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> N @with_metadata_in def test_pyproject_support_with_git(wd: WorkDir, metadata_in: str) -> None: - if sys.version_info <= (3, 10): + if sys.version_info < (3, 11): pytest.importorskip("tomli") wd.write("pyproject.toml", PYPROJECT_FILES[metadata_in]) wd.write("setup.py", SETUP_PY_FILES[metadata_in]) diff --git a/testing/test_main.py b/testing/test_main.py index ad9a2903..3c0ff3f8 100644 --- a/testing/test_main.py +++ b/testing/test_main.py @@ -20,7 +20,7 @@ def test_main() -> None: exec(code, ns) -@pytest.fixture() +@pytest.fixture def repo(wd: WorkDir) -> WorkDir: wd("git init") wd("git config user.email user@host") diff --git a/testing/test_mercurial.py b/testing/test_mercurial.py index b51c3fd9..57073716 100644 --- a/testing/test_mercurial.py +++ b/testing/test_mercurial.py @@ -21,7 +21,7 @@ ) -@pytest.fixture() +@pytest.fixture def wd(wd: WorkDir) -> WorkDir: wd("hg init") wd.add_command = "hg add ." @@ -153,7 +153,7 @@ def test_parse_no_worktree(tmp_path: Path) -> None: assert ret is None -@pytest.fixture() +@pytest.fixture def version_1_0(wd: WorkDir) -> WorkDir: wd("hg branch default") wd.commit_testfile() @@ -161,7 +161,7 @@ def version_1_0(wd: WorkDir) -> WorkDir: return wd -@pytest.fixture() +@pytest.fixture def pre_merge_commit_after_tag(version_1_0: WorkDir) -> WorkDir: wd = version_1_0 wd("hg branch testbranch") diff --git a/testing/test_regressions.py b/testing/test_regressions.py index d523f60c..385549c2 100644 --- a/testing/test_regressions.py +++ b/testing/test_regressions.py @@ -127,6 +127,6 @@ def test_write_to_absolute_path_passes_when_subdir_of_root(tmp_path: Path) -> No with pytest.raises( # todo: python version specific error list ValueError, - match=".*VERSION.py' .* .*subdir.*", + match=r".*VERSION.py' .* .*subdir.*", ): write_version_files(replace(c, root=subdir), "1.0", v) diff --git a/testing/test_version.py b/testing/test_version.py index 5233ef57..edbb9dae 100644 --- a/testing/test_version.py +++ b/testing/test_version.py @@ -235,7 +235,7 @@ def __str__(self) -> str: config = Configuration(version_cls=YikesVersion) # type: ignore[arg-type] with pytest.raises( ValueError, - match=".*does not end with a number to bump, " + match=r".*does not end with a number to bump, " "please correct or use a custom version scheme", ): guess_next_version(tag_version=meta("2.0.0-alpha.5-PMC", config=config))