Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump ruff from 0.3.4 to 0.9.1 #1096

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/setuptools_scm/_integration/setuptools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 3 additions & 3 deletions src/setuptools_scm/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/setuptools_scm/integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/setuptools_scm/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions testing/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion testing/test_file_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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() == []

Expand Down
2 changes: 1 addition & 1 deletion testing/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
4 changes: 2 additions & 2 deletions testing/test_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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")
Expand Down
6 changes: 3 additions & 3 deletions testing/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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"
Expand Down Expand Up @@ -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])
Expand Down
2 changes: 1 addition & 1 deletion testing/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
6 changes: 3 additions & 3 deletions testing/test_mercurial.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
)


@pytest.fixture()
@pytest.fixture
def wd(wd: WorkDir) -> WorkDir:
wd("hg init")
wd.add_command = "hg add ."
Expand Down Expand Up @@ -153,15 +153,15 @@ 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()
wd('hg tag 1.0.0 -u test -d "0 0"')
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")
Expand Down
2 changes: 1 addition & 1 deletion testing/test_regressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion testing/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
Loading