Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 25bac1d

Browse files
authored
csv, ctypes, configparser explanations (#5204)
1 parent 4dd10fe commit 25bac1d

5 files changed

Lines changed: 34 additions & 24 deletions

File tree

stdlib/configparser.pyi

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ class Interpolation:
4545

4646
class BasicInterpolation(Interpolation): ...
4747
class ExtendedInterpolation(Interpolation): ...
48-
class LegacyInterpolation(Interpolation): ...
48+
49+
class LegacyInterpolation(Interpolation):
50+
def before_get(self, parser: _parser, section: str, option: str, value: str, vars: _section) -> str: ...
4951

5052
class RawConfigParser(_parser):
5153
_SECT_TMPL: ClassVar[str] = ... # Undocumented
@@ -188,7 +190,7 @@ class SectionProxy(MutableMapping[str, str]):
188190
def getboolean(
189191
self, option: str, fallback: _T = ..., *, raw: bool = ..., vars: Optional[_section] = ...
190192
) -> Union[bool, _T]: ...
191-
# SectionProxy can have arbitrary attributes when custon converters are used
193+
# SectionProxy can have arbitrary attributes when custom converters are used
192194
def __getattr__(self, key: str) -> Callable[..., Any]: ...
193195

194196
class ConverterMapping(MutableMapping[str, Optional[_converter]]):

stdlib/ctypes/__init__.pyi

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,25 @@ class CDLL(object):
3636
_name: str = ...
3737
_handle: int = ...
3838
_FuncPtr: Type[_FuncPointer] = ...
39-
def __init__(
40-
self,
41-
name: Optional[str],
42-
mode: int = ...,
43-
handle: Optional[int] = ...,
44-
use_errno: bool = ...,
45-
use_last_error: bool = ...,
46-
winmode: Optional[int] = ...,
47-
) -> None: ...
39+
if sys.version_info >= (3, 8):
40+
def __init__(
41+
self,
42+
name: Optional[str],
43+
mode: int = ...,
44+
handle: Optional[int] = ...,
45+
use_errno: bool = ...,
46+
use_last_error: bool = ...,
47+
winmode: Optional[int] = ...,
48+
) -> None: ...
49+
else:
50+
def __init__(
51+
self,
52+
name: Optional[str],
53+
mode: int = ...,
54+
handle: Optional[int] = ...,
55+
use_errno: bool = ...,
56+
use_last_error: bool = ...,
57+
) -> None: ...
4858
def __getattr__(self, name: str) -> _NamedFuncPointer: ...
4959
def __getitem__(self, name: str) -> _NamedFuncPointer: ...
5060

@@ -151,7 +161,7 @@ def byref(obj: _CData, offset: int = ...) -> _CArgObject: ...
151161

152162
_CastT = TypeVar("_CastT", bound=_CanCastTo)
153163

154-
def cast(obj: _UnionT[_CData, _CArgObject, int], type: Type[_CastT]) -> _CastT: ...
164+
def cast(obj: _UnionT[_CData, _CArgObject, int], typ: Type[_CastT]) -> _CastT: ...
155165
def create_string_buffer(init: _UnionT[int, bytes], size: Optional[int] = ...) -> Array[c_char]: ...
156166

157167
c_buffer = create_string_buffer

tests/stubtest_whitelists/py36.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ collections.AsyncGenerator.ag_running
2020
collections.UserString.maketrans
2121
contextlib._GeneratorContextManager.__init__
2222
copy.PyStringMap
23-
ctypes.CDLL.__init__
2423
email.message.MIMEPart.as_string
2524
enum.Enum._generate_next_value_
2625
fractions.Fraction.__new__ # overload is too complicated for stubtest to resolve

tests/stubtest_whitelists/py37.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ contextvars.Context.get
2929
contextvars.ContextVar.get
3030
contextlib.nullcontext # not a function at runtime
3131
copy.PyStringMap
32-
ctypes.CDLL.__init__
3332
dataclasses.field
3433
email.message.MIMEPart.as_string
3534
enum.Enum._generate_next_value_

tests/stubtest_whitelists/py3_common.txt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -120,24 +120,24 @@ collections.abc.Generator.gi_yieldfrom
120120
collections.abc.Mapping.get
121121
collections.abc.Sequence.index
122122
collections.deque.__hash__
123-
configparser.LegacyInterpolation.before_get
124-
configparser.SectionProxy.__getattr__
123+
configparser.SectionProxy.__getattr__ # SectionProxy can have arbitrary attributes when custom converters are used
124+
# SectionProxy get functions are set in __init__
125125
configparser.SectionProxy.getboolean
126126
configparser.SectionProxy.getfloat
127127
configparser.SectionProxy.getint
128+
# The Dialect properties are initialized as None in Dialect but their values are enforced in _Dialect
128129
csv.Dialect.delimiter
129130
csv.Dialect.doublequote
130131
csv.Dialect.lineterminator
131132
csv.Dialect.quoting
132133
csv.Dialect.skipinitialspace
133-
ctypes.Array.__iter__
134-
ctypes.CDLL._FuncPtr
135-
ctypes.cast
136-
ctypes.memmove
137-
ctypes.memset
138-
ctypes.pointer
139-
ctypes.string_at
140-
ctypes.wstring_at
134+
ctypes.Array.__iter__ # mypy doesn't support using __getitem__ instead of __iter__ so this is here https://github.com/python/mypy/issues/2220
135+
ctypes.CDLL._FuncPtr # None at class level but initialized in __init__ to this value
136+
ctypes.memmove # CFunctionType
137+
ctypes.memset # CFunctionType
138+
ctypes.pointer # imported C function
139+
ctypes.string_at # docstring argument name is wrong
140+
ctypes.wstring_at # docstring argument name is wrong
141141
dbm.error
142142
difflib.SequenceMatcher.__init__ # mypy default value for generic parameter issues. See https://github.com/python/mypy/issues/3737
143143
distutils.command.bdist_packager # It exists in docs as package name but not in code except as a mention in a comment.

0 commit comments

Comments
 (0)