Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap long lines to comply with flake8 E501 #4985

Merged
merged 24 commits into from
Jan 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
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
2 changes: 0 additions & 2 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ enable-extensions = TC, TC2
type-checking-exempt-modules = typing, typing-extensions
eradicate-whitelist-extend = ^-.*;
extend-ignore =
# E501: Line too long (FIXME: long string constants)
E501,
# E203: Whitespace before ':' (pycqa/pycodestyle#373)
E203,
# SIM106: Handle error-cases first
Expand Down
31 changes: 18 additions & 13 deletions get-poetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,21 +458,21 @@ def _is_supported(x):
print(
colorize(
"error",
"Version {version} does not support this installation method. Please specify a version prior to "
"1.2.0a1 explicitly using the '--version' option.\n"
"Please see "
"https://python-poetry.org/blog/announcing-poetry-1-2-0a1.html#deprecation-of-the-get-poetry-py-script "
"for more information.".format(version=version),
"Version {version} does not support this installation method."
" Please specify a version prior to 1.2.0a1 explicitly using the"
" '--version' option.\nPlease see"
" https://python-poetry.org/blog/announcing-poetry-1-2-0a1.html#deprecation-of-the-get-poetry-py-script"
" for more information.".format(version=version),
)
)
return None, None

print(
colorize(
"warning",
"This installer is deprecated. "
"Poetry versions installed using this script will not be able to use 'self update' command to upgrade to "
"1.2.0a1 or later.",
"This installer is deprecated. Poetry versions installed using this"
" script will not be able to use 'self update' command to upgrade to"
" 1.2.0a1 or later.",
)
)

Expand Down Expand Up @@ -685,7 +685,8 @@ def _which_python(self):
return executable

if fallback is None:
# keep this one as the fallback; it was the first valid executable we found.
# keep this one as the fallback; it was the first valid executable we
# found.
fallback = executable

if fallback is None:
Expand Down Expand Up @@ -773,7 +774,8 @@ def add_to_fish_path(self):
print(
colorize(
"warning",
"\nUnable to get the PATH value. It will not be updated automatically.",
"\nUnable to get the PATH value. It will not be updated"
" automatically.",
)
)
self._modify_path = False
Expand Down Expand Up @@ -808,7 +810,8 @@ def add_to_windows_path(self):
print(
colorize(
"warning",
"Unable to get the PATH value. It will not be updated automatically",
"Unable to get the PATH value. It will not be updated"
" automatically",
)
)
self._modify_path = False
Expand Down Expand Up @@ -1074,8 +1077,10 @@ def main():
"--file",
dest="file",
action="store",
help="Install from a local file instead of fetching the latest version "
"of Poetry available online.",
help=(
"Install from a local file instead of fetching the latest version "
"of Poetry available online."
),
)

args = parser.parse_args()
Expand Down
24 changes: 16 additions & 8 deletions install-poetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,8 @@ def __init__(self, return_code: int = 0, log: Optional[str] = None):
class VirtualEnvironment:
def __init__(self, path: Path) -> None:
self._path = path
# str is required for compatibility with subprocess run on CPython <= 3.7 on Windows
# str is required for compatibility with subprocess run on CPython <= 3.7 on
# Windows
self._python = str(
self._path.joinpath("Scripts/python.exe" if WINDOWS else "bin/python")
)
Expand Down Expand Up @@ -313,7 +314,8 @@ def make(cls, target: Path) -> "VirtualEnvironment":

env = cls(target)

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

return env
Expand Down Expand Up @@ -480,7 +482,8 @@ def _is_self_upgrade_supported(x):
mx = self.VERSION_REGEX.match(x)

if mx is None:
# the version is not semver, perhaps scm or file, we assume upgrade is supported
# the version is not semver, perhaps scm or file, we assume upgrade is
# supported
return True

vx = tuple(int(p) for p in mx.groups()[:3]) + (mx.group(5),)
Expand All @@ -490,8 +493,9 @@ def _is_self_upgrade_supported(x):
self._write(
colorize(
"warning",
f"You are installing {version}. When using the current installer, this version does not support "
f"updating using the 'self update' command. Please use 1.1.7 or later.",
f"You are installing {version}. When using the current installer,"
" this version does not support updating using the 'self update'"
" command. Please use 1.1.7 or later.",
)
)
if not self._accept_all:
Expand Down Expand Up @@ -883,7 +887,10 @@ def main():
text=True,
)
installer._write(colorize("error", f"See {path} for error logs."))
text = f"{e.log}\nTraceback:\n\n{''.join(traceback.format_tb(e.__traceback__))}"
text = (
f"{e.log}\n"
f"Traceback:\n\n{''.join(traceback.format_tb(e.__traceback__))}"
)
Path(path).write_text(text)

return e.return_code
Expand All @@ -893,8 +900,9 @@ def main():
sys.stdout.write(
colorize(
"warning",
"The canonical source for Poetry's installation script is now https://install.python-poetry.org. "
"Please update your usage to reflect this.\n",
"The canonical source for Poetry's installation script is now"
" https://install.python-poetry.org. Please update your usage to reflect"
" this.\n",
)
)
sys.exit(main())
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ extend_skip = ["setup.py"]

[tool.black]
target-version = ['py36']
experimental_string_processing = true
force-exclude = '''
.*/setup\.py$
'''
Expand Down
2 changes: 1 addition & 1 deletion src/poetry/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore[has-type]
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore[has-type] # noqa: E501
2 changes: 1 addition & 1 deletion src/poetry/console/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ def _get_solution_provider_repository(self) -> "SolutionProviderRepository":
SolutionProviderRepository,
)

from poetry.mixology.solutions.providers.python_requirement_solution_provider import (
from poetry.mixology.solutions.providers.python_requirement_solution_provider import ( # noqa: E501
PythonRequirementSolutionProvider,
)

Expand Down
9 changes: 6 additions & 3 deletions src/poetry/console/commands/about.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ class AboutCommand(Command):

def handle(self) -> None:
self.line(
"""<info>Poetry - Package Management for Python</info>
"""\
<info>Poetry - Package Management for Python</info>

<comment>Poetry is a dependency manager tracking local dependencies of your projects and libraries.
See <fg=blue>https://github.com/python-poetry/poetry</> for more information.</comment>"""
<comment>Poetry is a dependency manager tracking local dependencies of your projects\
and libraries.
See <fg=blue>https://github.com/python-poetry/poetry</> for more information.</comment>\
"""
)
45 changes: 27 additions & 18 deletions src/poetry/console/commands/add.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,31 @@ 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)."),
]
help = (
"The add command adds required packages to your <comment>pyproject.toml</> and installs them.\n\n"
"If you do not specify a version constraint, poetry will choose a suitable one based on the available package versions.\n\n"
"You can specify a package in the following forms:\n"
" - A single name (<b>requests</b>)\n"
" - A name and a constraint (<b>requests@^2.23.0</b>)\n"
" - A git url (<b>git+https://github.com/python-poetry/poetry.git</b>)\n"
" - A git url with a revision (<b>git+https://github.com/python-poetry/poetry.git#develop</b>)\n"
" - A git SSH url (<b>git+ssh://github.com/python-poetry/poetry.git</b>)\n"
" - A git SSH url with a revision (<b>git+ssh://github.com/python-poetry/poetry.git#develop</b>)\n"
" - A file path (<b>../my-package/my-package.whl</b>)\n"
" - A directory (<b>../my-package/</b>)\n"
" - A url (<b>https://example.com/packages/my-package-0.1.0.tar.gz</b>)\n"
)
help = """\
The add command adds required packages to your <comment>pyproject.toml</> and installs\
them.

If you do not specify a version constraint, poetry will choose a suitable one based on\
the available package versions.

You can specify a package in the following forms:
- A single name (<b>requests</b>)
- A name and a constraint (<b>requests@^2.23.0</b>)
- A git url (<b>git+https://github.com/python-poetry/poetry.git</b>)
- A git url with a revision\
(<b>git+https://github.com/python-poetry/poetry.git#develop</b>)
- A git SSH url (<b>git+ssh://github.com/python-poetry/poetry.git</b>)
- A git SSH url with a revision\
(<b>git+ssh://github.com/python-poetry/poetry.git#develop</b>)
- A file path (<b>../my-package/my-package.whl</b>)
- A directory (<b>../my-package/</b>)
- A url (<b>https://example.com/packages/my-package-0.1.0.tar.gz</b>)
"""

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

Expand Down Expand Up @@ -244,11 +251,13 @@ def get_existing_packages_from_input(

def notify_about_existing_packages(self, existing_packages: List[str]) -> None:
self.line(
"The following packages are already present in the pyproject.toml and will be skipped:\n"
"The following packages are already present in the pyproject.toml and will"
" be skipped:\n"
)
for name in existing_packages:
self.line(f" • <c1>{name}</c1>")
self.line(
"\nIf you want to update it to the latest compatible version, you can use `poetry update package`.\n"
"If you prefer to upgrade it to the latest available version, you can use `poetry add package@latest`.\n"
"\nIf you want to update it to the latest compatible version, you can use"
" `poetry update package`.\nIf you prefer to upgrade it to the latest"
" available version, you can use `poetry add package@latest`.\n"
)
3 changes: 1 addition & 2 deletions src/poetry/console/commands/cache/clear.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ def handle(self) -> int:
if len(parts) == 1:
if not self.option("all"):
raise RuntimeError(
"Add the --all option if you want to clear all "
f"{parts[0]} caches"
f"Add the --all option if you want to clear all {parts[0]} caches"
)

if not os.path.exists(str(cache_dir)):
Expand Down
9 changes: 6 additions & 3 deletions src/poetry/console/commands/env/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,15 @@ def _display_complete_info(self, env: "Env") -> None:
listing = [
f"<info>Python</info>: <comment>{env_python_version}</>",
f"<info>Implementation</info>: <comment>{env.python_implementation}</>",
f"<info>Path</info>: <comment>{env.path if env.is_venv() else 'NA'}</>",
f"<info>Executable</info>: <comment>{env.python if env.is_venv() else 'NA'}</>",
"<info>Path</info>: "
f" <comment>{env.path if env.is_venv() else 'NA'}</>",
"<info>Executable</info>: "
f" <comment>{env.python if env.is_venv() else 'NA'}</>",
]
if env.is_venv():
listing.append(
f"<info>Valid</info>: <{'comment' if env.is_sane() else 'error'}>{env.is_sane()}</>"
"<info>Valid</info>: "
f" <{'comment' if env.is_sane() else 'error'}>{env.is_sane()}</>"
)
self.line("\n".join(listing))

Expand Down
9 changes: 5 additions & 4 deletions src/poetry/console/commands/env/remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,18 @@ 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,
)
]
options = [
option(
"all",
description="Remove all managed virtual environments associated with the "
"project.",
description=(
"Remove all managed virtual environments associated with the project."
),
),
]

Expand Down
43 changes: 26 additions & 17 deletions src/poetry/console/commands/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ class InitCommand(Command):
]

help = """\
The <c1>init</c1> command creates a basic <comment>pyproject.toml</> file in the current directory.
The <c1>init</c1> command creates a basic <comment>pyproject.toml</> file in the\
current directory.
"""

def __init__(self) -> None:
Expand All @@ -76,13 +77,15 @@ def handle(self) -> int:
if pyproject.file.exists():
if pyproject.is_poetry_project():
self.line(
"<error>A pyproject.toml file with a poetry section already exists.</error>"
"<error>A pyproject.toml file with a poetry section already"
" exists.</error>"
)
return 1

if pyproject.data.get("build-system"):
self.line(
"<error>A pyproject.toml file with a defined build-system already exists.</error>"
"<error>A pyproject.toml file with a defined build-system already"
" exists.</error>"
)
return 1

Expand All @@ -91,7 +94,8 @@ def handle(self) -> int:
if self.io.is_interactive():
self.line("")
self.line(
"This command will guide you through creating your <info>pyproject.toml</> config."
"This command will guide you through creating your"
" <info>pyproject.toml</> config."
)
self.line("")

Expand Down Expand Up @@ -165,16 +169,18 @@ def handle(self) -> int:
)

question = "Would you like to define your main dependencies interactively?"
help_message = (
"You can specify a package in the following forms:\n"
" - A single name (<b>requests</b>)\n"
" - A name and a constraint (<b>requests@^2.23.0</b>)\n"
" - A git url (<b>git+https://github.com/python-poetry/poetry.git</b>)\n"
" - A git url with a revision (<b>git+https://github.com/python-poetry/poetry.git#develop</b>)\n"
" - A file path (<b>../my-package/my-package.whl</b>)\n"
" - A directory (<b>../my-package/</b>)\n"
" - A url (<b>https://example.com/packages/my-package-0.1.0.tar.gz</b>)\n"
)
help_message = """\
You can specify a package in the following forms:
- A single name (<b>requests</b>)
- A name and a constraint (<b>requests@^2.23.0</b>)
- A git url (<b>git+https://github.com/python-poetry/poetry.git</b>)
- A git url with a revision\
(<b>git+https://github.com/python-poetry/poetry.git#develop</b>)
- A file path (<b>../my-package/my-package.whl</b>)
- A directory (<b>../my-package/</b>)
- A url (<b>https://example.com/packages/my-package-0.1.0.tar.gz</b>)
"""

help_displayed = False
if self.confirm(question, True):
if self.io.is_interactive():
Expand Down Expand Up @@ -280,11 +286,13 @@ def _determine_requirements(
choices.append(found_package.pretty_name)

self.line(
f"Found <info>{len(matches)}</info> packages matching <c1>{package}</c1>"
f"Found <info>{len(matches)}</info> packages matching"
f" <c1>{package}</c1>"
)

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,
)
Expand All @@ -310,7 +318,8 @@ def _determine_requirements(
)

self.line(
f"Using version <b>{package_constraint}</b> for <c1>{package}</c1>"
f"Using version <b>{package_constraint}</b> for"
f" <c1>{package}</c1>"
)

constraint["version"] = package_constraint
Expand Down
Loading