Skip to content

Commit ecb030e

Browse files
authored
Wrap long lines to comply with flake8 E501 (#4985)
* Update flake8 settings * Add poetry to isort namespace packages * Ignore flake8 E501 for long test names * Run automatic string formatting on tests * Run automatic string formatting on src * Fix typo "already exits" * Ignore long URLs, hashes, and paths * Fix in-line comments * Fix in-line comments in tests * Fix docstrings * Ignore misc * Fix f-strings in src * Fix f-strings in tests * Fix multi-line strings in src * Fix multi-line strings in tests * Fix some oddly autoformatted code * Replace some strings by multi-line strings * Revert namespace change * Add black string processing to pre-commit * Move black pre-commit config to pyproject.toml * Autoformat install scripts * Manual line wrapping for install scripts * Disable black formatting for expected strings * Replace strings by constant
1 parent b5279e0 commit ecb030e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+591
-365
lines changed

.flake8

-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ enable-extensions = TC, TC2
1212
type-checking-exempt-modules = typing, typing-extensions
1313
eradicate-whitelist-extend = ^-.*;
1414
extend-ignore =
15-
# E501: Line too long (FIXME: long string constants)
16-
E501,
1715
# E203: Whitespace before ':' (pycqa/pycodestyle#373)
1816
E203,
1917
# SIM106: Handle error-cases first

get-poetry.py

+18-13
Original file line numberDiff line numberDiff line change
@@ -458,21 +458,21 @@ def _is_supported(x):
458458
print(
459459
colorize(
460460
"error",
461-
"Version {version} does not support this installation method. Please specify a version prior to "
462-
"1.2.0a1 explicitly using the '--version' option.\n"
463-
"Please see "
464-
"https://python-poetry.org/blog/announcing-poetry-1-2-0a1.html#deprecation-of-the-get-poetry-py-script "
465-
"for more information.".format(version=version),
461+
"Version {version} does not support this installation method."
462+
" Please specify a version prior to 1.2.0a1 explicitly using the"
463+
" '--version' option.\nPlease see"
464+
" https://python-poetry.org/blog/announcing-poetry-1-2-0a1.html#deprecation-of-the-get-poetry-py-script"
465+
" for more information.".format(version=version),
466466
)
467467
)
468468
return None, None
469469

470470
print(
471471
colorize(
472472
"warning",
473-
"This installer is deprecated. "
474-
"Poetry versions installed using this script will not be able to use 'self update' command to upgrade to "
475-
"1.2.0a1 or later.",
473+
"This installer is deprecated. Poetry versions installed using this"
474+
" script will not be able to use 'self update' command to upgrade to"
475+
" 1.2.0a1 or later.",
476476
)
477477
)
478478

@@ -685,7 +685,8 @@ def _which_python(self):
685685
return executable
686686

687687
if fallback is None:
688-
# keep this one as the fallback; it was the first valid executable we found.
688+
# keep this one as the fallback; it was the first valid executable we
689+
# found.
689690
fallback = executable
690691

691692
if fallback is None:
@@ -773,7 +774,8 @@ def add_to_fish_path(self):
773774
print(
774775
colorize(
775776
"warning",
776-
"\nUnable to get the PATH value. It will not be updated automatically.",
777+
"\nUnable to get the PATH value. It will not be updated"
778+
" automatically.",
777779
)
778780
)
779781
self._modify_path = False
@@ -808,7 +810,8 @@ def add_to_windows_path(self):
808810
print(
809811
colorize(
810812
"warning",
811-
"Unable to get the PATH value. It will not be updated automatically",
813+
"Unable to get the PATH value. It will not be updated"
814+
" automatically",
812815
)
813816
)
814817
self._modify_path = False
@@ -1074,8 +1077,10 @@ def main():
10741077
"--file",
10751078
dest="file",
10761079
action="store",
1077-
help="Install from a local file instead of fetching the latest version "
1078-
"of Poetry available online.",
1080+
help=(
1081+
"Install from a local file instead of fetching the latest version "
1082+
"of Poetry available online."
1083+
),
10791084
)
10801085

10811086
args = parser.parse_args()

install-poetry.py

+16-8
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,8 @@ def __init__(self, return_code: int = 0, log: Optional[str] = None):
273273
class VirtualEnvironment:
274274
def __init__(self, path: Path) -> None:
275275
self._path = path
276-
# str is required for compatibility with subprocess run on CPython <= 3.7 on Windows
276+
# str is required for compatibility with subprocess run on CPython <= 3.7 on
277+
# Windows
277278
self._python = str(
278279
self._path.joinpath("Scripts/python.exe" if WINDOWS else "bin/python")
279280
)
@@ -313,7 +314,8 @@ def make(cls, target: Path) -> "VirtualEnvironment":
313314

314315
env = cls(target)
315316

316-
# we do this here to ensure that outdated system default pip does not trigger older bugs
317+
# we do this here to ensure that outdated system default pip does not trigger
318+
# older bugs
317319
env.pip("install", "--disable-pip-version-check", "--upgrade", "pip")
318320

319321
return env
@@ -480,7 +482,8 @@ def _is_self_upgrade_supported(x):
480482
mx = self.VERSION_REGEX.match(x)
481483

482484
if mx is None:
483-
# the version is not semver, perhaps scm or file, we assume upgrade is supported
485+
# the version is not semver, perhaps scm or file, we assume upgrade is
486+
# supported
484487
return True
485488

486489
vx = tuple(int(p) for p in mx.groups()[:3]) + (mx.group(5),)
@@ -490,8 +493,9 @@ def _is_self_upgrade_supported(x):
490493
self._write(
491494
colorize(
492495
"warning",
493-
f"You are installing {version}. When using the current installer, this version does not support "
494-
f"updating using the 'self update' command. Please use 1.1.7 or later.",
496+
f"You are installing {version}. When using the current installer,"
497+
" this version does not support updating using the 'self update'"
498+
" command. Please use 1.1.7 or later.",
495499
)
496500
)
497501
if not self._accept_all:
@@ -883,7 +887,10 @@ def main():
883887
text=True,
884888
)
885889
installer._write(colorize("error", f"See {path} for error logs."))
886-
text = f"{e.log}\nTraceback:\n\n{''.join(traceback.format_tb(e.__traceback__))}"
890+
text = (
891+
f"{e.log}\n"
892+
f"Traceback:\n\n{''.join(traceback.format_tb(e.__traceback__))}"
893+
)
887894
Path(path).write_text(text)
888895

889896
return e.return_code
@@ -893,8 +900,9 @@ def main():
893900
sys.stdout.write(
894901
colorize(
895902
"warning",
896-
"The canonical source for Poetry's installation script is now https://install.python-poetry.org. "
897-
"Please update your usage to reflect this.\n",
903+
"The canonical source for Poetry's installation script is now"
904+
" https://install.python-poetry.org. Please update your usage to reflect"
905+
" this.\n",
898906
)
899907
)
900908
sys.exit(main())

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ extend_skip = ["setup.py"]
8989

9090
[tool.black]
9191
target-version = ['py36']
92+
experimental_string_processing = true
9293
force-exclude = '''
9394
.*/setup\.py$
9495
'''

src/poetry/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore[has-type]
1+
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore[has-type] # noqa: E501

src/poetry/console/application.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ def _get_solution_provider_repository(self) -> "SolutionProviderRepository":
353353
SolutionProviderRepository,
354354
)
355355

356-
from poetry.mixology.solutions.providers.python_requirement_solution_provider import (
356+
from poetry.mixology.solutions.providers.python_requirement_solution_provider import ( # noqa: E501
357357
PythonRequirementSolutionProvider,
358358
)
359359

src/poetry/console/commands/about.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ class AboutCommand(Command):
99

1010
def handle(self) -> None:
1111
self.line(
12-
"""<info>Poetry - Package Management for Python</info>
12+
"""\
13+
<info>Poetry - Package Management for Python</info>
1314
14-
<comment>Poetry is a dependency manager tracking local dependencies of your projects and libraries.
15-
See <fg=blue>https://github.com/python-poetry/poetry</> for more information.</comment>"""
15+
<comment>Poetry is a dependency manager tracking local dependencies of your projects\
16+
and libraries.
17+
See <fg=blue>https://github.com/python-poetry/poetry</> for more information.</comment>\
18+
"""
1619
)

src/poetry/console/commands/add.py

+27-18
Original file line numberDiff line numberDiff line change
@@ -54,24 +54,31 @@ class AddCommand(InstallerCommand, InitCommand):
5454
option(
5555
"dry-run",
5656
None,
57-
"Output the operations but do not execute anything (implicitly enables --verbose).",
57+
"Output the operations but do not execute anything (implicitly enables"
58+
" --verbose).",
5859
),
5960
option("lock", None, "Do not perform operations (only update the lockfile)."),
6061
]
61-
help = (
62-
"The add command adds required packages to your <comment>pyproject.toml</> and installs them.\n\n"
63-
"If you do not specify a version constraint, poetry will choose a suitable one based on the available package versions.\n\n"
64-
"You can specify a package in the following forms:\n"
65-
" - A single name (<b>requests</b>)\n"
66-
" - A name and a constraint (<b>requests@^2.23.0</b>)\n"
67-
" - A git url (<b>git+https://github.com/python-poetry/poetry.git</b>)\n"
68-
" - A git url with a revision (<b>git+https://github.com/python-poetry/poetry.git#develop</b>)\n"
69-
" - A git SSH url (<b>git+ssh://github.com/python-poetry/poetry.git</b>)\n"
70-
" - A git SSH url with a revision (<b>git+ssh://github.com/python-poetry/poetry.git#develop</b>)\n"
71-
" - A file path (<b>../my-package/my-package.whl</b>)\n"
72-
" - A directory (<b>../my-package/</b>)\n"
73-
" - A url (<b>https://example.com/packages/my-package-0.1.0.tar.gz</b>)\n"
74-
)
62+
help = """\
63+
The add command adds required packages to your <comment>pyproject.toml</> and installs\
64+
them.
65+
66+
If you do not specify a version constraint, poetry will choose a suitable one based on\
67+
the available package versions.
68+
69+
You can specify a package in the following forms:
70+
- A single name (<b>requests</b>)
71+
- A name and a constraint (<b>requests@^2.23.0</b>)
72+
- A git url (<b>git+https://github.com/python-poetry/poetry.git</b>)
73+
- A git url with a revision\
74+
(<b>git+https://github.com/python-poetry/poetry.git#develop</b>)
75+
- A git SSH url (<b>git+ssh://github.com/python-poetry/poetry.git</b>)
76+
- A git SSH url with a revision\
77+
(<b>git+ssh://github.com/python-poetry/poetry.git#develop</b>)
78+
- A file path (<b>../my-package/my-package.whl</b>)
79+
- A directory (<b>../my-package/</b>)
80+
- A url (<b>https://example.com/packages/my-package-0.1.0.tar.gz</b>)
81+
"""
7582

7683
loggers = ["poetry.repositories.pypi_repository", "poetry.inspection.info"]
7784

@@ -244,11 +251,13 @@ def get_existing_packages_from_input(
244251

245252
def notify_about_existing_packages(self, existing_packages: List[str]) -> None:
246253
self.line(
247-
"The following packages are already present in the pyproject.toml and will be skipped:\n"
254+
"The following packages are already present in the pyproject.toml and will"
255+
" be skipped:\n"
248256
)
249257
for name in existing_packages:
250258
self.line(f" • <c1>{name}</c1>")
251259
self.line(
252-
"\nIf you want to update it to the latest compatible version, you can use `poetry update package`.\n"
253-
"If you prefer to upgrade it to the latest available version, you can use `poetry add package@latest`.\n"
260+
"\nIf you want to update it to the latest compatible version, you can use"
261+
" `poetry update package`.\nIf you prefer to upgrade it to the latest"
262+
" available version, you can use `poetry add package@latest`.\n"
254263
)

src/poetry/console/commands/cache/clear.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ def handle(self) -> int:
4242
if len(parts) == 1:
4343
if not self.option("all"):
4444
raise RuntimeError(
45-
"Add the --all option if you want to clear all "
46-
f"{parts[0]} caches"
45+
f"Add the --all option if you want to clear all {parts[0]} caches"
4746
)
4847

4948
if not os.path.exists(str(cache_dir)):

src/poetry/console/commands/env/info.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,15 @@ def _display_complete_info(self, env: "Env") -> None:
4040
listing = [
4141
f"<info>Python</info>: <comment>{env_python_version}</>",
4242
f"<info>Implementation</info>: <comment>{env.python_implementation}</>",
43-
f"<info>Path</info>: <comment>{env.path if env.is_venv() else 'NA'}</>",
44-
f"<info>Executable</info>: <comment>{env.python if env.is_venv() else 'NA'}</>",
43+
"<info>Path</info>: "
44+
f" <comment>{env.path if env.is_venv() else 'NA'}</>",
45+
"<info>Executable</info>: "
46+
f" <comment>{env.python if env.is_venv() else 'NA'}</>",
4547
]
4648
if env.is_venv():
4749
listing.append(
48-
f"<info>Valid</info>: <{'comment' if env.is_sane() else 'error'}>{env.is_sane()}</>"
50+
"<info>Valid</info>: "
51+
f" <{'comment' if env.is_sane() else 'error'}>{env.is_sane()}</>"
4952
)
5053
self.line("\n".join(listing))
5154

src/poetry/console/commands/env/remove.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,18 @@ class EnvRemoveCommand(Command):
1212
arguments = [
1313
argument(
1414
"python",
15-
"The python executables associated with, or names of the virtual environments which are to "
16-
"be removed.",
15+
"The python executables associated with, or names of the virtual"
16+
" environments which are to be removed.",
1717
optional=True,
1818
multiple=True,
1919
)
2020
]
2121
options = [
2222
option(
2323
"all",
24-
description="Remove all managed virtual environments associated with the "
25-
"project.",
24+
description=(
25+
"Remove all managed virtual environments associated with the project."
26+
),
2627
),
2728
]
2829

src/poetry/console/commands/init.py

+26-17
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ class InitCommand(Command):
5454
]
5555

5656
help = """\
57-
The <c1>init</c1> command creates a basic <comment>pyproject.toml</> file in the current directory.
57+
The <c1>init</c1> command creates a basic <comment>pyproject.toml</> file in the\
58+
current directory.
5859
"""
5960

6061
def __init__(self) -> None:
@@ -76,13 +77,15 @@ def handle(self) -> int:
7677
if pyproject.file.exists():
7778
if pyproject.is_poetry_project():
7879
self.line(
79-
"<error>A pyproject.toml file with a poetry section already exists.</error>"
80+
"<error>A pyproject.toml file with a poetry section already"
81+
" exists.</error>"
8082
)
8183
return 1
8284

8385
if pyproject.data.get("build-system"):
8486
self.line(
85-
"<error>A pyproject.toml file with a defined build-system already exists.</error>"
87+
"<error>A pyproject.toml file with a defined build-system already"
88+
" exists.</error>"
8689
)
8790
return 1
8891

@@ -91,7 +94,8 @@ def handle(self) -> int:
9194
if self.io.is_interactive():
9295
self.line("")
9396
self.line(
94-
"This command will guide you through creating your <info>pyproject.toml</> config."
97+
"This command will guide you through creating your"
98+
" <info>pyproject.toml</> config."
9599
)
96100
self.line("")
97101

@@ -165,16 +169,18 @@ def handle(self) -> int:
165169
)
166170

167171
question = "Would you like to define your main dependencies interactively?"
168-
help_message = (
169-
"You can specify a package in the following forms:\n"
170-
" - A single name (<b>requests</b>)\n"
171-
" - A name and a constraint (<b>requests@^2.23.0</b>)\n"
172-
" - A git url (<b>git+https://github.com/python-poetry/poetry.git</b>)\n"
173-
" - A git url with a revision (<b>git+https://github.com/python-poetry/poetry.git#develop</b>)\n"
174-
" - A file path (<b>../my-package/my-package.whl</b>)\n"
175-
" - A directory (<b>../my-package/</b>)\n"
176-
" - A url (<b>https://example.com/packages/my-package-0.1.0.tar.gz</b>)\n"
177-
)
172+
help_message = """\
173+
You can specify a package in the following forms:
174+
- A single name (<b>requests</b>)
175+
- A name and a constraint (<b>requests@^2.23.0</b>)
176+
- A git url (<b>git+https://github.com/python-poetry/poetry.git</b>)
177+
- A git url with a revision\
178+
(<b>git+https://github.com/python-poetry/poetry.git#develop</b>)
179+
- A file path (<b>../my-package/my-package.whl</b>)
180+
- A directory (<b>../my-package/</b>)
181+
- A url (<b>https://example.com/packages/my-package-0.1.0.tar.gz</b>)
182+
"""
183+
178184
help_displayed = False
179185
if self.confirm(question, True):
180186
if self.io.is_interactive():
@@ -280,11 +286,13 @@ def _determine_requirements(
280286
choices.append(found_package.pretty_name)
281287

282288
self.line(
283-
f"Found <info>{len(matches)}</info> packages matching <c1>{package}</c1>"
289+
f"Found <info>{len(matches)}</info> packages matching"
290+
f" <c1>{package}</c1>"
284291
)
285292

286293
package = self.choice(
287-
"\nEnter package # to add, or the complete package name if it is not listed",
294+
"\nEnter package # to add, or the complete package name if it"
295+
" is not listed",
288296
choices,
289297
attempts=3,
290298
)
@@ -310,7 +318,8 @@ def _determine_requirements(
310318
)
311319

312320
self.line(
313-
f"Using version <b>{package_constraint}</b> for <c1>{package}</c1>"
321+
f"Using version <b>{package_constraint}</b> for"
322+
f" <c1>{package}</c1>"
314323
)
315324

316325
constraint["version"] = package_constraint

0 commit comments

Comments
 (0)