Skip to content

Commit e7fe63f

Browse files
Add guidance on robust runtime use (#189)
1 parent 57aae62 commit e7fe63f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

doc/index.rst

+20
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,26 @@ version from which features were backported; for example,
4242
``typing_extensions`` 3.10.0.0 was meant to reflect ``typing`` as of
4343
Python 3.10.0. During this period, no changelog was maintained.
4444

45+
Runtime use of types
46+
~~~~~~~~~~~~~~~~~~~~
47+
48+
We aim for complete backwards compatibility in terms of the names we export:
49+
code like ``from typing_extensions import X`` that works on one
50+
typing-extensions release will continue to work on the next.
51+
It is more difficult to maintain compatibility for users that introspect
52+
types at runtime, as almost any detail can potentially break compatibility.
53+
Users who introspect types should follow these guidelines to minimize
54+
the risk of compatibility issues:
55+
56+
- Always check for both the :mod:`typing` and ``typing_extensions`` versions
57+
of objects, even if they are currently the same on some Python version.
58+
Future ``typing_extensions`` releases may re-export a separate version of
59+
the object to backport some new feature or bugfix.
60+
- Use public APIs like :func:`get_origin` and :func:`get_original_bases` to
61+
access internal information about types, instead of accessing private
62+
attributes directly. If some information is not available through a public
63+
attribute, consider opening an issue in CPython to add such an API.
64+
4565
Python version support
4666
----------------------
4767

0 commit comments

Comments
 (0)