diff options
author | Alex Waygood <Alex.Waygood@Gmail.com> | 2023-07-26 10:54:03 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-26 10:54:03 (GMT) |
commit | 14d074e1fb403e54edb345505cfd2c73601e21f3 (patch) | |
tree | 86dd30686940803624b6dd3af5c71376f64da2d5 /Tools | |
parent | c362678dd289c45ff36ea9c61246a406990befd2 (diff) | |
download | cpython-14d074e1fb403e54edb345505cfd2c73601e21f3.zip cpython-14d074e1fb403e54edb345505cfd2c73601e21f3.tar.gz cpython-14d074e1fb403e54edb345505cfd2c73601e21f3.tar.bz2 |
gh-104683: Argument Clinic: Make most arguments to `Class` and `Function` required (#107289)
Diffstat (limited to 'Tools')
-rwxr-xr-x | Tools/clinic/clinic.py | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py index 54fd1ae..f557984 100755 --- a/Tools/clinic/clinic.py +++ b/Tools/clinic/clinic.py @@ -1325,7 +1325,6 @@ class CLanguage(Language): cpp_endif = "#endif /* " + conditional + " */" assert clinic is not None - assert f.full_name is not None if methoddef_define and f.full_name not in clinic.ifndef_symbols: clinic.ifndef_symbols.add(f.full_name) methoddef_ifndef = normalize_snippet(""" @@ -1541,11 +1540,8 @@ class CLanguage(Language): '{impl_parameters}' in templates['parser_prototype']): data.declarations.pop(0) - template_dict = {} - - assert isinstance(f.full_name, str) full_name = f.full_name - template_dict['full_name'] = full_name + template_dict = {'full_name': full_name} if new_or_init: assert isinstance(f.cls, Class) @@ -2398,10 +2394,10 @@ class Module: @dc.dataclass(repr=False) class Class: name: str - module: Module | None = None - cls: Class | None = None - typedef: str | None = None - type_object: str | None = None + module: Module + cls: Class | None + typedef: str + type_object: str def __post_init__(self) -> None: self.parent = self.cls or self.module @@ -2527,14 +2523,14 @@ class Function: _: dc.KW_ONLY name: str module: Module - cls: Class | None = None - c_basename: str | None = None - full_name: str | None = None + cls: Class | None + c_basename: str | None + full_name: str return_converter: CReturnConverter + kind: FunctionKind + coexist: bool return_annotation: object = inspect.Signature.empty docstring: str = '' - kind: FunctionKind = CALLABLE - coexist: bool = False # docstring_only means "don't generate a machine-readable # signature, just a normal docstring". it's True for # functions with optional groups because we can't represent @@ -5325,7 +5321,6 @@ class DSLParser: def format_docstring(self) -> str: f = self.function assert f is not None - assert f.full_name is not None new_or_init = f.kind.new_or_init if new_or_init and not f.docstring: |