From 292a699ad1a3a3ece760a8335cae73927cccd711 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 3 Oct 2023 06:05:36 -0500 Subject: [PATCH] Typing fixups (#875) --- traitlets/config/application.py | 18 +++++++++--------- traitlets/tests/utils.py | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/traitlets/config/application.py b/traitlets/config/application.py index 8c15abd8..b0cf36f7 100644 --- a/traitlets/config/application.py +++ b/traitlets/config/application.py @@ -153,21 +153,21 @@ class Application(SingletonConfigurable): # The name of the application, will usually match the name of the command # line application - name = Unicode("application") + name: str | Unicode[str, str | bytes] = Unicode("application") # The description of the application that is printed at the beginning # of the help. - description = Unicode("This is an application.") + description: str | Unicode[str, str | bytes] = Unicode("This is an application.") # default section descriptions - option_description = Unicode(option_description) - keyvalue_description = Unicode(keyvalue_description) - subcommand_description = Unicode(subcommand_description) + option_description: str | Unicode[str, str | bytes] = Unicode(option_description) + keyvalue_description: str | Unicode[str, str | bytes] = Unicode(keyvalue_description) + subcommand_description: str | Unicode[str, str | bytes] = Unicode(subcommand_description) python_config_loader_class = PyFileConfigLoader json_config_loader_class = JSONFileConfigLoader # The usage and example string that goes at the end of the help string. - examples = Unicode() + examples: str | Unicode[str, str | bytes] = Unicode() # A sequence of Configurable subclasses whose config=True attributes will # be exposed at the command line. @@ -196,7 +196,7 @@ def _classes_inc_parents( yield parent # The version string of this application. - version = Unicode("0.0") + version: str | Unicode[str, str | bytes] = Unicode("0.0") # the argv used to initialize the application argv = List() @@ -891,7 +891,7 @@ def parse_command_line(self, argv: ArgvType = None) -> None: def _load_config_files( cls, basefilename: str, - path: list[str | None] | str | None = None, + path: list[str | None] | None = None, log: AnyLogger | None = None, raise_config_file_errors: bool = False, ) -> t.Generator[t.Any, None, None]: @@ -949,7 +949,7 @@ def loaded_config_files(self) -> list[str]: return self._loaded_config_files[:] @catch_config_error - def load_config_file(self, filename: str, path: str | None = None) -> None: + def load_config_file(self, filename: str, path: list[str | None] | None = None) -> None: """Load config files by filename and path.""" filename, ext = os.path.splitext(filename) new_config = Config() diff --git a/traitlets/tests/utils.py b/traitlets/tests/utils.py index 7e10b5b8..b4d0fe95 100644 --- a/traitlets/tests/utils.py +++ b/traitlets/tests/utils.py @@ -14,7 +14,7 @@ def get_output_error_code(cmd: str | list[str]) -> tuple[str, str, Any]: return out_str, err_str, p.returncode -def check_help_output(pkg: str, subcommand: str | None = None) -> tuple[str, str]: +def check_help_output(pkg: str, subcommand: list[str] | None = None) -> tuple[str, str]: """test that `python -m PKG [subcommand] -h` works""" cmd = [sys.executable, "-m", pkg] if subcommand: @@ -28,7 +28,7 @@ def check_help_output(pkg: str, subcommand: str | None = None) -> tuple[str, str return out, err -def check_help_all_output(pkg: str, subcommand: str | None = None) -> tuple[str, str]: +def check_help_all_output(pkg: str, subcommand: list[str] | None = None) -> tuple[str, str]: """test that `python -m PKG --help-all` works""" cmd = [sys.executable, "-m", pkg] if subcommand: