diff --git a/docs/introduction.md b/docs/introduction.md index 28e3cf9..cabbf57 100644 --- a/docs/introduction.md +++ b/docs/introduction.md @@ -78,7 +78,7 @@ There are several interesting things to note here: The `optional` or `default = ...` part don't influence the annotation. - Referencing the `float` and `Iterable` worked out of the box. - All [built-in types](https://docs.python.org/3/library/stdtypes.html#built-in-types) as well as types from the standard library's `typing` and `collections.abc` module can be used like this. + All [built-in types](https://docs.python.org/3/library/stdtypes.html#built-in-types) as well as types from the standard library's `typing`, `types` and `collections.abc` module can be used like this. Necessary imports will be added automatically to the stub file. diff --git a/src/docstub/_analysis.py b/src/docstub/_analysis.py index 8c71b60..d5bffe4 100644 --- a/src/docstub/_analysis.py +++ b/src/docstub/_analysis.py @@ -274,6 +274,7 @@ def common_known_types(): types |= _runtime_types_in_module("typing") # Overrides containers from typing types |= _runtime_types_in_module("collections.abc") + types |= _runtime_types_in_module("types") return types diff --git a/tests/test_analysis.py b/tests/test_analysis.py index 99a0305..11bdbbf 100644 --- a/tests/test_analysis.py +++ b/tests/test_analysis.py @@ -256,6 +256,8 @@ def test_query_prefix(self, search_name, expected_name, expected_origin): ("collections.abc.Iterable", "collections.abc"), ("Literal", "typing"), ("typing.Literal", "typing"), + ("NoneType", "types"), + ("SimpleNamespace", "types"), ], ) def test_common_known_types(self, search_name, import_path):