PEP 484 indicates that all type annotations within a stub file are supposed to be considered forward references even if they are not quoted. This means a type checker needs to use scope-based symbol resolution without regard for code flow order. Lookups will find same-named symbols within the same scope even if they are declared after the type annotation. This change fixes a couple of cases where this occurs and confuses pyright.
Co-authored-by: Eric Traut <erictr@microsoft.com>
* sys: simplify _getframe
* sys: mark positional-only args
* sys: fix platform availability
* sys: remove settscdump
This function is no longer documented in 3.6 and above (and doesn't
exist on master, was removed in 4fd64b9a6aba9e6e1a5d).
In 3.5 documentation it's mentioned that it's only available if Python
was compiled with a special flag:
https://docs.python.org/3.5/library/sys.html#sys.settscdump
* sys: update whitelists
displayhook should accept any object, not just integers.
displayhook and excepthook may be assigned to, so they should be
Callable values rather than function definitions. That way it's fine
to assign a function with different argument names. Their dunder
variants are supposed to be constant.
* Add os.add_dll_directory()
* Add memfd_create() and flags
* Add type annotation to flags
* Add stat_result.st_reparse_tag and flags
* Add ncurses_version
* Add Path.link_to()
* Add Picker.reducer_override()
* Add plistlib.UID
* Add has_dualstack_ipv6() and create_server()
* Add shlex.join()
* Add SSL methods and fields
* Add Python 3.8 statistics functions and classes
* Remove obsolete sys.subversion
* Add sys.unraisablehook
* Add threading.excepthook
* Add get_native_id() and Thread.native_id
* Add Python 3.8 tkinter methods
* Add CLOCK_UPTIME_RAW
* Add SupportsIndex
* Add typing.get_origin() and get_args()
* Add unicodedata.is_normalized
* Add unittest.mock.AsyncMock
Currently this is just an alias for Any like Mock and MagicMock. All of
these classes should probably be sub-classing Any and add their own
methods. See also #3224.
* Add unittest cleanup methods
* Add IsolatedAsyncioTestCase
* Add ElementTree.canonicalize() and C14NWriterTarget
* cProfile.Profile can be used as a context manager
* Add asyncio task name handling
* mmap.flush() now always returns None
* Add posonlyargcount to CodeType
While it may eventually be useful to mark the exceptions that can be
raised from a function or method, the semantics are currently undefined
and unclear.
* Add ExcInfo and OptExcInfo type aliases
* Implement StartResponse using a protocol
* Mark stub-only types with an underscore
* Remove wrong TODO note
python/mypy#1178 is about variable-length tuples, while exc_info()
always returns a tuple with length 3. Ideally, exc_info() would
return Union[Tuple[Type[_E], _E, TracebackType], Tuple[None, None, None]],
but that is a different issue.
This is necessary, because exception formatting functions like `traceback.format_exception()` expect to get `Type[BaseException]`, but sys.excepthook only provided `type`