diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 812efe2f970..dfc06e64968 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -21,7 +21,7 @@ repos:
- id: check-docstring-first
- repo: https://github.com/psf/black
- rev: 23.3.0
+ rev: 23.7.0
hooks:
- id: black
@@ -30,7 +30,7 @@ repos:
hooks:
- id: validate_manifest
- - repo: https://github.com/charliermarsh/ruff-pre-commit
- rev: v0.0.272
+ - repo: https://github.com/astral-sh/ruff-pre-commit
+ rev: v0.0.278
hooks:
- id: ruff
diff --git a/pyproject.toml b/pyproject.toml
index 50e7829aaed..4776b608705 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -135,6 +135,9 @@ known-first-party = ["poetry"]
known-third-party = ["poetry.core"]
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]
target-version = ['py38']
preview = true
diff --git a/src/poetry/config/config.py b/src/poetry/config/config.py
index b19bb16afb9..6d7658645ae 100644
--- a/src/poetry/config/config.py
+++ b/src/poetry/config/config.py
@@ -9,6 +9,7 @@
from pathlib import Path
from typing import TYPE_CHECKING
from typing import Any
+from typing import ClassVar
from packaging.utils import canonicalize_name
@@ -104,7 +105,7 @@ def validator(cls, policy: str) -> bool:
class Config:
- default_config: dict[str, Any] = {
+ default_config: ClassVar[dict[str, Any]] = {
"cache-dir": str(DEFAULT_CACHE_DIR),
"virtualenvs": {
"create": True,
diff --git a/src/poetry/config/source.py b/src/poetry/config/source.py
index 7a4043b45b9..d3783bb5933 100644
--- a/src/poetry/config/source.py
+++ b/src/poetry/config/source.py
@@ -21,11 +21,9 @@ def __post_init__(self, default: bool, secondary: bool) -> None:
self.priority = Priority[self.priority.upper()]
if default or secondary:
warnings.warn(
- (
- "Parameters 'default' and 'secondary' to"
- " 'Source' are deprecated. Please provide"
- " 'priority' instead."
- ),
+ "Parameters 'default' and 'secondary' to"
+ " 'Source' are deprecated. Please provide"
+ " 'priority' instead.",
DeprecationWarning,
stacklevel=2,
)
diff --git a/src/poetry/console/commands/add.py b/src/poetry/console/commands/add.py
index 2db11dfb0c1..37277c94514 100644
--- a/src/poetry/console/commands/add.py
+++ b/src/poetry/console/commands/add.py
@@ -30,10 +30,8 @@ class AddCommand(InstallerCommand, InitCommand):
option(
"dev",
"D",
- (
- "Add as a development dependency. (Deprecated) Use"
- " --group=dev instead."
- ),
+ "Add as a development dependency. (Deprecated) Use"
+ " --group=dev instead.",
),
option("editable", "e", "Add vcs/path dependencies as editable."),
option(
@@ -66,10 +64,8 @@ class AddCommand(InstallerCommand, InitCommand):
option(
"dry-run",
None,
- (
- "Output the operations but do not execute anything (implicitly enables"
- " --verbose)."
- ),
+ "Output the operations but do not execute anything (implicitly enables"
+ " --verbose).",
),
option("lock", None, "Do not perform operations (only update the lockfile)."),
]
diff --git a/src/poetry/console/commands/check.py b/src/poetry/console/commands/check.py
index 95bd9912195..570a7f4e768 100644
--- a/src/poetry/console/commands/check.py
+++ b/src/poetry/console/commands/check.py
@@ -22,10 +22,8 @@ class CheckCommand(Command):
option(
"lock",
None,
- (
- "Checks that poetry.lock> exists for the current"
- " version of pyproject.toml>."
- ),
+ "Checks that poetry.lock> exists for the current"
+ " version of pyproject.toml>.",
),
]
diff --git a/src/poetry/console/commands/env/remove.py b/src/poetry/console/commands/env/remove.py
index d7029b96ac3..d23fafe5526 100644
--- a/src/poetry/console/commands/env/remove.py
+++ b/src/poetry/console/commands/env/remove.py
@@ -13,10 +13,8 @@ class EnvRemoveCommand(Command):
arguments = [
argument(
"python",
- (
- "The python executables associated with, or names of the virtual"
- " environments which are to be removed."
- ),
+ "The python executables associated with, or names of the virtual"
+ " environments which are to be removed.",
optional=True,
multiple=True,
)
diff --git a/src/poetry/console/commands/init.py b/src/poetry/console/commands/init.py
index 8424f90b60e..d7dc3bbeea3 100644
--- a/src/poetry/console/commands/init.py
+++ b/src/poetry/console/commands/init.py
@@ -40,20 +40,16 @@ class InitCommand(Command):
option(
"dependency",
None,
- (
- "Package to require, with an optional version constraint, "
- "e.g. requests:^2.10.0 or requests=2.11.1."
- ),
+ "Package to require, with an optional version constraint, "
+ "e.g. requests:^2.10.0 or requests=2.11.1.",
flag=False,
multiple=True,
),
option(
"dev-dependency",
None,
- (
- "Package to require for development, with an optional version"
- " constraint, e.g. requests:^2.10.0 or requests=2.11.1."
- ),
+ "Package to require for development, with an optional version"
+ " constraint, e.g. requests:^2.10.0 or requests=2.11.1.",
flag=False,
multiple=True,
),
@@ -330,10 +326,8 @@ def _determine_requirements(
choices.append("")
package = self.choice(
- (
- "\nEnter package # to add, or the complete package name if"
- " it is not listed"
- ),
+ "\nEnter package # to add, or the complete package name if"
+ " it is not listed",
choices,
attempts=3,
default=len(choices) - 1,
diff --git a/src/poetry/console/commands/install.py b/src/poetry/console/commands/install.py
index 66c419f1035..cc6e22eb624 100644
--- a/src/poetry/console/commands/install.py
+++ b/src/poetry/console/commands/install.py
@@ -14,18 +14,14 @@ class InstallCommand(InstallerCommand):
option(
"no-dev",
None,
- (
- "Do not install the development dependencies."
- " (Deprecated)"
- ),
+ "Do not install the development dependencies."
+ " (Deprecated)",
),
option(
"sync",
None,
- (
- "Synchronize the environment with the locked packages and the specified"
- " groups."
- ),
+ "Synchronize the environment with the locked packages and the specified"
+ " groups.",
),
option(
"no-root", None, "Do not install the root package (the current project)."
@@ -33,28 +29,22 @@ class InstallCommand(InstallerCommand):
option(
"no-directory",
None,
- (
- "Do not install any directory path dependencies; useful to install"
- " dependencies without source code, e.g. for caching of Docker layers)"
- ),
+ "Do not install any directory path dependencies; useful to install"
+ " dependencies without source code, e.g. for caching of Docker layers)",
flag=True,
multiple=False,
),
option(
"dry-run",
None,
- (
- "Output the operations but do not execute anything "
- "(implicitly enables --verbose)."
- ),
+ "Output the operations but do not execute anything "
+ "(implicitly enables --verbose).",
),
option(
"remove-untracked",
None,
- (
- "Removes packages not present in the lock file."
- " (Deprecated)"
- ),
+ "Removes packages not present in the lock file."
+ " (Deprecated)",
),
option(
"extras",
@@ -68,11 +58,9 @@ class InstallCommand(InstallerCommand):
option(
"compile",
None,
- (
- "Compile Python source files to bytecode."
- " (This option has no effect if modern-installation is disabled"
- " because the old installer always compiles.)"
- ),
+ "Compile Python source files to bytecode."
+ " (This option has no effect if modern-installation is disabled"
+ " because the old installer always compiles.)",
),
]
diff --git a/src/poetry/console/commands/lock.py b/src/poetry/console/commands/lock.py
index 87273a66776..b32c05dd4e4 100644
--- a/src/poetry/console/commands/lock.py
+++ b/src/poetry/console/commands/lock.py
@@ -16,11 +16,9 @@ class LockCommand(InstallerCommand):
option(
"check",
None,
- (
- "Check that the poetry.lock> file corresponds to the current"
- " version of pyproject.toml>. (Deprecated>) Use"
- " poetry check --lock> instead."
- ),
+ "Check that the poetry.lock> file corresponds to the current"
+ " version of pyproject.toml>. (Deprecated>) Use"
+ " poetry check --lock> instead.",
),
]
diff --git a/src/poetry/console/commands/remove.py b/src/poetry/console/commands/remove.py
index 10b605b4d9f..d4315e80bf8 100644
--- a/src/poetry/console/commands/remove.py
+++ b/src/poetry/console/commands/remove.py
@@ -21,19 +21,15 @@ class RemoveCommand(InstallerCommand):
option(
"dev",
"D",
- (
- "Remove a package from the development dependencies."
- " (Deprecated)"
- " Use --group=dev instead."
- ),
+ "Remove a package from the development dependencies."
+ " (Deprecated)"
+ " Use --group=dev instead.",
),
option(
"dry-run",
None,
- (
- "Output the operations but do not execute anything "
- "(implicitly enables --verbose)."
- ),
+ "Output the operations but do not execute anything "
+ "(implicitly enables --verbose).",
),
option("lock", None, "Do not perform operations (only update the lockfile)."),
]
diff --git a/src/poetry/console/commands/self/update.py b/src/poetry/console/commands/self/update.py
index 6cd94d71402..f42a3d477d8 100644
--- a/src/poetry/console/commands/self/update.py
+++ b/src/poetry/console/commands/self/update.py
@@ -23,10 +23,8 @@ class SelfUpdateCommand(SelfCommand):
option(
"dry-run",
None,
- (
- "Output the operations but do not execute anything "
- "(implicitly enables --verbose)."
- ),
+ "Output the operations but do not execute anything "
+ "(implicitly enables --verbose).",
),
]
help = """\
diff --git a/src/poetry/console/commands/show.py b/src/poetry/console/commands/show.py
index 090e5ca17a7..58f12b26160 100644
--- a/src/poetry/console/commands/show.py
+++ b/src/poetry/console/commands/show.py
@@ -48,10 +48,8 @@ class ShowCommand(GroupCommand, EnvCommand):
option(
"why",
None,
- (
- "When showing the full list, or a --tree for a single"
- " package, also display why it's included."
- ),
+ "When showing the full list, or a --tree for a single"
+ " package, also display why it's included.",
),
option("latest", "l", "Show the latest version."),
option(
diff --git a/src/poetry/console/commands/source/add.py b/src/poetry/console/commands/source/add.py
index 1997deb5328..5e1526f0f95 100644
--- a/src/poetry/console/commands/source/add.py
+++ b/src/poetry/console/commands/source/add.py
@@ -21,10 +21,8 @@ class SourceAddCommand(Command):
),
argument(
"url",
- (
- "Source repository URL."
- " Required, except for PyPI, for which it is not allowed."
- ),
+ "Source repository URL."
+ " Required, except for PyPI, for which it is not allowed.",
optional=True,
),
]
@@ -33,28 +31,22 @@ class SourceAddCommand(Command):
option(
"default",
"d",
- (
- "Set this source as the default (disable PyPI). A "
- "default source will also be the fallback source if "
- "you add other sources. (Deprecated, use --priority)"
- ),
+ "Set this source as the default (disable PyPI). A "
+ "default source will also be the fallback source if "
+ "you add other sources. (Deprecated, use --priority)",
),
option(
"secondary",
"s",
- (
- "Set this source as secondary. (Deprecated, use"
- " --priority)"
- ),
+ "Set this source as secondary. (Deprecated, use"
+ " --priority)",
),
option(
"priority",
"p",
- (
- "Set the priority of this source. One of:"
- f" {', '.join(p.name.lower() for p in Priority)}. Defaults to"
- f" {Priority.PRIMARY.name.lower()}."
- ),
+ "Set the priority of this source. One of:"
+ f" {', '.join(p.name.lower() for p in Priority)}. Defaults to"
+ f" {Priority.PRIMARY.name.lower()}.",
flag=False,
),
]
diff --git a/src/poetry/console/commands/update.py b/src/poetry/console/commands/update.py
index 4e97d84796b..57b173000a9 100644
--- a/src/poetry/console/commands/update.py
+++ b/src/poetry/console/commands/update.py
@@ -20,18 +20,14 @@ class UpdateCommand(InstallerCommand):
option(
"no-dev",
None,
- (
- "Do not update the development dependencies."
- " (Deprecated)"
- ),
+ "Do not update the development dependencies."
+ " (Deprecated)",
),
option(
"dry-run",
None,
- (
- "Output the operations but do not execute anything "
- "(implicitly enables --verbose)."
- ),
+ "Output the operations but do not execute anything "
+ "(implicitly enables --verbose).",
),
option("lock", None, "Do not perform operations (only update the lockfile)."),
]
diff --git a/src/poetry/installation/chooser.py b/src/poetry/installation/chooser.py
index 4601189d16d..cb05dff1b6d 100644
--- a/src/poetry/installation/chooser.py
+++ b/src/poetry/installation/chooser.py
@@ -48,10 +48,8 @@ def choose_for(self, package: Package) -> Link:
if link.is_wheel:
if not self._no_binary_policy.allows(package.name):
logger.debug(
- (
- "Skipping wheel for %s as requested in no binary policy for"
- " package (%s)"
- ),
+ "Skipping wheel for %s as requested in no binary policy for"
+ " package (%s)",
link.filename,
package.name,
)
@@ -59,10 +57,8 @@ def choose_for(self, package: Package) -> Link:
if not Wheel(link.filename).is_supported_by_environment(self._env):
logger.debug(
- (
- "Skipping wheel %s as this is not supported by the current"
- " environment"
- ),
+ "Skipping wheel %s as this is not supported by the current"
+ " environment",
link.filename,
)
continue
diff --git a/src/poetry/installation/executor.py b/src/poetry/installation/executor.py
index 72d08a19648..33bc924dfc0 100644
--- a/src/poetry/installation/executor.py
+++ b/src/poetry/installation/executor.py
@@ -370,12 +370,10 @@ def _do_execute_operation(self, operation: Operation) -> int:
if self.supports_fancy_output():
self._write(
operation,
- (
- f" •> {operation_message}: "
- "Skipped> "
- "for the following reason:> "
- f"{operation.skip_reason}>"
- ),
+ f" •> {operation_message}: "
+ "Skipped> "
+ "for the following reason:> "
+ f"{operation.skip_reason}>",
)
self._skipped[operation.job_type] += 1
diff --git a/src/poetry/locations.py b/src/poetry/locations.py
index 2d3b25da722..0b8c0826d97 100644
--- a/src/poetry/locations.py
+++ b/src/poetry/locations.py
@@ -35,12 +35,10 @@
if any(file.exists() for file in (auth_toml, config_toml)):
logger.warning(
- (
- "Configuration file exists at %s, reusing this"
- " directory.\n\nConsider moving TOML configuration files to %s, as"
- " support for the legacy directory will be removed in an upcoming"
- " release."
- ),
+ "Configuration file exists at %s, reusing this"
+ " directory.\n\nConsider moving TOML configuration files to %s, as"
+ " support for the legacy directory will be removed in an upcoming"
+ " release.",
_LEGACY_CONFIG_DIR,
CONFIG_DIR,
)
diff --git a/src/poetry/mixology/failure.py b/src/poetry/mixology/failure.py
index 6d13ee2ca56..da14d15edd4 100644
--- a/src/poetry/mixology/failure.py
+++ b/src/poetry/mixology/failure.py
@@ -144,10 +144,8 @@ def _visit(
self._visit(without_line)
self._write(
incompatibility,
- (
- f"{conjunction} because {with_line!s} ({line}),"
- f" {incompatibility_string}."
- ),
+ f"{conjunction} because {with_line!s} ({line}),"
+ f" {incompatibility_string}.",
numbered=numbered,
)
else:
@@ -172,11 +170,9 @@ def _visit(
self._write(
incompatibility,
- (
- f"{conjunction} because {cause.conflict!s}"
- f" ({self._line_numbers[cause.conflict]}),"
- f" {incompatibility_string}"
- ),
+ f"{conjunction} because {cause.conflict!s}"
+ f" ({self._line_numbers[cause.conflict]}),"
+ f" {incompatibility_string}",
numbered=numbered,
)
elif isinstance(cause.conflict.cause, ConflictCause) or isinstance(
diff --git a/src/poetry/mixology/solutions/providers/python_requirement_solution_provider.py b/src/poetry/mixology/solutions/providers/python_requirement_solution_provider.py
index ef278abb57b..b7d6e83bed2 100644
--- a/src/poetry/mixology/solutions/providers/python_requirement_solution_provider.py
+++ b/src/poetry/mixology/solutions/providers/python_requirement_solution_provider.py
@@ -19,10 +19,8 @@ def can_solve(self, exception: Exception) -> bool:
return False
m = re.match(
- (
- "^The current project's Python requirement (.+) is not compatible "
- "with some of the required packages Python requirement"
- ),
+ "^The current project's Python requirement (.+) is not compatible "
+ "with some of the required packages Python requirement",
str(exception),
)
diff --git a/src/poetry/packages/locker.py b/src/poetry/packages/locker.py
index a0cbfb24f51..69adb802ef6 100644
--- a/src/poetry/packages/locker.py
+++ b/src/poetry/packages/locker.py
@@ -9,6 +9,7 @@
from pathlib import Path
from typing import TYPE_CHECKING
from typing import Any
+from typing import ClassVar
from typing import cast
from packaging.utils import canonicalize_name
@@ -50,8 +51,13 @@ class Locker:
_VERSION = "2.0"
_READ_VERSION_RANGE = ">=1,<3"
- _legacy_keys = ["dependencies", "source", "extras", "dev-dependencies"]
- _relevant_keys = [*_legacy_keys, "group"]
+ _legacy_keys: ClassVar[list[str]] = [
+ "dependencies",
+ "source",
+ "extras",
+ "dev-dependencies",
+ ]
+ _relevant_keys: ClassVar[list[str]] = [*_legacy_keys, "group"]
def __init__(self, lock: Path, local_config: dict[str, Any]) -> None:
self._lock = lock
diff --git a/src/poetry/puzzle/provider.py b/src/poetry/puzzle/provider.py
index ea1eb8d9559..e8204fffcf3 100644
--- a/src/poetry/puzzle/provider.py
+++ b/src/poetry/puzzle/provider.py
@@ -7,6 +7,7 @@
from collections import defaultdict
from contextlib import contextmanager
from typing import TYPE_CHECKING
+from typing import ClassVar
from typing import cast
from cleo.ui.progress_indicator import ProgressIndicator
@@ -93,7 +94,7 @@ def _formatter_elapsed(self) -> str:
class Provider:
- UNSAFE_PACKAGES: set[str] = set()
+ UNSAFE_PACKAGES: ClassVar[set[str]] = set()
def __init__(
self,
diff --git a/src/poetry/repositories/installed_repository.py b/src/poetry/repositories/installed_repository.py
index 4256c509beb..1eb6b1d9742 100644
--- a/src/poetry/repositories/installed_repository.py
+++ b/src/poetry/repositories/installed_repository.py
@@ -258,11 +258,9 @@ def load(cls, env: Env, with_dependencies: bool = False) -> InstalledRepository:
name = distribution.metadata.get("name") # type: ignore[attr-defined]
if name is None:
logger.warning(
- (
- "Project environment contains an invalid distribution"
- " (%s>). Consider removing it manually or recreate"
- " the environment."
- ),
+ "Project environment contains an invalid distribution"
+ " (%s>). Consider removing it manually or recreate"
+ " the environment.",
path,
)
skipped.add(path)
diff --git a/src/poetry/repositories/link_sources/base.py b/src/poetry/repositories/link_sources/base.py
index b2bd455d42a..9948ec8cd35 100644
--- a/src/poetry/repositories/link_sources/base.py
+++ b/src/poetry/repositories/link_sources/base.py
@@ -5,6 +5,7 @@
from functools import cached_property
from typing import TYPE_CHECKING
+from typing import ClassVar
from typing import DefaultDict
from typing import List
@@ -31,7 +32,7 @@
class LinkSource:
VERSION_REGEX = re.compile(r"(?i)([a-z0-9_\-.]+?)-(?=\d)([a-z0-9_.!+-]+)")
CLEAN_REGEX = re.compile(r"[^a-z0-9$&+,/:;=?@.#%_\\|-]", re.I)
- SUPPORTED_FORMATS = [
+ SUPPORTED_FORMATS: ClassVar[list[str]] = [
".tar.gz",
".whl",
".zip",
diff --git a/src/poetry/repositories/pypi_repository.py b/src/poetry/repositories/pypi_repository.py
index d91cfafe0d8..73e8e3eb6b1 100644
--- a/src/poetry/repositories/pypi_repository.py
+++ b/src/poetry/repositories/pypi_repository.py
@@ -62,10 +62,8 @@ def search(self, query: str) -> list[Package]:
results.append(package)
except InvalidVersion:
self._log(
- (
- f'Unable to parse version "{result.version}" for the'
- f" {result.name} package, skipping"
- ),
+ f'Unable to parse version "{result.version}" for the'
+ f" {result.name} package, skipping",
level="debug",
)
diff --git a/src/poetry/repositories/repository_pool.py b/src/poetry/repositories/repository_pool.py
index cd839521a35..0d8a861951a 100644
--- a/src/poetry/repositories/repository_pool.py
+++ b/src/poetry/repositories/repository_pool.py
@@ -135,11 +135,9 @@ def add_repository(
if default or secondary:
warnings.warn(
- (
- "Parameters 'default' and 'secondary' to"
- " 'RepositoryPool.add_repository' are deprecated. Please provide"
- " the keyword-argument 'priority' instead."
- ),
+ "Parameters 'default' and 'secondary' to"
+ " 'RepositoryPool.add_repository' are deprecated. Please provide"
+ " the keyword-argument 'priority' instead.",
DeprecationWarning,
stacklevel=2,
)
diff --git a/src/poetry/toml/file.py b/src/poetry/toml/file.py
index 8c5bf729276..6733de7f037 100644
--- a/src/poetry/toml/file.py
+++ b/src/poetry/toml/file.py
@@ -38,11 +38,9 @@ def read(self) -> TOMLDocument:
def __getattr__(self, item: str) -> Any:
warnings.warn(
- (
- "`__getattr__` will be removed from the `TOMLFile` in a future release."
- "\n\nInstead of accessing properties of the underlying `Path` as "
- "`tomlfile.whatever`, prefer `tomlfile.path.whatever`."
- ),
+ "`__getattr__` will be removed from the `TOMLFile` in a future release."
+ "\n\nInstead of accessing properties of the underlying `Path` as "
+ "`tomlfile.whatever`, prefer `tomlfile.path.whatever`.",
DeprecationWarning,
stacklevel=2,
)
diff --git a/src/poetry/utils/env/env_manager.py b/src/poetry/utils/env/env_manager.py
index 438dc7455f5..1fa70afad1f 100644
--- a/src/poetry/utils/env/env_manager.py
+++ b/src/poetry/utils/env/env_manager.py
@@ -78,10 +78,8 @@ def _full_python_path(python: str) -> Path | None:
def _detect_active_python(io: None | IO = None) -> Path | None:
io = io or NullIO()
io.write_error_line(
- (
- "Trying to detect current active python executable as specified in"
- " the config."
- ),
+ "Trying to detect current active python executable as specified in"
+ " the config.",
verbosity=Verbosity.VERBOSE,
)
@@ -91,10 +89,8 @@ def _detect_active_python(io: None | IO = None) -> Path | None:
io.write_error_line(f"Found: {executable}", verbosity=Verbosity.VERBOSE)
else:
io.write_error_line(
- (
- "Unable to detect the current active python executable. Falling"
- " back to default."
- ),
+ "Unable to detect the current active python executable. Falling"
+ " back to default.",
verbosity=Verbosity.VERBOSE,
)
diff --git a/src/poetry/utils/setup_reader.py b/src/poetry/utils/setup_reader.py
index f9cecc4335a..53cd5e9e68e 100644
--- a/src/poetry/utils/setup_reader.py
+++ b/src/poetry/utils/setup_reader.py
@@ -5,6 +5,7 @@
from configparser import ConfigParser
from typing import TYPE_CHECKING
from typing import Any
+from typing import ClassVar
from poetry.core.constraints.version import Version
@@ -18,7 +19,7 @@ class SetupReader:
Class that reads a setup.py file without executing it.
"""
- DEFAULT: dict[str, Any] = {
+ DEFAULT: ClassVar[dict[str, Any]] = {
"name": None,
"version": None,
"install_requires": [],
@@ -26,7 +27,7 @@ class SetupReader:
"python_requires": None,
}
- FILES = ["setup.py", "setup.cfg"]
+ FILES: ClassVar[list[str]] = ["setup.py", "setup.cfg"]
@classmethod
def read_from_directory(cls, directory: Path) -> dict[str, Any]:
diff --git a/src/poetry/vcs/git/backend.py b/src/poetry/vcs/git/backend.py
index 3d58850f468..fcafc430605 100644
--- a/src/poetry/vcs/git/backend.py
+++ b/src/poetry/vcs/git/backend.py
@@ -296,10 +296,8 @@ def _clone(cls, url: str, refspec: GitRefSpec, target: Path) -> Repo:
if isinstance(e, KeyError):
# the local copy is at a bad state, lets remove it
logger.debug(
- (
- "Removing local clone (%s>) of repository as it is in a"
- " broken state."
- ),
+ "Removing local clone (%s>) of repository as it is in a"
+ " broken state.",
local.path,
)
remove_directory(Path(local.path), force=True)
@@ -308,11 +306,9 @@ def _clone(cls, url: str, refspec: GitRefSpec, target: Path) -> Repo:
raise
logger.debug(
- (
- "\nRequested ref (%s) was not fetched to local copy and"
- " cannot be used. The following error was"
- " raised:\n\n\t%s>"
- ),
+ "\nRequested ref (%s) was not fetched to local copy and"
+ " cannot be used. The following error was"
+ " raised:\n\n\t%s>",
refspec.key,
e,
)
@@ -447,10 +443,8 @@ def clone(
# without additional configuration or changes for existing projects that
# use http basic auth credentials.
logger.debug(
- (
- "Unable to fetch from private repository '%s', falling back to"
- " system git"
- ),
+ "Unable to fetch from private repository '%s', falling back to"
+ " system git",
url,
)
diff --git a/tests/console/commands/test_init.py b/tests/console/commands/test_init.py
index 9e963ef80f8..3352387246c 100644
--- a/tests/console/commands/test_init.py
+++ b/tests/console/commands/test_init.py
@@ -848,15 +848,13 @@ def test_predefined_all_options(tester: CommandTester, repo: TestRepository) ->
]
tester.execute(
- (
- "--name my-package "
- "--description 'This is a description' "
- "--author 'Foo Bar ' "
- "--python '^3.8' "
- "--license MIT "
- "--dependency pendulum "
- "--dev-dependency pytest"
- ),
+ "--name my-package "
+ "--description 'This is a description' "
+ "--author 'Foo Bar ' "
+ "--python '^3.8' "
+ "--license MIT "
+ "--dependency pendulum "
+ "--dev-dependency pytest",
inputs="\n".join(inputs),
)
@@ -947,12 +945,10 @@ def test_init_non_interactive_existing_pyproject_add_dependency(
repo.add_package(get_package("foo", "1.19.2"))
tester.execute(
- (
- "--author 'Your Name ' "
- "--name 'my-package' "
- "--python '^3.6' "
- "--dependency foo"
- ),
+ "--author 'Your Name ' "
+ "--name 'my-package' "
+ "--python '^3.6' "
+ "--dependency foo",
interactive=False,
)
diff --git a/tests/console/test_application.py b/tests/console/test_application.py
index 21310a81478..931944e227f 100644
--- a/tests/console/test_application.py
+++ b/tests/console/test_application.py
@@ -3,6 +3,7 @@
import re
from typing import TYPE_CHECKING
+from typing import ClassVar
import pytest
@@ -32,7 +33,7 @@ def handle(self) -> int:
class AddCommandPlugin(ApplicationPlugin):
- commands = [FooCommand]
+ commands: ClassVar[list[type[Command]]] = [FooCommand]
@pytest.fixture
diff --git a/tests/plugins/test_plugin_manager.py b/tests/plugins/test_plugin_manager.py
index 7ac296b8ef9..b6baa358ec7 100644
--- a/tests/plugins/test_plugin_manager.py
+++ b/tests/plugins/test_plugin_manager.py
@@ -2,6 +2,7 @@
from pathlib import Path
from typing import TYPE_CHECKING
+from typing import ClassVar
from typing import Protocol
import pytest
@@ -22,6 +23,7 @@
from cleo.io.io import IO
from pytest_mock import MockerFixture
+ from poetry.console.commands.command import Command
from tests.conftest import Config
from tests.types import FixtureDirGetter
@@ -38,7 +40,7 @@ def activate(self, poetry: Poetry, io: IO) -> None:
class MyCommandPlugin(ApplicationPlugin):
- commands = []
+ commands: ClassVar[list[type[Command]]] = []
class InvalidPlugin: