1
0
Fork 0
mirror of https://github.com/python-poetry/install.python-poetry.org.git synced 2024-11-22 06:00:59 -05:00

chore: clean up minor code smells

This resolves some code smells found during python-poetry/poetry#4773. I
have not yet added the new lints to this repo, but I once they're
relatively stable/agreed on the main repo I will PR them here.
This commit is contained in:
Bjorn Neergaard 2021-11-16 09:38:35 -07:00
parent ea79142501
commit 2f92f18b7b

View file

@ -213,7 +213,7 @@ def _get_win_folder_with_ctypes(csidl_name):
if WINDOWS: if WINDOWS:
try: try:
from ctypes import windll # noqa from ctypes import windll # noqa: F401
_get_win_folder = _get_win_folder_with_ctypes _get_win_folder = _get_win_folder_with_ctypes
except ImportError: except ImportError:
@ -580,7 +580,7 @@ class Installer:
try: try:
self._install_comment(version, "Creating environment") self._install_comment(version, "Creating environment")
yield VirtualEnvironment.make(env_path) yield VirtualEnvironment.make(env_path)
except Exception as e: # noqa except Exception as e:
if env_path.exists(): if env_path.exists():
self._install_comment( self._install_comment(
version, "An error occurred. Removing partial environment." version, "An error occurred. Removing partial environment."
@ -871,7 +871,7 @@ def main():
try: try:
return installer.run() return installer.run()
except PoetryInstallationError as e: except PoetryInstallationError as e:
installer._write(colorize("error", "Poetry installation failed.")) # noqa installer._write(colorize("error", "Poetry installation failed."))
if e.log is not None: if e.log is not None:
import traceback import traceback
@ -882,7 +882,7 @@ def main():
dir=str(Path.cwd()), dir=str(Path.cwd()),
text=True, text=True,
) )
installer._write(colorize("error", f"See {path} for error logs.")) # noqa 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}\nTraceback:\n\n{''.join(traceback.format_tb(e.__traceback__))}"
Path(path).write_text(text) Path(path).write_text(text)