Skip to content

Commit

Permalink
restore application.py to main
Browse files Browse the repository at this point in the history
  • Loading branch information
maartenbreddels committed Dec 21, 2022
1 parent e4060b8 commit e45e1e1
Showing 1 changed file with 17 additions and 19 deletions.
36 changes: 17 additions & 19 deletions traitlets/config/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from copy import deepcopy
from logging.config import dictConfig
from textwrap import dedent
from typing import Callable, TypeVar, cast
from typing import Any, Callable, TypeVar, cast

from traitlets.config.configurable import Configurable, SingletonConfigurable
from traitlets.config.loader import (
Expand All @@ -29,7 +29,6 @@
PyFileConfigLoader,
)
from traitlets.traitlets import (
Any,
Bool,
Dict,
Enum,
Expand Down Expand Up @@ -150,23 +149,21 @@ class Application(SingletonConfigurable):

# The name of the application, will usually match the name of the command
# line application
name = Unicode("application")

log = Any(help="Logger or LoggerAdapter instance", allow_none=False)
name: t.Union[str, Unicode] = Unicode("application")

# The description of the application that is printed at the beginning
# of the help.
description = Unicode("This is an application.")
description: t.Union[str, Unicode] = 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: t.Union[str, Unicode] = Unicode(option_description)
keyvalue_description: t.Union[str, Unicode] = Unicode(keyvalue_description)
subcommand_description: t.Union[str, Unicode] = 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: t.Union[str, Unicode] = Unicode()

# A sequence of Configurable subclasses whose config=True attributes will
# be exposed at the command line.
Expand All @@ -193,28 +190,30 @@ def _classes_inc_parents(self, classes=None):
yield parent

# The version string of this application.
version = Unicode("0.0")
version: t.Union[str, Unicode] = Unicode("0.0")

# the argv used to initialize the application
argv: t.Union[t.List[str], List] = List()

# Whether failing to load config files should prevent startup
raise_config_file_errors = Bool(TRAITLETS_APPLICATION_RAISE_CONFIG_FILE_ERROR)
raise_config_file_errors: t.Union[bool, Bool] = Bool(
TRAITLETS_APPLICATION_RAISE_CONFIG_FILE_ERROR
)

# The log level for the application
log_level = Enum(
log_level: t.Union[str, int, Enum] = Enum(
(0, 10, 20, 30, 40, 50, "DEBUG", "INFO", "WARN", "ERROR", "CRITICAL"),
default_value=logging.WARN,
help="Set the log level by value or name.",
).tag(config=True)

_log_formatter_cls = LevelFormatter

log_datefmt = Unicode(
log_datefmt: t.Union[str, Unicode] = Unicode(
"%Y-%m-%d %H:%M:%S", help="The date format used by logging formatters for %(asctime)s"
).tag(config=True)

log_format = Unicode(
log_format: t.Union[str, Unicode] = Unicode(
"[%(name)s]%(highlevel)s %(message)s",
help="The Logging format template",
).tag(config=True)
Expand Down Expand Up @@ -403,7 +402,7 @@ def _log_default(self):
# and the second being the help string for the subcommand
subcommands: t.Union[t.Dict[str, t.Tuple[t.Any, str]], Dict] = Dict()
# parse_command_line will initialize a subapp, if requested
subapp: Instance[t.Any] = Instance("traitlets.config.application.Application", allow_none=True)
subapp = Instance("traitlets.config.application.Application", allow_none=True)

# extra command-line arguments that don't set config values
extra_args: t.Union[t.List[str], List] = List(Unicode())
Expand All @@ -421,11 +420,11 @@ def _log_default(self):

_loaded_config_files = List()

show_config = Bool(
show_config: t.Union[bool, Bool] = Bool(
help="Instead of starting the Application, dump configuration to stdout"
).tag(config=True)

show_config_json = Bool(
show_config_json: t.Union[bool, Bool] = Bool(
help="Instead of starting the Application, dump configuration to stdout (as JSON)"
).tag(config=True)

Expand Down Expand Up @@ -564,7 +563,6 @@ def emit_flag_help(self):
return

for flags, (cfg, fhelp) in self.flags.items():
assert isinstance(cfg, dict)
try:
if not isinstance(flags, tuple):
flags = (flags,)
Expand Down

0 comments on commit e45e1e1

Please sign in to comment.