Skip to content
Merged
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: 1 addition & 2 deletions _own_version_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ def parse(root: str, config: Configuration) -> ScmVersion | None:
else:
if parsed is not None:
return parsed
else:
return None
return None


def scm_version() -> str:
Expand Down
3 changes: 1 addition & 2 deletions src/setuptools_scm/_entrypoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ def _get_ep(group: str, name: str) -> Any | None:
for ep in iter_entry_points(group, name):
log.debug("ep found: %s", ep.name)
return ep.load()
else:
return None
return None


def _get_from_object_reference_str(path: str, group: str) -> Any | None:
Expand Down
4 changes: 2 additions & 2 deletions src/setuptools_scm/_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


class AlwaysStdErrHandler(logging.StreamHandler): # type: ignore[type-arg]
def __init___(self) -> None:
def __init__(self) -> None:
super().__init__(sys.stderr)

@property # type: ignore [override]
Expand Down Expand Up @@ -51,7 +51,7 @@ def make_default_handler() -> logging.Handler:

def _default_log_level(_env: Mapping[str, str] = os.environ) -> int:
val: str | None = _env.get("SETUPTOOLS_SCM_DEBUG")
return logging.WARN if val is None else logging.DEBUG
return logging.WARNING if val is None else logging.DEBUG


log.setLevel(_default_log_level())
Expand Down
29 changes: 15 additions & 14 deletions src/setuptools_scm/_version_cls.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@
from packaging.version import InvalidVersion
from packaging.version import Version as Version
except ImportError:
from setuptools.extern.packaging.version import InvalidVersion # type: ignore
from setuptools.extern.packaging.version import Version as Version # type: ignore
from setuptools.extern.packaging.version import ( # type: ignore[import-untyped, no-redef]
InvalidVersion,
)
from setuptools.extern.packaging.version import ( # type: ignore[no-redef]
Version as Version,
)
from . import _log

log = _log.log.getChild("version_cls")
Expand Down Expand Up @@ -76,16 +80,13 @@ def _validate_version_cls(
"`normalize=False`"
)
return NonNormalizedVersion
# Use `version_cls` if provided, default to packaging or pkg_resources
elif version_cls is None:
return Version
elif isinstance(version_cls, str):
try:
return cast(Type[_VersionT], import_name(version_cls))
except Exception:
raise ValueError(f"Unable to import version_cls='{version_cls}'") from None
else:
# Use `version_cls` if provided, default to packaging or pkg_resources
if version_cls is None:
return Version
elif isinstance(version_cls, str):
try:
return cast(Type[_VersionT], import_name(version_cls))
except: # noqa
raise ValueError(
f"Unable to import version_cls='{version_cls}'"
) from None
else:
return version_cls
return version_cls
17 changes: 7 additions & 10 deletions src/setuptools_scm/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,6 @@ def version_from_describe(
config: Configuration,
describe_command: _t.CMD_TYPE | None,
) -> ScmVersion | None:
pass

if config.git_describe_command is not None:
describe_command = config.git_describe_command

Expand Down Expand Up @@ -323,15 +321,14 @@ def archival_to_version(
version = tag_to_version(ref, config)
if version is not None:
return meta(version, config=config)
node = data.get("node")
if node is None:
return None
elif "$FORMAT" in node.upper():
warnings.warn("unprocessed git archival found (no export subst applied)")
return None
else:
node = data.get("node")
if node is None:
return None
elif "$FORMAT" in node.upper():
warnings.warn("unprocessed git archival found (no export subst applied)")
return None
else:
return meta("0.0", node=node, config=config)
return meta("0.0", node=node, config=config)


def parse_archival(root: _t.PathT, config: Configuration) -> ScmVersion | None:
Expand Down
2 changes: 1 addition & 1 deletion src/setuptools_scm/hg.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ def get_meta(self, config: Configuration) -> ScmVersion | None:
return meta(tag, config=config, node_date=node_date)

except ValueError:
# unpacking failed, old hg
log.exception("error")
pass # unpacking failed, old hg

return None

Expand Down
15 changes: 7 additions & 8 deletions src/setuptools_scm/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,15 +263,14 @@ def guess_next_simple_semver(
def simplified_semver_version(version: ScmVersion) -> str:
if version.exact:
return guess_next_simple_semver(version, retain=SEMVER_LEN, increment=False)
elif version.branch is not None and "feature" in version.branch:
return version.format_next_version(
guess_next_simple_semver, retain=SEMVER_MINOR
)
else:
if version.branch is not None and "feature" in version.branch:
return version.format_next_version(
guess_next_simple_semver, retain=SEMVER_MINOR
)
else:
return version.format_next_version(
guess_next_simple_semver, retain=SEMVER_PATCH
)
return version.format_next_version(
guess_next_simple_semver, retain=SEMVER_PATCH
)


def release_branch_semver_version(version: ScmVersion) -> str:
Expand Down
2 changes: 1 addition & 1 deletion testing/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from setuptools_scm._cli import main

from .conftest import DebugMode
from .test_git import wd as wd_fixture # NOQA evil fixture reuse
from .test_git import wd as wd_fixture # noqa: F401 (evil fixture reuse)
from .wd_wrapper import WorkDir

PYPROJECT_TOML = "pyproject.toml"
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 @@ -16,7 +16,7 @@
def inwd(
request: pytest.FixtureRequest, wd: WorkDir, monkeypatch: pytest.MonkeyPatch
) -> WorkDir:
param: str = request.param # type: ignore
param: str = request.param # type: ignore[attr-defined]
if param == "git":
try:
wd("git init")
Expand Down
Loading