Skip to content

Typing fixups #875

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

Merged
merged 3 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 9 additions & 9 deletions traitlets/config/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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]:
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions traitlets/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down