Skip to content

Commit

Permalink
refactor!(ruff): Run all automated fixes as of ruff 0.3.4
Browse files Browse the repository at this point in the history
ruff check --select ALL . --fix --unsafe-fixes --preview --show-fixes; ruff format .

Fixed 206 errors:
- conftest.py:
     1 × PIE790 (unnecessary-placeholder)
- docs/conf.py:
     1 × RET505 (superfluous-else-return)
- src/libvcs/__init__.py:
     1 × RUF022 (unsorted-dunder-all)
- src/libvcs/_internal/query_list.py:
     3 × RSE102 (unnecessary-paren-on-raise-exception)
     2 × ANN204 (missing-return-type-special-method)
     1 × T201 (print)
     1 × PLR5501 (collapsible-else-if)
     1 × RET505 (superfluous-else-return)
     1 × RET506 (superfluous-else-raise)
     1 × F841 (unused-variable)
- src/libvcs/_internal/run.py:
     1 × TID252 (relative-imports)
     1 × I001 (unsorted-imports)
- src/libvcs/_internal/shortcuts.py:
     3 × RET505 (superfluous-else-return)
     3 × ANN204 (missing-return-type-special-method)
     2 × COM812 (missing-trailing-comma)
     1 × PLR6201 (literal-membership)
- src/libvcs/_internal/subprocess.py:
     1 × ANN204 (missing-return-type-special-method)
- src/libvcs/cmd/git.py:
     1 × PLR5501 (collapsible-else-if)
     1 × PLR2044 (empty-comment)
     1 × RET505 (superfluous-else-return)
- src/libvcs/cmd/svn.py:
     1 × RSE102 (unnecessary-paren-on-raise-exception)
     1 × ANN204 (missing-return-type-special-method)
- src/libvcs/pytest_plugin.py:
    12 × PT001 (pytest-fixture-incorrect-parentheses-style)
     3 × PT003 (pytest-extraneous-scope-function)
     1 × ANN204 (missing-return-type-special-method)
     1 × E303 (too-many-blank-lines)
     1 × PT025 (pytest-erroneous-use-fixtures-on-fixture)
     1 × RET504 (unnecessary-assign)
     1 × SIM103 (needless-bool)
- src/libvcs/sync/base.py:
     1 × F841 (unused-variable)
     1 × RET504 (unnecessary-assign)
     1 × E303 (too-many-blank-lines)
- src/libvcs/sync/git.py:
     5 × ANN204 (missing-return-type-special-method)
     1 × TID252 (relative-imports)
     1 × RET505 (superfluous-else-return)
     1 × I001 (unsorted-imports)
     1 × PLR5501 (collapsible-else-if)
     1 × E303 (too-many-blank-lines)
     1 × PLR1714 (repeated-equality-comparison)
     1 × RSE102 (unnecessary-paren-on-raise-exception)
     1 × PIE804 (unnecessary-dict-kwargs)
     1 × F841 (unused-variable)
     1 × PLR6201 (literal-membership)
     1 × RET504 (unnecessary-assign)
- src/libvcs/sync/svn.py:
     1 × FURB167 (regex-flag-alias)
     1 × ANN204 (missing-return-type-special-method)
     1 × PIE810 (multiple-starts-ends-with)
- src/libvcs/url/base.py:
     1 × ANN204 (missing-return-type-special-method)
- src/libvcs/url/registry.py:
     1 × ANN204 (missing-return-type-special-method)
- src/libvcs/url/svn.py:
     2 × PLR2044 (empty-comment)
- tests/_internal/subprocess/test_SubprocessCommand.py:
     9 × PT007 (pytest-parametrize-values-wrong-type)
     6 × PT006 (pytest-parametrize-names-wrong-type)
     1 × PLW1510 (subprocess-run-without-check)
- tests/_internal/test_query_list.py:
    38 × PT007 (pytest-parametrize-values-wrong-type)
     1 × PT006 (pytest-parametrize-names-wrong-type)
- tests/sync/test_git.py:
    38 × PT007 (pytest-parametrize-values-wrong-type)
    12 × PT006 (pytest-parametrize-names-wrong-type)
    10 × PIE804 (unnecessary-dict-kwargs)
     1 × COM812 (missing-trailing-comma)
- tests/test_shortcuts.py:
     1 × PT006 (pytest-parametrize-names-wrong-type)
- tests/url/test_git.py:
     4 × PT006 (pytest-parametrize-names-wrong-type)
- tests/url/test_hg.py:
     3 × PT006 (pytest-parametrize-names-wrong-type)
     1 × PT014 (pytest-duplicate-parametrize-test-cases)
- tests/url/test_registry.py:
     1 × FURB148 (unnecessary-enumerate)
- tests/url/test_svn.py:
     3 × PT006 (pytest-parametrize-names-wrong-type)
     1 × PT014 (pytest-duplicate-parametrize-test-cases)
  • Loading branch information
tony committed Mar 24, 2024
1 parent 7720bbc commit 6b51eda
Show file tree
Hide file tree
Showing 24 changed files with 307 additions and 354 deletions.
1 change: 0 additions & 1 deletion conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,3 @@ def setup(
set_home: pathlib.Path,
) -> None:
"""Configure test fixtures for pytest."""
pass
17 changes: 8 additions & 9 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,15 +209,14 @@ def linkcode_resolve(domain: str, info: dict[str, str]) -> t.Union[None, str]:
fn,
linespec,
)
else:
return "{}/blob/v{}/{}/{}/{}{}".format(
about["__github__"],
about["__version__"],
"src",
about["__package_name__"],
fn,
linespec,
)
return "{}/blob/v{}/{}/{}/{}{}".format(
about["__github__"],
about["__version__"],
"src",
about["__package_name__"],
fn,
linespec,
)


def remove_tabs_js(app: "Sphinx", exc: Exception) -> None:
Expand Down
4 changes: 2 additions & 2 deletions src/libvcs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
from .sync.svn import SvnSync

__all__ = [
"BaseSync",
"CmdLoggingAdapter",
"GitSync",
"HgSync",
"SvnSync",
"BaseSync",
"CmdLoggingAdapter",
]

logger = logging.getLogger(__name__)
23 changes: 10 additions & 13 deletions src/libvcs/_internal/query_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,8 @@ def keygetter(
dct = dct[sub_field]
elif hasattr(dct, sub_field):
dct = getattr(dct, sub_field)
except Exception as e:
except Exception:
traceback.print_stack()
print(f"Above error was {e}")
return None
return dct

Expand Down Expand Up @@ -304,12 +303,12 @@ def lookup_iregex(


class PKRequiredException(Exception):
def __init__(self, *args: object):
def __init__(self, *args: object) -> None:
return super().__init__("items() require a pk_key exists")


class OpNotFound(ValueError):
def __init__(self, op: str, *args: object):
def __init__(self, op: str, *args: object) -> None:
return super().__init__(f"{op} not in LOOKUP_NAME_MAP")


Expand Down Expand Up @@ -470,7 +469,7 @@ def __init__(self, items: t.Optional["Iterable[T]"] = None) -> None:

def items(self) -> list[tuple[str, T]]:
if self.pk_key is None:
raise PKRequiredException()
raise PKRequiredException
return [(getattr(item, self.pk_key), item) for item in self]

def __eq__(
Expand All @@ -490,9 +489,8 @@ def __eq__(
for key in a_keys:
if abs(a[key] - b[key]) > 1:
return False
else:
if a != b:
return False
elif a != b:
return False

return True
return False
Expand Down Expand Up @@ -529,8 +527,7 @@ def filter_lookup(obj: t.Any) -> bool:
def val_match(obj: t.Union[str, list[t.Any], T]) -> bool:
if isinstance(matcher, list):
return obj in matcher
else:
return bool(obj == matcher)
return bool(obj == matcher)

_filter = val_match
else:
Expand All @@ -546,9 +543,9 @@ def get(
) -> t.Optional[T]:
objs = self.filter(matcher=matcher, **kwargs)
if len(objs) > 1:
raise MultipleObjectsReturned()
elif len(objs) == 0:
raise MultipleObjectsReturned
if len(objs) == 0:
if default == no_arg:
raise ObjectDoesNotExist()
raise ObjectDoesNotExist
return default
return objs[0]
3 changes: 1 addition & 2 deletions src/libvcs/_internal/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
from collections.abc import Iterable, Mapping, MutableMapping, Sequence
from typing import IO, TYPE_CHECKING, Any, AnyStr, Callable, Optional, Protocol, Union

from libvcs import exc
from libvcs._internal.types import StrOrBytesPath

from .. import exc

logger = logging.getLogger(__name__)

console_encoding = sys.__stdout__.encoding
Expand Down
25 changes: 15 additions & 10 deletions src/libvcs/_internal/shortcuts.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@


class VCSNoMatchFoundForUrl(exc.LibVCSException):
def __init__(self, url: str, *args: object):
def __init__(self, url: str, *args: object) -> None:
return super().__init__(f"No VCS found for url: {url}")


class VCSMultipleMatchFoundForUrl(exc.LibVCSException):
def __init__(self, url: str, *args: object):
def __init__(self, url: str, *args: object) -> None:
return super().__init__(f"Multiple VCS found for url: {url}")


class VCSNotSupported(exc.LibVCSException):
def __init__(self, url: str, vcs: str, *args: object):
def __init__(self, url: str, vcs: str, *args: object) -> None:
return super().__init__(f"VCS '{vcs}' not supported, based on URL: {url}")


Expand Down Expand Up @@ -110,7 +110,7 @@ def create_project(
assert vcs_matches[0].vcs is not None

def is_vcs(val: t.Any) -> "TypeGuard[VCSLiteral]":
return isinstance(val, str) and val in ["git", "hg", "svn"]
return isinstance(val, str) and val in {"git", "hg", "svn"}

if is_vcs(vcs_matches[0].vcs):
vcs = vcs_matches[0].vcs
Expand All @@ -119,13 +119,18 @@ def is_vcs(val: t.Any) -> "TypeGuard[VCSLiteral]":

if vcs == "git":
return GitSync(
url=url, path=path, progress_callback=progress_callback, **kwargs
url=url,
path=path,
progress_callback=progress_callback,
**kwargs,
)
elif vcs == "hg":
if vcs == "hg":
return HgSync(url=url, path=path, progress_callback=progress_callback, **kwargs)
elif vcs == "svn":
if vcs == "svn":
return SvnSync(
url=url, path=path, progress_callback=progress_callback, **kwargs
url=url,
path=path,
progress_callback=progress_callback,
**kwargs,
)
else:
raise InvalidVCS("VCS %s is not a valid VCS" % vcs)
raise InvalidVCS("VCS %s is not a valid VCS" % vcs)
2 changes: 1 addition & 1 deletion src/libvcs/_internal/subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@


class SubprocessCheckOutputError(Exception):
def __init__(self, output: str, *args: object):
def __init__(self, output: str, *args: object) -> None:
return super().__init__(f"output is not str or bytes: {output}")


Expand Down
8 changes: 3 additions & 5 deletions src/libvcs/cmd/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def run(
def stringify(v: Any) -> str:
if isinstance(v, bool):
return "true" if True else "false"
elif not isinstance(v, str):
if not isinstance(v, str):
return str(v)
return v

Expand Down Expand Up @@ -398,7 +398,6 @@ def fetch(
Union[bool, Literal["yes", "on-demand"]]
] = None,
submodule_prefix: Optional[StrOrBytesPath] = None,
#
_all: Optional[bool] = None,
force: Optional[bool] = None,
keep: Optional[bool] = None,
Expand Down Expand Up @@ -1821,9 +1820,8 @@ def rev_parse(
if parseopt is True:
if args is not None:
local_flags.extend(["--", args])
else:
if args is not None:
local_flags.append(args)
elif args is not None:
local_flags.append(args)

return self.run(
["rev-parse", *local_flags],
Expand Down
4 changes: 2 additions & 2 deletions src/libvcs/cmd/svn.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
class SvnPropsetValueOrValuePathRequired(exc.LibVCSException, TypeError):
"""Raised when required parameters are not passed."""

def __init__(self, *args: object):
def __init__(self, *args: object) -> None:
return super().__init__("Must enter a value or value_path")


Expand Down Expand Up @@ -783,7 +783,7 @@ def propset(
elif isinstance(value_path, pathlib.Path):
local_flags.extend(["--file", str(pathlib.Path(value_path).absolute())])
else:
raise SvnPropsetValueOrValuePathRequired()
raise SvnPropsetValueOrValuePathRequired

if path is not None:
if isinstance(path, (str, pathlib.Path)):
Expand Down
Loading

0 comments on commit 6b51eda

Please sign in to comment.