To make the typehints in "Bases" field simple, this adds a new parameter
`mode` to sphinx.util.typing:restify() to suppress the leading module
name from typehints in "Bases" field.
To make the generated function signatures simple, this adds a new
parameter `smartref` to sphinx.util.typing:stringify() to suppress the
leading module name from typehints.
This allows to inject a reST snippet through autodoc-process-bases
event. It helps to modify the base classes of any class to the expected
mark-up'ed text by custom extension.
Autodoc generates reST code that uses raw `:obj:` and `:class:` xrefs to
refer the classes and types. But they're fragile because they assume
the primary_domain=='py'.
This adds `:py:` prefix to these xrefs to make them robust.
Before 3.10, an instance of NewType has incorrect module name. But it
was fixed on 3.10. This starts to use the module info if the
interpreter is 3.10+.
On generating the base class information, unexpected nit-picky warning
for ``typing.Any`` was emitted. This fixes it by using `~` prefix on
generating a cross-reference to make it valid.
So far, a TypeVar is rendered without module name. As a result, it
could not be resolved if it is imported from other modules. This
prepends its module name and make it resolvable. This is available
only in Python 3.7 or above.
As a side effect, all of TypeVars are displayed with module name. It
should be fixed in latter step (refs: #7119)
Keep imports alphabetically sorted and their order homogeneous across
Python source files.
The isort project has more feature and is more active than the
flake8-import-order plugin.
Most issues caught were simply import ordering from the same module.
Where imports were purposefully placed out of order, tag with
isort:skip.
Typically, the __args__ attribute of type annotations is a tuple
containing arguments for the types (ex. The __args__ of `List[int]` is
`(int,)`). But some kind of types has non tuple __args__ attribute.
For example, `nptyping.NDArray` is one of them.
This fixes the TypeError when the invalid __args__ attribute found.