Skip to content

Commit

Permalink
Merge branch 'main' into pythongh-75367
Browse files Browse the repository at this point in the history
  • Loading branch information
furkanonder authored May 16, 2023
2 parents ccb7fe7 + 0bb61dd commit de48adc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Doc/library/logging.config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ in :mod:`logging` itself) and defining handlers which are declared either in
they or their ancestors are explicitly named
in the logging configuration.

:param encoding: The encoding used to open file when *fname* is filename.
:param encoding: The encoding used to open file when *fname* is filename.

.. versionchanged:: 3.4
An instance of a subclass of :class:`~configparser.RawConfigParser` is
Expand Down
33 changes: 16 additions & 17 deletions Tools/clinic/clinic.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@
import sys
import textwrap
import traceback
import types

from collections.abc import Callable
from types import *
from types import FunctionType, NoneType
from typing import Any, NamedTuple

# TODO:
Expand Down Expand Up @@ -2669,15 +2668,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)
Expand Down Expand Up @@ -2713,10 +2712,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

Expand Down Expand Up @@ -2776,7 +2775,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) -> None:
"""
parameter is a clinic.Parameter instance.
data is a CRenderData instance.
Expand Down Expand Up @@ -2852,31 +2851,31 @@ 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.
If no initialization is necessary, returns an empty string.
"""
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.
If no modification is necessary, returns an empty string.
"""
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.
If no operation is necessary, return an empty string.
"""
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.
Expand Down Expand Up @@ -2929,7 +2928,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
Expand Down Expand Up @@ -4037,7 +4036,7 @@ def eval_ast_expr(node, globals, *, filename='-'):

node = ast.Expression(node)
co = compile(node, filename, 'eval')
fn = types.FunctionType(co, globals)
fn = FunctionType(co, globals)
return fn()


Expand Down

0 comments on commit de48adc

Please sign in to comment.