Require Config to have a default (#143150)

With aliases coming soon, we want to reject alias + default combo, so we need defaults to be passed in. On top of this, this simplifies statically type checking config.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/143150
Approved by: https://github.com/ezyang
This commit is contained in:
Oguz Ulgen
2024-12-12 14:53:59 -08:00
committed by PyTorch MergeBot
parent bf711a9cce
commit 9d05c8110d
2 changed files with 3 additions and 3 deletions

View File

@ -20,7 +20,7 @@ magic_cache_config_ignored = True
# [@compile_ignored: debug]
e_compile_ignored = True
e_config = Config(default=True)
e_jk = Config(justknob="does_not_exist")
e_jk = Config(justknob="does_not_exist", default=True)
e_jk_false = Config(justknob="does_not_exist", default=False)
e_env_default = Config(env_name_default="ENV_TRUE", default=False)
e_env_default_FALSE = Config(env_name_default="ENV_FALSE", default=True)

View File

@ -51,7 +51,7 @@ class Config:
default behaviour. I.e. user overrides take preference.
"""
default: Any = True
default: Any
justknob: Optional[str] = None
env_name_default: Optional[str] = None
env_name_force: Optional[str] = None
@ -59,7 +59,7 @@ class Config:
def __init__(
self,
default: Any = True,
default: Any,
justknob: Optional[str] = None,
env_name_default: Optional[str] = None,
env_name_force: Optional[str] = None,