From e30b0de0fbf738f807586f1eaedaac00334bfec1 Mon Sep 17 00:00:00 2001 From: Felipe Campos Date: Tue, 2 Jun 2020 10:48:40 -0700 Subject: [PATCH 01/12] colorama shorthand ANSI sequence for red error text --- setup.cfg | 1 + twine/__main__.py | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index fadcc21b..b5e81b26 100644 --- a/setup.cfg +++ b/setup.cfg @@ -43,6 +43,7 @@ install_requires= importlib_metadata; python_version < "3.8" keyring >= 15.1 rfc3986 >= 1.4.0 + colorama >= 0.4.3 setup_requires = setuptools_scm >= 1.15 include_package_data = True diff --git a/twine/__main__.py b/twine/__main__.py index 1bd71b0c..0685ffdd 100644 --- a/twine/__main__.py +++ b/twine/__main__.py @@ -15,6 +15,7 @@ import sys from typing import Any +import colorama # type: ignore import requests from twine import cli @@ -23,9 +24,15 @@ def main() -> Any: try: + colorama.init() return cli.dispatch(sys.argv[1:]) except (exceptions.TwineException, requests.HTTPError) as exc: - return "{}: {}".format(exc.__class__.__name__, exc.args[0]) + return "{}{}: {}{}".format( + colorama.Fore.RED, + exc.__class__.__name__, + exc.args[0], + colorama.Style.RESET_ALL, + ) if __name__ == "__main__": From 761a4fa58f13466671bb7dae0121c61eb0fcbe31 Mon Sep 17 00:00:00 2001 From: Felipe Campos Date: Tue, 2 Jun 2020 10:50:46 -0700 Subject: [PATCH 02/12] ignore colorama imports in mypy config file --- mypy.ini | 4 ++++ twine/__main__.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/mypy.ini b/mypy.ini index 9db3a7c7..a4043596 100644 --- a/mypy.ini +++ b/mypy.ini @@ -18,6 +18,10 @@ warn_return_any = True no_implicit_reexport = True strict_equality = True +[mypy-colorama] +; https://github.com/tartley/colorama/issues/206 +ignore_missing_imports = True + [mypy-importlib_metadata] ; https://gitlab.com/python-devs/importlib_metadata/-/issues/10 ignore_missing_imports = True diff --git a/twine/__main__.py b/twine/__main__.py index 0685ffdd..45a1504b 100644 --- a/twine/__main__.py +++ b/twine/__main__.py @@ -15,7 +15,7 @@ import sys from typing import Any -import colorama # type: ignore +import colorama import requests from twine import cli From cc99aea6016b277bc99d55817920fb2c8b2da94b Mon Sep 17 00:00:00 2001 From: Felipe Campos Date: Tue, 2 Jun 2020 12:15:16 -0700 Subject: [PATCH 03/12] update tests and authors list --- AUTHORS | 1 + tests/test_main.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index 350e944a..dde4f351 100644 --- a/AUTHORS +++ b/AUTHORS @@ -26,3 +26,4 @@ Wasim Thabraze Varun Kamath Brian Rutledge Peter Stensmyr (http://www.peterstensmyr.com) +Felipe Rocha Campos diff --git a/tests/test_main.py b/tests/test_main.py index e8869f94..7293a3f6 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -11,6 +11,7 @@ # limitations under the License. import pretend +import colorama from twine import __main__ as dunder_main from twine import cli @@ -20,4 +21,4 @@ def test_exception_handling(monkeypatch): replaced_dispatch = pretend.raiser(exceptions.InvalidConfiguration("foo")) monkeypatch.setattr(cli, "dispatch", replaced_dispatch) - assert dunder_main.main() == "InvalidConfiguration: foo" + assert dunder_main.main() == colorama.Fore.RED + "InvalidConfiguration: foo" + colorama.Style.RESET_ALL From e4b0263a6e35bba01331e917fe4dc79ecb1ffecf Mon Sep 17 00:00:00 2001 From: Felipe Campos Date: Tue, 2 Jun 2020 12:18:17 -0700 Subject: [PATCH 04/12] style --- tests/test_main.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/test_main.py b/tests/test_main.py index 7293a3f6..12808670 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -10,8 +10,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pretend import colorama +import pretend from twine import __main__ as dunder_main from twine import cli @@ -21,4 +21,7 @@ def test_exception_handling(monkeypatch): replaced_dispatch = pretend.raiser(exceptions.InvalidConfiguration("foo")) monkeypatch.setattr(cli, "dispatch", replaced_dispatch) - assert dunder_main.main() == colorama.Fore.RED + "InvalidConfiguration: foo" + colorama.Style.RESET_ALL + assert ( + dunder_main.main() + == colorama.Fore.RED + "InvalidConfiguration: foo" + colorama.Style.RESET_ALL + ) From 33d2693a352da4be477a013cb908c1c5d2f6f40c Mon Sep 17 00:00:00 2001 From: Felipe Campos Date: Tue, 2 Jun 2020 15:16:29 -0700 Subject: [PATCH 05/12] gracefully handle colorama not being available --- twine/__main__.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/twine/__main__.py b/twine/__main__.py index 45a1504b..ed2cf758 100644 --- a/twine/__main__.py +++ b/twine/__main__.py @@ -15,23 +15,29 @@ import sys from typing import Any -import colorama import requests from twine import cli from twine import exceptions +try: + import colorama +except Exception: + colorama = None + def main() -> Any: try: - colorama.init() + if colorama: + colorama.init() return cli.dispatch(sys.argv[1:]) except (exceptions.TwineException, requests.HTTPError) as exc: + pre_style, post_style = "", "" + if colorama: + pre_style, post_style = colorama.Fore.RED, colorama.Style.RESET_ALL + return "{}{}: {}{}".format( - colorama.Fore.RED, - exc.__class__.__name__, - exc.args[0], - colorama.Style.RESET_ALL, + pre_style, exc.__class__.__name__, exc.args[0], post_style, ) From 37f15f9f7638db10da6a7813d43fbceeefd79110 Mon Sep 17 00:00:00 2001 From: Felipe Campos Date: Wed, 3 Jun 2020 11:14:02 -0700 Subject: [PATCH 06/12] remove colorama import exception handling --- twine/__main__.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/twine/__main__.py b/twine/__main__.py index ed2cf758..52a2e851 100644 --- a/twine/__main__.py +++ b/twine/__main__.py @@ -15,26 +15,19 @@ import sys from typing import Any +import colorama import requests from twine import cli from twine import exceptions -try: - import colorama -except Exception: - colorama = None - def main() -> Any: try: - if colorama: - colorama.init() + colorama.init() return cli.dispatch(sys.argv[1:]) except (exceptions.TwineException, requests.HTTPError) as exc: - pre_style, post_style = "", "" - if colorama: - pre_style, post_style = colorama.Fore.RED, colorama.Style.RESET_ALL + pre_style, post_style = colorama.Fore.RED, colorama.Style.RESET_ALL return "{}{}: {}{}".format( pre_style, exc.__class__.__name__, exc.args[0], post_style, From 0f8f8b602c8b137b03d23e6ad73e4dd15df6fb10 Mon Sep 17 00:00:00 2001 From: Felipe Campos Date: Wed, 3 Jun 2020 12:25:36 -0700 Subject: [PATCH 07/12] moving colorama.init() & remove local colorama bindings --- twine/__main__.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/twine/__main__.py b/twine/__main__.py index 52a2e851..3b5ec366 100644 --- a/twine/__main__.py +++ b/twine/__main__.py @@ -23,14 +23,15 @@ def main() -> Any: + colorama.init() try: - colorama.init() return cli.dispatch(sys.argv[1:]) except (exceptions.TwineException, requests.HTTPError) as exc: - pre_style, post_style = colorama.Fore.RED, colorama.Style.RESET_ALL - return "{}{}: {}{}".format( - pre_style, exc.__class__.__name__, exc.args[0], post_style, + colorama.Fore.RED, + exc.__class__.__name__, + exc.args[0], + colorama.Style.RESET_ALL, ) From f667a1d7fe98f2012d077502124ed264e178c426 Mon Sep 17 00:00:00 2001 From: Felipe Campos Date: Fri, 5 Jun 2020 12:04:12 -0700 Subject: [PATCH 08/12] add no-color flag --- twine/__main__.py | 20 +++++++++++++++----- twine/settings.py | 7 +++++++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/twine/__main__.py b/twine/__main__.py index 3b5ec366..1ccaa5ac 100644 --- a/twine/__main__.py +++ b/twine/__main__.py @@ -12,6 +12,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +import argparse import sys from typing import Any @@ -23,15 +24,24 @@ def main() -> Any: - colorama.init() try: return cli.dispatch(sys.argv[1:]) except (exceptions.TwineException, requests.HTTPError) as exc: + # somehow parse args here + parser = argparse.ArgumentParser() + parser.add_argument( + "--no_color", default=False, required=False, action="store_true", + ) + + args, _ = parser.parse_known_args(sys.argv[1:]) + + pre_style, post_style = "", "" + if not args.no_color: + colorama.init() + pre_style, post_style = colorama.Fore.RED, colorama.Style.RESET_ALL + return "{}{}: {}{}".format( - colorama.Fore.RED, - exc.__class__.__name__, - exc.args[0], - colorama.Style.RESET_ALL, + pre_style, exc.__class__.__name__, exc.args[0], post_style, ) diff --git a/twine/settings.py b/twine/settings.py index 34c23435..8a720f56 100644 --- a/twine/settings.py +++ b/twine/settings.py @@ -263,6 +263,13 @@ def register_argparse_arguments(parser: argparse.ArgumentParser) -> None: action="store_true", help="Disable the progress bar.", ) + parser.add_argument( + "--no_color", + default=False, + required=False, + action="store_true", + help="Disable colored output.", + ) @classmethod def from_argparse(cls, args: argparse.Namespace) -> "Settings": From 9eb228104f989b5a857b8a462e94b224d2ffa460 Mon Sep 17 00:00:00 2001 From: Felipe Campos Date: Fri, 5 Jun 2020 12:20:31 -0700 Subject: [PATCH 09/12] add no-color test --- tests/test_main.py | 9 +++++++++ twine/__main__.py | 3 +-- twine/settings.py | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/test_main.py b/tests/test_main.py index 12808670..6eea753d 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -10,6 +10,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import sys + import colorama import pretend @@ -25,3 +27,10 @@ def test_exception_handling(monkeypatch): dunder_main.main() == colorama.Fore.RED + "InvalidConfiguration: foo" + colorama.Style.RESET_ALL ) + + +def test_no_color_exception(monkeypatch): + replaced_dispatch = pretend.raiser(exceptions.InvalidConfiguration("foo")) + monkeypatch.setattr(cli, "dispatch", replaced_dispatch) + monkeypatch.setattr(sys, "argv", ["upload", "--no-color"]) + assert dunder_main.main() == "InvalidConfiguration: foo" diff --git a/twine/__main__.py b/twine/__main__.py index 1ccaa5ac..189b7d79 100644 --- a/twine/__main__.py +++ b/twine/__main__.py @@ -27,10 +27,9 @@ def main() -> Any: try: return cli.dispatch(sys.argv[1:]) except (exceptions.TwineException, requests.HTTPError) as exc: - # somehow parse args here parser = argparse.ArgumentParser() parser.add_argument( - "--no_color", default=False, required=False, action="store_true", + "--no-color", default=False, required=False, action="store_true", ) args, _ = parser.parse_known_args(sys.argv[1:]) diff --git a/twine/settings.py b/twine/settings.py index 8a720f56..043877b9 100644 --- a/twine/settings.py +++ b/twine/settings.py @@ -264,7 +264,7 @@ def register_argparse_arguments(parser: argparse.ArgumentParser) -> None: help="Disable the progress bar.", ) parser.add_argument( - "--no_color", + "--no-color", default=False, required=False, action="store_true", From e54201b8954d92688f635f61f70de349619cc57d Mon Sep 17 00:00:00 2001 From: Felipe Campos Date: Thu, 11 Jun 2020 09:46:11 -0700 Subject: [PATCH 10/12] f-string colorama formatting in helper method --- tox.ini | 1 + twine/__main__.py | 26 ++++++++++++++------------ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/tox.ini b/tox.ini index 115b31e0..e28ff85b 100644 --- a/tox.ini +++ b/tox.ini @@ -11,6 +11,7 @@ deps = portend pytest-services munch + colorama passenv = PYTEST_ADDOPTS commands = diff --git a/twine/__main__.py b/twine/__main__.py index 189b7d79..91c576cf 100644 --- a/twine/__main__.py +++ b/twine/__main__.py @@ -27,21 +27,23 @@ def main() -> Any: try: return cli.dispatch(sys.argv[1:]) except (exceptions.TwineException, requests.HTTPError) as exc: - parser = argparse.ArgumentParser() - parser.add_argument( - "--no-color", default=False, required=False, action="store_true", - ) + return _format_error(f"{exc.__class__.__name__}: {exc.args[0]}") - args, _ = parser.parse_known_args(sys.argv[1:]) - pre_style, post_style = "", "" - if not args.no_color: - colorama.init() - pre_style, post_style = colorama.Fore.RED, colorama.Style.RESET_ALL +def _format_error(err: str) -> str: + parser = argparse.ArgumentParser() + parser.add_argument( + "--no-color", default=False, required=False, action="store_true", + ) - return "{}{}: {}{}".format( - pre_style, exc.__class__.__name__, exc.args[0], post_style, - ) + args, _ = parser.parse_known_args(sys.argv[1:]) + + pre_style, post_style = "", "" + if not args.no_color: + colorama.init() + pre_style, post_style = colorama.Fore.RED, colorama.Style.RESET_ALL + + return f"{pre_style}{err}{post_style}" if __name__ == "__main__": From e683bff28f8e1beda6f4597c9b5ddbeb3ad1653f Mon Sep 17 00:00:00 2001 From: Felipe Campos Date: Fri, 12 Jun 2020 19:16:29 -0700 Subject: [PATCH 11/12] no-color option working for twine check with updated tests --- tests/test_check.py | 5 +++-- twine/__main__.py | 19 +++++++++---------- twine/commands/check.py | 11 +++++++++-- twine/settings.py | 2 ++ 4 files changed, 23 insertions(+), 14 deletions(-) diff --git a/tests/test_check.py b/tests/test_check.py index 3d2c5ea3..860a4089 100644 --- a/tests/test_check.py +++ b/tests/test_check.py @@ -18,6 +18,7 @@ from twine import commands from twine import package as package_file +from twine import settings from twine.commands import check @@ -158,8 +159,8 @@ def test_check_failing_distribution(monkeypatch): def test_main(monkeypatch): check_result = pretend.stub() - check_stub = pretend.call_recorder(lambda a: check_result) + check_stub = pretend.call_recorder(lambda a, check_settings: check_result) monkeypatch.setattr(check, "check", check_stub) assert check.main(["dist/*"]) == check_result - assert check_stub.calls == [pretend.call(["dist/*"])] + assert check_stub.calls[0].args[0] == ["dist/*"] diff --git a/twine/__main__.py b/twine/__main__.py index 91c576cf..1a05ce30 100644 --- a/twine/__main__.py +++ b/twine/__main__.py @@ -21,29 +21,28 @@ from twine import cli from twine import exceptions +from twine import settings def main() -> Any: try: return cli.dispatch(sys.argv[1:]) except (exceptions.TwineException, requests.HTTPError) as exc: - return _format_error(f"{exc.__class__.__name__}: {exc.args[0]}") + parser = argparse.ArgumentParser() + settings.Settings.register_argparse_arguments(parser) + args, _ = parser.parse_known_args(sys.argv[1:]) + color = not settings.Settings.from_argparse(args).no_color + return _format_error(f"{exc.__class__.__name__}: {exc.args[0]}", color=color) -def _format_error(err: str) -> str: - parser = argparse.ArgumentParser() - parser.add_argument( - "--no-color", default=False, required=False, action="store_true", - ) - - args, _ = parser.parse_known_args(sys.argv[1:]) +def _format_error(message: str, color: bool = True) -> str: pre_style, post_style = "", "" - if not args.no_color: + if color: colorama.init() pre_style, post_style = colorama.Fore.RED, colorama.Style.RESET_ALL - return f"{pre_style}{err}{post_style}" + return f"{pre_style}{message}{post_style}" if __name__ == "__main__": diff --git a/twine/commands/check.py b/twine/commands/check.py index d8a1317d..b32a3154 100644 --- a/twine/commands/check.py +++ b/twine/commands/check.py @@ -27,6 +27,7 @@ from twine import commands from twine import package as package_file +from twine import settings _RENDERERS = { None: readme_renderer.rst, # Default if description_content_type is None @@ -105,7 +106,11 @@ def _check_file( return warnings, is_ok -def check(dists: List[str], output_stream: IO[str] = sys.stdout) -> bool: +def check( + dists: List[str], + output_stream: IO[str] = sys.stdout, + check_settings: Optional[settings.Settings] = None, +) -> bool: uploads = [i for i in commands._find_dists(dists) if not i.endswith(".asc")] if not uploads: # Return early, if there are no files to check. output_stream.write("No files to check.\n") @@ -143,6 +148,7 @@ def check(dists: List[str], output_stream: IO[str] = sys.stdout) -> bool: def main(args: List[str]) -> bool: parser = argparse.ArgumentParser(prog="twine check") + settings.Settings.register_argparse_arguments(parser) parser.add_argument( "dists", nargs="+", @@ -151,6 +157,7 @@ def main(args: List[str]) -> bool: ) parsed_args = parser.parse_args(args) + check_settings = settings.Settings.from_argparse(parsed_args) # Call the check function with the arguments from the command line - return check(parsed_args.dists) + return check(parsed_args.dists, check_settings=check_settings) diff --git a/twine/settings.py b/twine/settings.py index 043877b9..ae7e5f74 100644 --- a/twine/settings.py +++ b/twine/settings.py @@ -59,6 +59,7 @@ def __init__( repository_url: Optional[str] = None, verbose: bool = False, disable_progress_bar: bool = False, + no_color: bool = False, **ignored_kwargs: Any, ) -> None: """Initialize our settings instance. @@ -122,6 +123,7 @@ def __init__( self.comment = comment self.verbose = verbose self.disable_progress_bar = disable_progress_bar + self.no_color = no_color self.skip_existing = skip_existing self._handle_repository_options( repository_name=repository_name, repository_url=repository_url, From dac0a85ccef93fdbe042e74d55826bfecdac048f Mon Sep 17 00:00:00 2001 From: Brian Rutledge Date: Wed, 17 Jun 2020 05:39:42 -0400 Subject: [PATCH 12/12] Move --no-color to base command --- tests/test_check.py | 5 ++--- tests/test_main.py | 19 ++++++------------- twine/__main__.py | 13 +++---------- twine/cli.py | 11 ++++++++++- twine/commands/check.py | 11 ++--------- twine/settings.py | 9 --------- 6 files changed, 23 insertions(+), 45 deletions(-) diff --git a/tests/test_check.py b/tests/test_check.py index 860a4089..3d2c5ea3 100644 --- a/tests/test_check.py +++ b/tests/test_check.py @@ -18,7 +18,6 @@ from twine import commands from twine import package as package_file -from twine import settings from twine.commands import check @@ -159,8 +158,8 @@ def test_check_failing_distribution(monkeypatch): def test_main(monkeypatch): check_result = pretend.stub() - check_stub = pretend.call_recorder(lambda a, check_settings: check_result) + check_stub = pretend.call_recorder(lambda a: check_result) monkeypatch.setattr(check, "check", check_stub) assert check.main(["dist/*"]) == check_result - assert check_stub.calls[0].args[0] == ["dist/*"] + assert check_stub.calls == [pretend.call(["dist/*"])] diff --git a/tests/test_main.py b/tests/test_main.py index 6eea753d..9fa53dcf 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -13,24 +13,17 @@ import sys import colorama -import pretend from twine import __main__ as dunder_main -from twine import cli -from twine import exceptions def test_exception_handling(monkeypatch): - replaced_dispatch = pretend.raiser(exceptions.InvalidConfiguration("foo")) - monkeypatch.setattr(cli, "dispatch", replaced_dispatch) - assert ( - dunder_main.main() - == colorama.Fore.RED + "InvalidConfiguration: foo" + colorama.Style.RESET_ALL - ) + monkeypatch.setattr(sys, "argv", ["twine", "upload", "missing.whl"]) + message = "InvalidDistribution: Cannot find file (or expand pattern): 'missing.whl'" + assert dunder_main.main() == colorama.Fore.RED + message + colorama.Style.RESET_ALL def test_no_color_exception(monkeypatch): - replaced_dispatch = pretend.raiser(exceptions.InvalidConfiguration("foo")) - monkeypatch.setattr(cli, "dispatch", replaced_dispatch) - monkeypatch.setattr(sys, "argv", ["upload", "--no-color"]) - assert dunder_main.main() == "InvalidConfiguration: foo" + monkeypatch.setattr(sys, "argv", ["twine", "--no-color", "upload", "missing.whl"]) + message = "InvalidDistribution: Cannot find file (or expand pattern): 'missing.whl'" + assert dunder_main.main() == message diff --git a/twine/__main__.py b/twine/__main__.py index 1a05ce30..3a19f9d1 100644 --- a/twine/__main__.py +++ b/twine/__main__.py @@ -12,7 +12,6 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -import argparse import sys from typing import Any @@ -21,24 +20,18 @@ from twine import cli from twine import exceptions -from twine import settings def main() -> Any: try: return cli.dispatch(sys.argv[1:]) except (exceptions.TwineException, requests.HTTPError) as exc: - parser = argparse.ArgumentParser() - settings.Settings.register_argparse_arguments(parser) - args, _ = parser.parse_known_args(sys.argv[1:]) - color = not settings.Settings.from_argparse(args).no_color + return _format_error(f"{exc.__class__.__name__}: {exc.args[0]}") - return _format_error(f"{exc.__class__.__name__}: {exc.args[0]}", color=color) - -def _format_error(message: str, color: bool = True) -> str: +def _format_error(message: str) -> str: pre_style, post_style = "", "" - if color: + if not cli.args.no_color: colorama.init() pre_style, post_style = colorama.Fore.RED, colorama.Style.RESET_ALL diff --git a/twine/cli.py b/twine/cli.py index 936d859f..7ff20855 100644 --- a/twine/cli.py +++ b/twine/cli.py @@ -27,6 +27,8 @@ import twine from twine import _installed +args = argparse.Namespace() + def _registered_commands( group: str = "twine.registered_commands", @@ -59,6 +61,13 @@ def dispatch(argv: List[str]) -> Any: action="version", version="%(prog)s version {} ({})".format(twine.__version__, dep_versions()), ) + parser.add_argument( + "--no-color", + default=False, + required=False, + action="store_true", + help="disable colored output", + ) parser.add_argument( "command", choices=registered_commands.keys(), ) @@ -66,7 +75,7 @@ def dispatch(argv: List[str]) -> Any: "args", help=argparse.SUPPRESS, nargs=argparse.REMAINDER, ) - args = parser.parse_args(argv) + parser.parse_args(argv, namespace=args) main = registered_commands[args.command].load() diff --git a/twine/commands/check.py b/twine/commands/check.py index b32a3154..d8a1317d 100644 --- a/twine/commands/check.py +++ b/twine/commands/check.py @@ -27,7 +27,6 @@ from twine import commands from twine import package as package_file -from twine import settings _RENDERERS = { None: readme_renderer.rst, # Default if description_content_type is None @@ -106,11 +105,7 @@ def _check_file( return warnings, is_ok -def check( - dists: List[str], - output_stream: IO[str] = sys.stdout, - check_settings: Optional[settings.Settings] = None, -) -> bool: +def check(dists: List[str], output_stream: IO[str] = sys.stdout) -> bool: uploads = [i for i in commands._find_dists(dists) if not i.endswith(".asc")] if not uploads: # Return early, if there are no files to check. output_stream.write("No files to check.\n") @@ -148,7 +143,6 @@ def check( def main(args: List[str]) -> bool: parser = argparse.ArgumentParser(prog="twine check") - settings.Settings.register_argparse_arguments(parser) parser.add_argument( "dists", nargs="+", @@ -157,7 +151,6 @@ def main(args: List[str]) -> bool: ) parsed_args = parser.parse_args(args) - check_settings = settings.Settings.from_argparse(parsed_args) # Call the check function with the arguments from the command line - return check(parsed_args.dists, check_settings=check_settings) + return check(parsed_args.dists) diff --git a/twine/settings.py b/twine/settings.py index ae7e5f74..34c23435 100644 --- a/twine/settings.py +++ b/twine/settings.py @@ -59,7 +59,6 @@ def __init__( repository_url: Optional[str] = None, verbose: bool = False, disable_progress_bar: bool = False, - no_color: bool = False, **ignored_kwargs: Any, ) -> None: """Initialize our settings instance. @@ -123,7 +122,6 @@ def __init__( self.comment = comment self.verbose = verbose self.disable_progress_bar = disable_progress_bar - self.no_color = no_color self.skip_existing = skip_existing self._handle_repository_options( repository_name=repository_name, repository_url=repository_url, @@ -265,13 +263,6 @@ def register_argparse_arguments(parser: argparse.ArgumentParser) -> None: action="store_true", help="Disable the progress bar.", ) - parser.add_argument( - "--no-color", - default=False, - required=False, - action="store_true", - help="Disable colored output.", - ) @classmethod def from_argparse(cls, args: argparse.Namespace) -> "Settings":