From 3fa5ea037af7dff80c5d56c5aa180f804c037033 Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Tue, 16 May 2023 12:50:36 +0200 Subject: [PATCH 1/2] gh-104050: Add basic typing to CConverter in clinic.py --- Tools/clinic/clinic.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py index 13fd66b0406f26..add870a9eb7a7b 100755 --- a/Tools/clinic/clinic.py +++ b/Tools/clinic/clinic.py @@ -2669,15 +2669,15 @@ class CConverter(metaclass=CConverterAutoRegister): # keep in sync with self_converter.__init__! def __init__(self, # Positional args: - name, - py_name, + name: str, + py_name: str, function, default=unspecified, *, # Keyword only args: - c_default=None, - py_default=None, - annotation=unspecified, - unused=False, + c_default: str | None = None, + py_default: str | None = None, + annotation: str | Unspecified = unspecified, + unused: bool = False, **kwargs ): self.name = ensure_legal_c_identifier(name) @@ -2713,10 +2713,10 @@ def __init__(self, def converter_init(self): pass - def is_optional(self): + def is_optional(self) -> bool: return (self.default is not unspecified) - def _render_self(self, parameter, data): + def _render_self(self, parameter: str, data: CRenderData) -> None: self.parameter = parameter name = self.parser_name @@ -2776,7 +2776,7 @@ def _render_non_self(self, parameter, data): if cleanup: data.cleanup.append('/* Cleanup for ' + name + ' */\n' + cleanup.rstrip() + "\n") - def render(self, parameter, data): + def render(self, parameter: str, data: CRenderData): """ parameter is a clinic.Parameter instance. data is a CRenderData instance. @@ -2852,7 +2852,7 @@ def declaration(self, *, in_parser=False): declaration.append(';') return "".join(declaration) - def initialize(self): + def initialize(self) -> str: """ The C statements required to set up this variable before parsing. Returns a string containing this code indented at column 0. @@ -2860,7 +2860,7 @@ def initialize(self): """ return "" - def modify(self): + def modify(self) -> str: """ The C statements required to modify this variable after parsing. Returns a string containing this code indented at column 0. @@ -2868,7 +2868,7 @@ def modify(self): """ return "" - def post_parsing(self): + def post_parsing(self) -> str: """ The C statements required to do some operations after the end of parsing but before cleaning up. Return a string containing this code indented at column 0. @@ -2876,7 +2876,7 @@ def post_parsing(self): """ return "" - def cleanup(self): + def cleanup(self) -> str: """ The C statements required to clean up after this variable. Returns a string containing this code indented at column 0. @@ -2929,7 +2929,7 @@ def parse_arg(self, argname, displayname): """.format(argname=argname, paramname=self.parser_name, cast=cast) return None - def set_template_dict(self, template_dict): + def set_template_dict(self, template_dict: dict[str, str]): pass @property From 6c02f60034b98c3e24080182173a976c12fdaae0 Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Tue, 16 May 2023 13:14:08 +0200 Subject: [PATCH 2/2] Update Tools/clinic/clinic.py Co-authored-by: Alex Waygood --- Tools/clinic/clinic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py index add870a9eb7a7b..6020935f8304c5 100755 --- a/Tools/clinic/clinic.py +++ b/Tools/clinic/clinic.py @@ -2776,7 +2776,7 @@ def _render_non_self(self, parameter, data): if cleanup: data.cleanup.append('/* Cleanup for ' + name + ' */\n' + cleanup.rstrip() + "\n") - def render(self, parameter: str, data: CRenderData): + def render(self, parameter: str, data: CRenderData) -> None: """ parameter is a clinic.Parameter instance. data is a CRenderData instance. pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy