Skip to content

Commit 9b64f71

Browse files
authored
Added pyupgrade check and upgraded script code (#16)
1 parent ae8a9ad commit 9b64f71

File tree

2 files changed

+23
-12
lines changed

2 files changed

+23
-12
lines changed

.pre-commit-config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,9 @@ repos:
2626
args:
2727
- --autofix
2828
- id: check-json
29+
30+
- repo: https://github.com/asottile/pyupgrade
31+
rev: v2.34.0
32+
hooks:
33+
- id: pyupgrade
34+
args: [--py36-plus]

install-poetry.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def colorize(style, text):
134134
if not is_decorated():
135135
return text
136136

137-
return "{}{}\033[0m".format(STYLES[style], text)
137+
return f"{STYLES[style]}{text}\033[0m"
138138

139139

140140
def string_to_bool(value):
@@ -267,7 +267,7 @@ def _get_win_folder_with_ctypes(csidl_name):
267267

268268
class PoetryInstallationError(RuntimeError):
269269
def __init__(self, return_code: int = 0, log: Optional[str] = None):
270-
super(PoetryInstallationError, self).__init__()
270+
super().__init__()
271271
self.return_code = return_code
272272
self.log = log
273273

@@ -367,32 +367,32 @@ def __init__(self) -> None:
367367
self._output = sys.stdout
368368

369369
def move_up(self, lines: int = 1) -> "Cursor":
370-
self._output.write("\x1b[{}A".format(lines))
370+
self._output.write(f"\x1b[{lines}A")
371371

372372
return self
373373

374374
def move_down(self, lines: int = 1) -> "Cursor":
375-
self._output.write("\x1b[{}B".format(lines))
375+
self._output.write(f"\x1b[{lines}B")
376376

377377
return self
378378

379379
def move_right(self, columns: int = 1) -> "Cursor":
380-
self._output.write("\x1b[{}C".format(columns))
380+
self._output.write(f"\x1b[{columns}C")
381381

382382
return self
383383

384384
def move_left(self, columns: int = 1) -> "Cursor":
385-
self._output.write("\x1b[{}D".format(columns))
385+
self._output.write(f"\x1b[{columns}D")
386386

387387
return self
388388

389389
def move_to_column(self, column: int) -> "Cursor":
390-
self._output.write("\x1b[{}G".format(column))
390+
self._output.write(f"\x1b[{column}G")
391391

392392
return self
393393

394394
def move_to_position(self, column: int, row: int) -> "Cursor":
395-
self._output.write("\x1b[{};{}H".format(row + 1, column))
395+
self._output.write(f"\x1b[{row + 1};{column}H")
396396

397397
return self
398398

@@ -789,7 +789,7 @@ def _compare_versions(x, y):
789789
)
790790

791791
if self._version and self._version not in releases:
792-
msg = "Version {} does not exist.".format(self._version)
792+
msg = f"Version {self._version} does not exist."
793793
self._write(colorize("error", msg))
794794

795795
raise ValueError(msg)
@@ -807,9 +807,7 @@ def _compare_versions(x, y):
807807

808808
if current_version == version and not self._force:
809809
self._write(
810-
"The latest version ({}) is already installed.".format(
811-
colorize("b", version)
812-
)
810+
f'The latest version ({colorize("b", version)}) is already installed.'
813811
)
814812

815813
return None, current_version
@@ -835,6 +833,13 @@ def _get(self, url):
835833

836834

837835
def main():
836+
if sys.version_info < (3, 6):
837+
sys.stdout.write(
838+
colorize("error", "Poetry installer requires Python 3.6 or newer to run!")
839+
)
840+
# return error code
841+
return 1
842+
838843
parser = argparse.ArgumentParser(
839844
description="Installs the latest (or given) version of poetry"
840845
)

0 commit comments

Comments
 (0)