gh-104683: Argument Clinic: Make most arguments to Class and Function required (#107289)

This commit is contained in:
Alex Waygood 2023-07-26 11:54:03 +01:00 committed by GitHub
parent c362678dd2
commit 14d074e1fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1325,7 +1325,6 @@ def parser_body(
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 @@ def render_function(
'{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 @@ def __repr__(self) -> str:
@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 @@ def state_function_docstring(self, line: str | None) -> None:
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: