# =========================
# New errors in Python 3.12
# =========================


# =======
# >= 3.12
# =======

zoneinfo.ZoneInfo.from_file  # Pos-only parameters had different "names" in different Python versions


# ====================================
# Pre-existing errors from Python 3.11
# ====================================


# =======
# >= 3.11
# =======

enum.Enum.__init__
typing.NewType.__mro_entries__


# =======
# >= 3.10
# =======

builtins.ellipsis  # type is not exposed anywhere
importlib._abc.Loader.exec_module  # See Lib/importlib/_abc.py. Might be defined for backwards compatibility

# positional-only complaints caused by differences between typing aliases and the "real" classes in the stdlib
_collections_abc.Coroutine.send
_collections_abc.Coroutine.throw
_collections_abc.Generator.send
_collections_abc.Generator.throw

# These are not positional-only at runtime, but we treat them as positional-only to match dict.
_collections_abc.MutableMapping.pop
_collections_abc.MutableMapping.setdefault

# These three have a pos-or-keyword first parameter at runtime, but deliberately have a pos-only first parameter in the stub. #6812
posixpath.join
ntpath.join
os.path.join

types.DynamicClassAttribute..*  # In the stub we pretend it's an alias for property, but it has positional-only differences

# typing.IO uses positional-or-keyword arguments, but in the stubs we prefer
# to mark these as positional-only for compatibility with existing sub-classes.
typing(_extensions)?\.BinaryIO\.write
typing(_extensions)?\.IO\.read
typing(_extensions)?\.IO\.readline
typing(_extensions)?\.IO\.readlines
typing(_extensions)?\.IO\.seek
typing(_extensions)?\.IO\.truncate
typing(_extensions)?\.IO\.write
typing(_extensions)?\.IO\.writelines


# ======
# >= 3.9
# ======

# Exists at runtime, but missing from stubs
_collections_abc.AsyncIterable.__class_getitem__
_collections_abc.Awaitable.__class_getitem__
_collections_abc.Container.__class_getitem__
_collections_abc.Iterable.__class_getitem__
_collections_abc.MappingView.__class_getitem__


# =======
# <= 3.12
# =======

# Exists at runtime, but missing from stubs
lib2to3.btm_utils
lib2to3.fixer_util
lib2to3.patcomp
lib2to3.pgen2.grammar.Grammar.loads
lib2to3.pygram.pattern_symbols
lib2to3.pygram.python_symbols
lib2to3.pytree.Base.__new__
lib2to3.pytree.Base.children
lib2to3.pytree.Base.type
lib2to3.pytree.BasePattern.__new__
lib2to3.pytree.BasePattern.type
lib2to3.pytree.NegatedPattern.match
lib2to3.pytree.NegatedPattern.match_seq
tkinter.tix.[A-Z_]+
tkinter.tix.CObjView
tkinter.tix.DialogShell
tkinter.tix.ExFileSelectDialog
tkinter.tix.FileSelectDialog
tkinter.tix.FileTypeList
tkinter.tix.Grid
tkinter.tix.NoteBookFrame
tkinter.tix.OptionName
tkinter.tix.ResizeHandle
tkinter.tix.ScrolledGrid
tkinter.tix.ScrolledHList
tkinter.tix.ScrolledListBox
tkinter.tix.ScrolledTList
tkinter.tix.ScrolledText
tkinter.tix.ScrolledWindow
tkinter.tix.Shell
tkinter.tix.TclVersion
tkinter.tix.TkVersion


# =============================================================
# Allowlist entries that cannot or should not be fixed; >= 3.12
# =============================================================

# Runtime AST node runtime constructor behaviour is too loose.
# For static typing, the loose behaviour is undesirable (https://github.com/python/typeshed/issues/8378).
# For the runtime, the loose behaviour is deprecated in Python 3.13 (https://github.com/python/cpython/issues/105858)
_?ast.type_param.__init__

# Deprecation wrapper classes; their methods are just pass-through, so we can ignore them.
importlib.metadata.DeprecatedNonAbstract.__new__

# Deprecated argument is supported at runtime by renaming it through a decorator.
importlib.resources._common.files
importlib.resources.files

sys._monitoring  # Doesn't really exist. See comments in the stub.
sys.last_exc  # not always defined

# These only exist to give a better error message if you try to subclass an instance
typing.ParamSpec.__mro_entries__
typing.ParamSpecArgs.__mro_entries__
typing.ParamSpecKwargs.__mro_entries__
typing.TypeVar.__mro_entries__
typing.TypeVarTuple.__mro_entries__

# TODO: mypy should infer that this attribute is inherited from builtins.type;
# why doesn't it infer this?
typing.SupportsAbs.__type_params__
typing.SupportsRound.__type_params__
typing_extensions.SupportsAbs.__type_params__
typing_extensions.SupportsRound.__type_params__


# =============================================================
# Allowlist entries that cannot or should not be fixed; >= 3.11
# =============================================================

argparse._MutuallyExclusiveGroup.add_mutually_exclusive_group  # deprecated, forwards arguments to super
enum.auto.__init__  # The stub for enum.auto is nothing like the implementation
enum.auto.value  # The stub for enum.auto is nothing like the implementation
http.HTTPMethod.description  # mutable instance attribute at runtime but we pretend it's a property
importlib.resources.abc.Traversable.open  # Problematic protocol signature at runtime, see source code comments.
inspect._ParameterKind.description  # Still exists, but stubtest can't see it
typing\._SpecialForm.*  # Super-special typing primitive
typing\.LiteralString  # Super-special typing primitive


# =============================================================
# Allowlist entries that cannot or should not be fixed; >= 3.10
# =============================================================

# Runtime AST node runtime constructor behaviour is too loose.
# For static typing, the loose behaviour is undesirable (https://github.com/python/typeshed/issues/8378).
# For the runtime, the loose behaviour is deprecated in Python 3.13 (https://github.com/python/cpython/issues/105858)
_?ast.pattern.__init__

_collections_abc.AsyncGenerator.athrow  # async at runtime, deliberately not in the stub, see #7491. Pos-only differences also.
builtins.property.__set_name__  # Doesn't actually exist
collections\.UserList\.index  # ignoring pos-or-keyword parameter
dataclasses.KW_ONLY  # white lies around defaults
importlib.metadata._meta.SimplePath.joinpath  # Runtime definition of protocol is incorrect
unittest.TestCase.__init_subclass__  # Runtime has *args, **kwargs, but will error if any are supplied
unittest.case.TestCase.__init_subclass__  # Runtime has *args, **kwargs, but will error if any are supplied


# ============================================================
# Allowlist entries that cannot or should not be fixed; >= 3.9
# ============================================================

_ast.ImportFrom.level  # None on the class, but never None on instances
_weakref.ProxyType.__reversed__  # Doesn't really exist
ast.ImportFrom.level  # None on the class, but never None on instances
ast.ExtSlice.__new__  # C signature is broader than what is actually accepted
ast.Index.__new__  # C signature is broader than what is actually accepted

# Treated an alias of a typing class in the stubs,
# they are generic to type checkers anyway.
contextlib.AbstractAsyncContextManager.__class_getitem__
contextlib.AbstractContextManager.__class_getitem__

functools._lru_cache_wrapper.cache_parameters  # Cannot be detected statically
importlib.abc.Traversable.open  # Problematic protocol signature at runtime, see source code comments.
os.PathLike.__class_getitem__  # PathLike is a protocol; we don't expect all PathLike classes to implement class_getitem
types.GenericAlias.__call__  # Would be complicated to fix properly, Any could silence problems. #6392
types.GenericAlias.__getattr__
types.GenericAlias.__mro_entries__
typing\.NamedTuple  # Super-special typing primitive
weakref.ProxyType.__reversed__  # Doesn't really exist


# ===============================================================
# Allowlist entries that cannot or should not be fixed; 3.12 only
# ===============================================================

concurrent.futures.__all__  # Incompatible changes introduced in Python 3.12.5
ctypes._endian.SIZEOF_TIME_T  # Incorrectly star import.


# ==================================================================
# Allowlist entries that cannot or should not be fixed; 3.11 to 3.12
# ==================================================================

configparser.LegacyInterpolation.__init__  # runtime is *args, **kwargs, but it's just a passthrough


# =================================================================
# Allowlist entries that cannot or should not be fixed; 3.9 to 3.12
# =================================================================

typing\.Annotated  # Super-special typing primitive


# =============================================================
# Allowlist entries that cannot or should not be fixed; <= 3.12
# =============================================================

# Undocumented implementation details
cgi.FieldStorage.bufsize
cgi.FieldStorage.read_binary
cgi.FieldStorage.read_lines
cgi.FieldStorage.read_lines_to_eof
cgi.FieldStorage.read_lines_to_outerboundary
cgi.FieldStorage.read_multi
cgi.FieldStorage.read_single
cgi.FieldStorage.read_urlencoded
cgi.FieldStorage.skip_lines

ctypes._endian.DEFAULT_MODE  # Incorrectly star import.
ctypes._endian.RTLD_GLOBAL  # Incorrectly star import.
ctypes._endian.RTLD_LOCAL  # Incorrectly star import.
multiprocessing.dummy.Lock  # Factory function at runtime, but that wouldn't let us use it in type hints

# These multiprocessing proxy methods have *args, **kwargs signatures at runtime,
# But have more precise (accurate) signatures in the stub
multiprocessing.managers.DictProxy.__iter__
multiprocessing.managers.DictProxy.__len__
multiprocessing.managers.DictProxy.copy
multiprocessing.managers.DictProxy.items
multiprocessing.managers.DictProxy.keys
multiprocessing.managers.DictProxy.values

# Runtime signature is incorrect (https://github.com/python/cpython/issues/93021)
multiprocessing.managers.DictProxy.clear
multiprocessing.managers.DictProxy.popitem

# Undocumented implementation details
pipes.Template.makepipeline
pipes.Template.open_r
pipes.Template.open_w
sunau.Au_read.initfp
sunau.Au_write.initfp

threading.Lock  # Factory function at runtime, but that wouldn't let us use it in type hints
types.SimpleNamespace.__init__  # class doesn't accept positional arguments but has default C signature
typing_extensions\.Annotated  # Undocumented implementation details
