Commit c71deb4b by pre-commit-ci[bot] Committed by GitHub

[pre-commit.ci] pre-commit autoupdate (#8136)

Co-authored-by: Bartek Sokorski <b.sokorski@gmail.com>
parent fd717ca1
...@@ -21,7 +21,7 @@ repos: ...@@ -21,7 +21,7 @@ repos:
- id: check-docstring-first - id: check-docstring-first
- repo: https://github.com/psf/black - repo: https://github.com/psf/black
rev: 23.3.0 rev: 23.7.0
hooks: hooks:
- id: black - id: black
...@@ -30,7 +30,7 @@ repos: ...@@ -30,7 +30,7 @@ repos:
hooks: hooks:
- id: validate_manifest - id: validate_manifest
- repo: https://github.com/charliermarsh/ruff-pre-commit - repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.272 rev: v0.0.278
hooks: hooks:
- id: ruff - id: ruff
...@@ -135,6 +135,9 @@ known-first-party = ["poetry"] ...@@ -135,6 +135,9 @@ known-first-party = ["poetry"]
known-third-party = ["poetry.core"] known-third-party = ["poetry.core"]
required-imports = ["from __future__ import annotations"] required-imports = ["from __future__ import annotations"]
[tool.ruff.per-file-ignores]
"src/poetry/console/*" = ["RUF012"] # Can't annotate properly until new version of Cleo
[tool.black] [tool.black]
target-version = ['py38'] target-version = ['py38']
preview = true preview = true
......
...@@ -9,6 +9,7 @@ from copy import deepcopy ...@@ -9,6 +9,7 @@ from copy import deepcopy
from pathlib import Path from pathlib import Path
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from typing import Any from typing import Any
from typing import ClassVar
from packaging.utils import canonicalize_name from packaging.utils import canonicalize_name
...@@ -104,7 +105,7 @@ _default_config: Config | None = None ...@@ -104,7 +105,7 @@ _default_config: Config | None = None
class Config: class Config:
default_config: dict[str, Any] = { default_config: ClassVar[dict[str, Any]] = {
"cache-dir": str(DEFAULT_CACHE_DIR), "cache-dir": str(DEFAULT_CACHE_DIR),
"virtualenvs": { "virtualenvs": {
"create": True, "create": True,
......
...@@ -21,11 +21,9 @@ class Source: ...@@ -21,11 +21,9 @@ class Source:
self.priority = Priority[self.priority.upper()] self.priority = Priority[self.priority.upper()]
if default or secondary: if default or secondary:
warnings.warn( warnings.warn(
( "Parameters 'default' and 'secondary' to"
"Parameters 'default' and 'secondary' to" " 'Source' are deprecated. Please provide"
" 'Source' are deprecated. Please provide" " 'priority' instead.",
" 'priority' instead."
),
DeprecationWarning, DeprecationWarning,
stacklevel=2, stacklevel=2,
) )
......
...@@ -30,10 +30,8 @@ class AddCommand(InstallerCommand, InitCommand): ...@@ -30,10 +30,8 @@ class AddCommand(InstallerCommand, InitCommand):
option( option(
"dev", "dev",
"D", "D",
( "Add as a development dependency. (<warning>Deprecated</warning>) Use"
"Add as a development dependency. (<warning>Deprecated</warning>) Use" " --group=dev instead.",
" --group=dev instead."
),
), ),
option("editable", "e", "Add vcs/path dependencies as editable."), option("editable", "e", "Add vcs/path dependencies as editable."),
option( option(
...@@ -66,10 +64,8 @@ class AddCommand(InstallerCommand, InitCommand): ...@@ -66,10 +64,8 @@ class AddCommand(InstallerCommand, InitCommand):
option( option(
"dry-run", "dry-run",
None, None,
( "Output the operations but do not execute anything (implicitly enables"
"Output the operations but do not execute anything (implicitly enables" " --verbose).",
" --verbose)."
),
), ),
option("lock", None, "Do not perform operations (only update the lockfile)."), option("lock", None, "Do not perform operations (only update the lockfile)."),
] ]
......
...@@ -22,10 +22,8 @@ class CheckCommand(Command): ...@@ -22,10 +22,8 @@ class CheckCommand(Command):
option( option(
"lock", "lock",
None, None,
( "Checks that <comment>poetry.lock</> exists for the current"
"Checks that <comment>poetry.lock</> exists for the current" " version of <comment>pyproject.toml</>.",
" version of <comment>pyproject.toml</>."
),
), ),
] ]
......
...@@ -13,10 +13,8 @@ class EnvRemoveCommand(Command): ...@@ -13,10 +13,8 @@ class EnvRemoveCommand(Command):
arguments = [ arguments = [
argument( argument(
"python", "python",
( "The python executables associated with, or names of the virtual"
"The python executables associated with, or names of the virtual" " environments which are to be removed.",
" environments which are to be removed."
),
optional=True, optional=True,
multiple=True, multiple=True,
) )
......
...@@ -40,20 +40,16 @@ class InitCommand(Command): ...@@ -40,20 +40,16 @@ class InitCommand(Command):
option( option(
"dependency", "dependency",
None, None,
( "Package to require, with an optional version constraint, "
"Package to require, with an optional version constraint, " "e.g. requests:^2.10.0 or requests=2.11.1.",
"e.g. requests:^2.10.0 or requests=2.11.1."
),
flag=False, flag=False,
multiple=True, multiple=True,
), ),
option( option(
"dev-dependency", "dev-dependency",
None, None,
( "Package to require for development, with an optional version"
"Package to require for development, with an optional version" " constraint, e.g. requests:^2.10.0 or requests=2.11.1.",
" constraint, e.g. requests:^2.10.0 or requests=2.11.1."
),
flag=False, flag=False,
multiple=True, multiple=True,
), ),
...@@ -330,10 +326,8 @@ You can specify a package in the following forms: ...@@ -330,10 +326,8 @@ You can specify a package in the following forms:
choices.append("") choices.append("")
package = self.choice( package = self.choice(
( "\nEnter package # to add, or the complete package name if"
"\nEnter package # to add, or the complete package name if" " it is not listed",
" it is not listed"
),
choices, choices,
attempts=3, attempts=3,
default=len(choices) - 1, default=len(choices) - 1,
......
...@@ -14,18 +14,14 @@ class InstallCommand(InstallerCommand): ...@@ -14,18 +14,14 @@ class InstallCommand(InstallerCommand):
option( option(
"no-dev", "no-dev",
None, None,
( "Do not install the development dependencies."
"Do not install the development dependencies." " (<warning>Deprecated</warning>)",
" (<warning>Deprecated</warning>)"
),
), ),
option( option(
"sync", "sync",
None, None,
( "Synchronize the environment with the locked packages and the specified"
"Synchronize the environment with the locked packages and the specified" " groups.",
" groups."
),
), ),
option( option(
"no-root", None, "Do not install the root package (the current project)." "no-root", None, "Do not install the root package (the current project)."
...@@ -33,28 +29,22 @@ class InstallCommand(InstallerCommand): ...@@ -33,28 +29,22 @@ class InstallCommand(InstallerCommand):
option( option(
"no-directory", "no-directory",
None, None,
( "Do not install any directory path dependencies; useful to install"
"Do not install any directory path dependencies; useful to install" " dependencies without source code, e.g. for caching of Docker layers)",
" dependencies without source code, e.g. for caching of Docker layers)"
),
flag=True, flag=True,
multiple=False, multiple=False,
), ),
option( option(
"dry-run", "dry-run",
None, None,
( "Output the operations but do not execute anything "
"Output the operations but do not execute anything " "(implicitly enables --verbose).",
"(implicitly enables --verbose)."
),
), ),
option( option(
"remove-untracked", "remove-untracked",
None, None,
( "Removes packages not present in the lock file."
"Removes packages not present in the lock file." " (<warning>Deprecated</warning>)",
" (<warning>Deprecated</warning>)"
),
), ),
option( option(
"extras", "extras",
...@@ -68,11 +58,9 @@ class InstallCommand(InstallerCommand): ...@@ -68,11 +58,9 @@ class InstallCommand(InstallerCommand):
option( option(
"compile", "compile",
None, None,
( "Compile Python source files to bytecode."
"Compile Python source files to bytecode." " (This option has no effect if modern-installation is disabled"
" (This option has no effect if modern-installation is disabled" " because the old installer always compiles.)",
" because the old installer always compiles.)"
),
), ),
] ]
......
...@@ -16,11 +16,9 @@ class LockCommand(InstallerCommand): ...@@ -16,11 +16,9 @@ class LockCommand(InstallerCommand):
option( option(
"check", "check",
None, None,
( "Check that the <comment>poetry.lock</> file corresponds to the current"
"Check that the <comment>poetry.lock</> file corresponds to the current" " version of <comment>pyproject.toml</>. (<warning>Deprecated</>) Use"
" version of <comment>pyproject.toml</>. (<warning>Deprecated</>) Use" " <comment>poetry check --lock</> instead.",
" <comment>poetry check --lock</> instead."
),
), ),
] ]
......
...@@ -21,19 +21,15 @@ class RemoveCommand(InstallerCommand): ...@@ -21,19 +21,15 @@ class RemoveCommand(InstallerCommand):
option( option(
"dev", "dev",
"D", "D",
( "Remove a package from the development dependencies."
"Remove a package from the development dependencies." " (<warning>Deprecated</warning>)"
" (<warning>Deprecated</warning>)" " Use --group=dev instead.",
" Use --group=dev instead."
),
), ),
option( option(
"dry-run", "dry-run",
None, None,
( "Output the operations but do not execute anything "
"Output the operations but do not execute anything " "(implicitly enables --verbose).",
"(implicitly enables --verbose)."
),
), ),
option("lock", None, "Do not perform operations (only update the lockfile)."), option("lock", None, "Do not perform operations (only update the lockfile)."),
] ]
......
...@@ -23,10 +23,8 @@ class SelfUpdateCommand(SelfCommand): ...@@ -23,10 +23,8 @@ class SelfUpdateCommand(SelfCommand):
option( option(
"dry-run", "dry-run",
None, None,
( "Output the operations but do not execute anything "
"Output the operations but do not execute anything " "(implicitly enables --verbose).",
"(implicitly enables --verbose)."
),
), ),
] ]
help = """\ help = """\
......
...@@ -48,10 +48,8 @@ class ShowCommand(GroupCommand, EnvCommand): ...@@ -48,10 +48,8 @@ class ShowCommand(GroupCommand, EnvCommand):
option( option(
"why", "why",
None, None,
( "When showing the full list, or a <info>--tree</info> for a single"
"When showing the full list, or a <info>--tree</info> for a single" " package, also display why it's included.",
" package, also display why it's included."
),
), ),
option("latest", "l", "Show the latest version."), option("latest", "l", "Show the latest version."),
option( option(
......
...@@ -21,10 +21,8 @@ class SourceAddCommand(Command): ...@@ -21,10 +21,8 @@ class SourceAddCommand(Command):
), ),
argument( argument(
"url", "url",
( "Source repository URL."
"Source repository URL." " Required, except for PyPI, for which it is not allowed.",
" Required, except for PyPI, for which it is not allowed."
),
optional=True, optional=True,
), ),
] ]
...@@ -33,28 +31,22 @@ class SourceAddCommand(Command): ...@@ -33,28 +31,22 @@ class SourceAddCommand(Command):
option( option(
"default", "default",
"d", "d",
( "Set this source as the default (disable PyPI). A "
"Set this source as the default (disable PyPI). A " "default source will also be the fallback source if "
"default source will also be the fallback source if " "you add other sources. (<warning>Deprecated</warning>, use --priority)",
"you add other sources. (<warning>Deprecated</warning>, use --priority)"
),
), ),
option( option(
"secondary", "secondary",
"s", "s",
( "Set this source as secondary. (<warning>Deprecated</warning>, use"
"Set this source as secondary. (<warning>Deprecated</warning>, use" " --priority)",
" --priority)"
),
), ),
option( option(
"priority", "priority",
"p", "p",
( "Set the priority of this source. One of:"
"Set the priority of this source. One of:" f" {', '.join(p.name.lower() for p in Priority)}. Defaults to"
f" {', '.join(p.name.lower() for p in Priority)}. Defaults to" f" {Priority.PRIMARY.name.lower()}.",
f" {Priority.PRIMARY.name.lower()}."
),
flag=False, flag=False,
), ),
] ]
......
...@@ -20,18 +20,14 @@ class UpdateCommand(InstallerCommand): ...@@ -20,18 +20,14 @@ class UpdateCommand(InstallerCommand):
option( option(
"no-dev", "no-dev",
None, None,
( "Do not update the development dependencies."
"Do not update the development dependencies." " (<warning>Deprecated</warning>)",
" (<warning>Deprecated</warning>)"
),
), ),
option( option(
"dry-run", "dry-run",
None, None,
( "Output the operations but do not execute anything "
"Output the operations but do not execute anything " "(implicitly enables --verbose).",
"(implicitly enables --verbose)."
),
), ),
option("lock", None, "Do not perform operations (only update the lockfile)."), option("lock", None, "Do not perform operations (only update the lockfile)."),
] ]
......
...@@ -48,10 +48,8 @@ class Chooser: ...@@ -48,10 +48,8 @@ class Chooser:
if link.is_wheel: if link.is_wheel:
if not self._no_binary_policy.allows(package.name): if not self._no_binary_policy.allows(package.name):
logger.debug( logger.debug(
( "Skipping wheel for %s as requested in no binary policy for"
"Skipping wheel for %s as requested in no binary policy for" " package (%s)",
" package (%s)"
),
link.filename, link.filename,
package.name, package.name,
) )
...@@ -59,10 +57,8 @@ class Chooser: ...@@ -59,10 +57,8 @@ class Chooser:
if not Wheel(link.filename).is_supported_by_environment(self._env): if not Wheel(link.filename).is_supported_by_environment(self._env):
logger.debug( logger.debug(
( "Skipping wheel %s as this is not supported by the current"
"Skipping wheel %s as this is not supported by the current" " environment",
" environment"
),
link.filename, link.filename,
) )
continue continue
......
...@@ -370,12 +370,10 @@ class Executor: ...@@ -370,12 +370,10 @@ class Executor:
if self.supports_fancy_output(): if self.supports_fancy_output():
self._write( self._write(
operation, operation,
( f" <fg=default;options=bold,dark>•</> {operation_message}: "
f" <fg=default;options=bold,dark>•</> {operation_message}: " "<fg=default;options=bold,dark>Skipped</> "
"<fg=default;options=bold,dark>Skipped</> " "<fg=default;options=dark>for the following reason:</> "
"<fg=default;options=dark>for the following reason:</> " f"<fg=default;options=bold,dark>{operation.skip_reason}</>",
f"<fg=default;options=bold,dark>{operation.skip_reason}</>"
),
) )
self._skipped[operation.job_type] += 1 self._skipped[operation.job_type] += 1
......
...@@ -35,12 +35,10 @@ if sys.platform == "darwin": ...@@ -35,12 +35,10 @@ if sys.platform == "darwin":
if any(file.exists() for file in (auth_toml, config_toml)): if any(file.exists() for file in (auth_toml, config_toml)):
logger.warning( logger.warning(
( "Configuration file exists at %s, reusing this"
"Configuration file exists at %s, reusing this" " directory.\n\nConsider moving TOML configuration files to %s, as"
" directory.\n\nConsider moving TOML configuration files to %s, as" " support for the legacy directory will be removed in an upcoming"
" support for the legacy directory will be removed in an upcoming" " release.",
" release."
),
_LEGACY_CONFIG_DIR, _LEGACY_CONFIG_DIR,
CONFIG_DIR, CONFIG_DIR,
) )
......
...@@ -144,10 +144,8 @@ class _Writer: ...@@ -144,10 +144,8 @@ class _Writer:
self._visit(without_line) self._visit(without_line)
self._write( self._write(
incompatibility, incompatibility,
( f"{conjunction} because {with_line!s} ({line}),"
f"{conjunction} because {with_line!s} ({line})," f" {incompatibility_string}.",
f" {incompatibility_string}."
),
numbered=numbered, numbered=numbered,
) )
else: else:
...@@ -172,11 +170,9 @@ class _Writer: ...@@ -172,11 +170,9 @@ class _Writer:
self._write( self._write(
incompatibility, incompatibility,
( f"{conjunction} because {cause.conflict!s}"
f"{conjunction} because {cause.conflict!s}" f" ({self._line_numbers[cause.conflict]}),"
f" ({self._line_numbers[cause.conflict]})," f" {incompatibility_string}",
f" {incompatibility_string}"
),
numbered=numbered, numbered=numbered,
) )
elif isinstance(cause.conflict.cause, ConflictCause) or isinstance( elif isinstance(cause.conflict.cause, ConflictCause) or isinstance(
......
...@@ -19,10 +19,8 @@ class PythonRequirementSolutionProvider(HasSolutionsForException): ...@@ -19,10 +19,8 @@ class PythonRequirementSolutionProvider(HasSolutionsForException):
return False return False
m = re.match( m = re.match(
( "^The current project's Python requirement (.+) is not compatible "
"^The current project's Python requirement (.+) is not compatible " "with some of the required packages Python requirement",
"with some of the required packages Python requirement"
),
str(exception), str(exception),
) )
......
...@@ -9,6 +9,7 @@ from hashlib import sha256 ...@@ -9,6 +9,7 @@ from hashlib import sha256
from pathlib import Path from pathlib import Path
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from typing import Any from typing import Any
from typing import ClassVar
from typing import cast from typing import cast
from packaging.utils import canonicalize_name from packaging.utils import canonicalize_name
...@@ -50,8 +51,13 @@ class Locker: ...@@ -50,8 +51,13 @@ class Locker:
_VERSION = "2.0" _VERSION = "2.0"
_READ_VERSION_RANGE = ">=1,<3" _READ_VERSION_RANGE = ">=1,<3"
_legacy_keys = ["dependencies", "source", "extras", "dev-dependencies"] _legacy_keys: ClassVar[list[str]] = [
_relevant_keys = [*_legacy_keys, "group"] "dependencies",
"source",
"extras",
"dev-dependencies",
]
_relevant_keys: ClassVar[list[str]] = [*_legacy_keys, "group"]
def __init__(self, lock: Path, local_config: dict[str, Any]) -> None: def __init__(self, lock: Path, local_config: dict[str, Any]) -> None:
self._lock = lock self._lock = lock
......
...@@ -7,6 +7,7 @@ import time ...@@ -7,6 +7,7 @@ import time
from collections import defaultdict from collections import defaultdict
from contextlib import contextmanager from contextlib import contextmanager
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from typing import ClassVar
from typing import cast from typing import cast
from cleo.ui.progress_indicator import ProgressIndicator from cleo.ui.progress_indicator import ProgressIndicator
...@@ -93,7 +94,7 @@ class Indicator(ProgressIndicator): ...@@ -93,7 +94,7 @@ class Indicator(ProgressIndicator):
class Provider: class Provider:
UNSAFE_PACKAGES: set[str] = set() UNSAFE_PACKAGES: ClassVar[set[str]] = set()
def __init__( def __init__(
self, self,
......
...@@ -258,11 +258,9 @@ class InstalledRepository(Repository): ...@@ -258,11 +258,9 @@ class InstalledRepository(Repository):
name = distribution.metadata.get("name") # type: ignore[attr-defined] name = distribution.metadata.get("name") # type: ignore[attr-defined]
if name is None: if name is None:
logger.warning( logger.warning(
( "Project environment contains an invalid distribution"
"Project environment contains an invalid distribution" " (<c1>%s</>). Consider removing it manually or recreate"
" (<c1>%s</>). Consider removing it manually or recreate" " the environment.",
" the environment."
),
path, path,
) )
skipped.add(path) skipped.add(path)
......
...@@ -5,6 +5,7 @@ import re ...@@ -5,6 +5,7 @@ import re
from functools import cached_property from functools import cached_property
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from typing import ClassVar
from typing import DefaultDict from typing import DefaultDict
from typing import List from typing import List
...@@ -31,7 +32,7 @@ logger = logging.getLogger(__name__) ...@@ -31,7 +32,7 @@ logger = logging.getLogger(__name__)
class LinkSource: class LinkSource:
VERSION_REGEX = re.compile(r"(?i)([a-z0-9_\-.]+?)-(?=\d)([a-z0-9_.!+-]+)") VERSION_REGEX = re.compile(r"(?i)([a-z0-9_\-.]+?)-(?=\d)([a-z0-9_.!+-]+)")
CLEAN_REGEX = re.compile(r"[^a-z0-9$&+,/:;=?@.#%_\\|-]", re.I) CLEAN_REGEX = re.compile(r"[^a-z0-9$&+,/:;=?@.#%_\\|-]", re.I)
SUPPORTED_FORMATS = [ SUPPORTED_FORMATS: ClassVar[list[str]] = [
".tar.gz", ".tar.gz",
".whl", ".whl",
".zip", ".zip",
......
...@@ -62,10 +62,8 @@ class PyPiRepository(HTTPRepository): ...@@ -62,10 +62,8 @@ class PyPiRepository(HTTPRepository):
results.append(package) results.append(package)
except InvalidVersion: except InvalidVersion:
self._log( self._log(
( f'Unable to parse version "{result.version}" for the'
f'Unable to parse version "{result.version}" for the' f" {result.name} package, skipping",
f" {result.name} package, skipping"
),
level="debug", level="debug",
) )
......
...@@ -135,11 +135,9 @@ class RepositoryPool(AbstractRepository): ...@@ -135,11 +135,9 @@ class RepositoryPool(AbstractRepository):
if default or secondary: if default or secondary:
warnings.warn( warnings.warn(
( "Parameters 'default' and 'secondary' to"
"Parameters 'default' and 'secondary' to" " 'RepositoryPool.add_repository' are deprecated. Please provide"
" 'RepositoryPool.add_repository' are deprecated. Please provide" " the keyword-argument 'priority' instead.",
" the keyword-argument 'priority' instead."
),
DeprecationWarning, DeprecationWarning,
stacklevel=2, stacklevel=2,
) )
......
...@@ -38,11 +38,9 @@ class TOMLFile(BaseTOMLFile): ...@@ -38,11 +38,9 @@ class TOMLFile(BaseTOMLFile):
def __getattr__(self, item: str) -> Any: def __getattr__(self, item: str) -> Any:
warnings.warn( warnings.warn(
( "`__getattr__` will be removed from the `TOMLFile` in a future release."
"`__getattr__` will be removed from the `TOMLFile` in a future release." "\n\nInstead of accessing properties of the underlying `Path` as "
"\n\nInstead of accessing properties of the underlying `Path` as " "`tomlfile.whatever`, prefer `tomlfile.path.whatever`.",
"`tomlfile.whatever`, prefer `tomlfile.path.whatever`."
),
DeprecationWarning, DeprecationWarning,
stacklevel=2, stacklevel=2,
) )
......
...@@ -78,10 +78,8 @@ class EnvManager: ...@@ -78,10 +78,8 @@ class EnvManager:
def _detect_active_python(io: None | IO = None) -> Path | None: def _detect_active_python(io: None | IO = None) -> Path | None:
io = io or NullIO() io = io or NullIO()
io.write_error_line( io.write_error_line(
( "Trying to detect current active python executable as specified in"
"Trying to detect current active python executable as specified in" " the config.",
" the config."
),
verbosity=Verbosity.VERBOSE, verbosity=Verbosity.VERBOSE,
) )
...@@ -91,10 +89,8 @@ class EnvManager: ...@@ -91,10 +89,8 @@ class EnvManager:
io.write_error_line(f"Found: {executable}", verbosity=Verbosity.VERBOSE) io.write_error_line(f"Found: {executable}", verbosity=Verbosity.VERBOSE)
else: else:
io.write_error_line( io.write_error_line(
( "Unable to detect the current active python executable. Falling"
"Unable to detect the current active python executable. Falling" " back to default.",
" back to default."
),
verbosity=Verbosity.VERBOSE, verbosity=Verbosity.VERBOSE,
) )
......
...@@ -5,6 +5,7 @@ import ast ...@@ -5,6 +5,7 @@ import ast
from configparser import ConfigParser from configparser import ConfigParser
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from typing import Any from typing import Any
from typing import ClassVar
from poetry.core.constraints.version import Version from poetry.core.constraints.version import Version
...@@ -18,7 +19,7 @@ class SetupReader: ...@@ -18,7 +19,7 @@ class SetupReader:
Class that reads a setup.py file without executing it. Class that reads a setup.py file without executing it.
""" """
DEFAULT: dict[str, Any] = { DEFAULT: ClassVar[dict[str, Any]] = {
"name": None, "name": None,
"version": None, "version": None,
"install_requires": [], "install_requires": [],
...@@ -26,7 +27,7 @@ class SetupReader: ...@@ -26,7 +27,7 @@ class SetupReader:
"python_requires": None, "python_requires": None,
} }
FILES = ["setup.py", "setup.cfg"] FILES: ClassVar[list[str]] = ["setup.py", "setup.cfg"]
@classmethod @classmethod
def read_from_directory(cls, directory: Path) -> dict[str, Any]: def read_from_directory(cls, directory: Path) -> dict[str, Any]:
......
...@@ -296,10 +296,8 @@ class Git: ...@@ -296,10 +296,8 @@ class Git:
if isinstance(e, KeyError): if isinstance(e, KeyError):
# the local copy is at a bad state, lets remove it # the local copy is at a bad state, lets remove it
logger.debug( logger.debug(
( "Removing local clone (<c1>%s</>) of repository as it is in a"
"Removing local clone (<c1>%s</>) of repository as it is in a" " broken state.",
" broken state."
),
local.path, local.path,
) )
remove_directory(Path(local.path), force=True) remove_directory(Path(local.path), force=True)
...@@ -308,11 +306,9 @@ class Git: ...@@ -308,11 +306,9 @@ class Git:
raise raise
logger.debug( logger.debug(
( "\nRequested ref (<c2>%s</c2>) was not fetched to local copy and"
"\nRequested ref (<c2>%s</c2>) was not fetched to local copy and" " cannot be used. The following error was"
" cannot be used. The following error was" " raised:\n\n\t<warning>%s</>",
" raised:\n\n\t<warning>%s</>"
),
refspec.key, refspec.key,
e, e,
) )
...@@ -447,10 +443,8 @@ class Git: ...@@ -447,10 +443,8 @@ class Git:
# without additional configuration or changes for existing projects that # without additional configuration or changes for existing projects that
# use http basic auth credentials. # use http basic auth credentials.
logger.debug( logger.debug(
( "Unable to fetch from private repository '%s', falling back to"
"Unable to fetch from private repository '%s', falling back to" " system git",
" system git"
),
url, url,
) )
......
...@@ -848,15 +848,13 @@ def test_predefined_all_options(tester: CommandTester, repo: TestRepository) -> ...@@ -848,15 +848,13 @@ def test_predefined_all_options(tester: CommandTester, repo: TestRepository) ->
] ]
tester.execute( tester.execute(
( "--name my-package "
"--name my-package " "--description 'This is a description' "
"--description 'This is a description' " "--author 'Foo Bar <foo@example.com>' "
"--author 'Foo Bar <foo@example.com>' " "--python '^3.8' "
"--python '^3.8' " "--license MIT "
"--license MIT " "--dependency pendulum "
"--dependency pendulum " "--dev-dependency pytest",
"--dev-dependency pytest"
),
inputs="\n".join(inputs), inputs="\n".join(inputs),
) )
...@@ -947,12 +945,10 @@ line-length = 88 ...@@ -947,12 +945,10 @@ line-length = 88
repo.add_package(get_package("foo", "1.19.2")) repo.add_package(get_package("foo", "1.19.2"))
tester.execute( tester.execute(
( "--author 'Your Name <you@example.com>' "
"--author 'Your Name <you@example.com>' " "--name 'my-package' "
"--name 'my-package' " "--python '^3.6' "
"--python '^3.6' " "--dependency foo",
"--dependency foo"
),
interactive=False, interactive=False,
) )
......
...@@ -3,6 +3,7 @@ from __future__ import annotations ...@@ -3,6 +3,7 @@ from __future__ import annotations
import re import re
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from typing import ClassVar
import pytest import pytest
...@@ -32,7 +33,7 @@ class FooCommand(Command): ...@@ -32,7 +33,7 @@ class FooCommand(Command):
class AddCommandPlugin(ApplicationPlugin): class AddCommandPlugin(ApplicationPlugin):
commands = [FooCommand] commands: ClassVar[list[type[Command]]] = [FooCommand]
@pytest.fixture @pytest.fixture
......
...@@ -2,6 +2,7 @@ from __future__ import annotations ...@@ -2,6 +2,7 @@ from __future__ import annotations
from pathlib import Path from pathlib import Path
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from typing import ClassVar
from typing import Protocol from typing import Protocol
import pytest import pytest
...@@ -22,6 +23,7 @@ if TYPE_CHECKING: ...@@ -22,6 +23,7 @@ if TYPE_CHECKING:
from cleo.io.io import IO from cleo.io.io import IO
from pytest_mock import MockerFixture from pytest_mock import MockerFixture
from poetry.console.commands.command import Command
from tests.conftest import Config from tests.conftest import Config
from tests.types import FixtureDirGetter from tests.types import FixtureDirGetter
...@@ -38,7 +40,7 @@ class MyPlugin(Plugin): ...@@ -38,7 +40,7 @@ class MyPlugin(Plugin):
class MyCommandPlugin(ApplicationPlugin): class MyCommandPlugin(ApplicationPlugin):
commands = [] commands: ClassVar[list[type[Command]]] = []
class InvalidPlugin: class InvalidPlugin:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment