Skip to content
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

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

Merged
merged 2 commits into from
Jul 26, 2023
Merged
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
25 changes: 10 additions & 15 deletions Tools/clinic/clinic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1324,7 +1324,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("""
Expand Down Expand Up @@ -1540,11 +1539,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)
Expand Down Expand Up @@ -2397,10 +2393,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
Expand Down Expand Up @@ -2526,14 +2522,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
Expand Down Expand Up @@ -5316,7 +5312,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:
Expand Down
Loading