Commit Graph

54 Commits

Author SHA1 Message Date
François Freitag
0949735210
Sort imports with isort
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.
2020-11-11 13:19:05 +01:00
Takeshi KOMIYA
218de39462 Fix testcases for singledispatch are sometimes failed
They are sometimes failed with python3.5 because the order of singledispatch
functions is not stable on python 3.5.  This uses comparision via "in"
keyword to check the signature of singledispatch functions stably.
2020-11-04 23:19:27 +09:00
Matthias Geier
82c83ed478 autodoc: Add test for single-string __slots__ 2020-10-25 10:27:43 +01:00
Takeshi KOMIYA
6dbe28a632 Fix #7786: autodoc: can't detect overloaded methods defined in other file 2020-10-05 22:49:05 +09:00
Takeshi KOMIYA
ec06f5571e
Merge pull request #8142 from jcarrano/typing-generic-signatures
autodoc: fix constructor signatures for classes derived from typing.Generic
2020-10-03 01:23:36 +09:00
Takeshi KOMIYA
dfbe687db6
Merge branch '3.x' into 8103_cached_property 2020-09-13 11:07:33 +09:00
Juan Carrano
740be7f2a5 autodoc: blacklist typing.Generic.__new__
When documenting classes derived from typing.Generic (essentially all classes in the
typing module) the constructor signature would show an unhelpful (*args, **kwds).

typing.Generic has a __new__ method which was picked up by sphinx. With this patch it
is skipped and constructor signatures for generic classes are shown as they should.
2020-08-21 18:47:50 +02:00
Juan Carrano
642686159f autodoc: Test the signature of typing.Generic subclasses.
This test is currently failing because typing.Generic.__new__ clobbers the
real signature.
2020-08-21 18:47:14 +02:00
Takeshi KOMIYA
088b049170 Fix #8103: autodoc: cached_property is not considered as a property
sphinx.util.inspect:isproperty() does not considers that
cached_property decorator that has been added since Python 3.8 is
a kind of properties.  This fixes it.
2020-08-13 23:16:59 +09:00
Takeshi KOMIYA
611fff975e Fix #8099: autodoc: NameError is raised when script uses TYPE_CHECKING
`typing.get_type_hints()` raises NameError when the target object
contains unresolavable type annotation (ex. TYPE_CHECKING).  This
handles the exception and use unresolved annotations for type hints.
2020-08-13 22:57:12 +09:00
Takeshi KOMIYA
88b2ec6c34 Fix #8041: autodoc: An ivar on super class is not shown unexpectedly
An annotated instance variable on super class is not documented when
derived class has also other annotated instance variables because
`obj.__annotations__` is overrided by derived class's type hints.

To get annotations of the target class correctly, this scans MRO to
get all of annotated instance variables.
2020-08-08 00:21:29 +09:00
Takeshi KOMIYA
c0157cf074 refactor: test: Rename target.enum to target.enums
Using "enum" for module name bothers me on debugging errors because
it sometimes raises ImportError.
2020-08-03 02:30:30 +09:00
Takeshi KOMIYA
5d301b44b9 Fix #8032: autodoc: A typehint for inherited ivars is not shown
This tries to import the parent object for the instance attribute
to get type annotations for the variable.
2020-08-02 18:27:03 +09:00
Takeshi KOMIYA
488a173904 Fix #1362: autodoc: Support private class attributes
So far, autodoc treats a "private" class attribute as a mere attribute.
But its name is mangled by python interpreter. This make it unmangled
name to be documented expectedly.
2020-07-18 03:39:38 +09:00
Takeshi KOMIYA
610ab926a4 fix 2020-07-16 23:59:26 +09:00
Takeshi KOMIYA
9b74e6cd67 autodoc: the signature of base function will be shown for decorated functions 2020-07-05 03:08:27 +09:00
Takeshi KOMIYA
659846b805 Fix #7812: autodoc: crashed when given name is conflicted
Note: this partially reverts #7594 to avoid errors.
2020-07-04 20:48:02 +09:00
Takeshi KOMIYA
e860903cd8 Fix #7844: autodoc: Failed to detect module when relative module name given 2020-06-22 01:53:09 +09:00
Takeshi KOMIYA
8bd5f8b214 autodoc: Support TypeVar (refs: #7722) 2020-06-06 12:45:20 +09:00
Takeshi KOMIYA
49de4ab1a1 Support overloaded constructors (__call__, __init__ and __new__) 2020-06-02 00:44:07 +09:00
Takeshi KOMIYA
fb2f777079 Close #3610: autodoc: Support overloaded functions 2020-05-31 23:59:32 +09:00
Takeshi KOMIYA
c1fd36cc9c Close #4422: autodoc: Support GenericAlias 2020-05-30 21:53:42 +09:00
Eric Wieser
d229b120ad Fix autoclass signature parsing
This fixes:
* Signatures defined by __new__
* Signatures defined by metaclasses
* Signatures defined by builtin base classes

All of these changes bring the sphinx docs inline with the behavior of `inspect.signature`.

Note that this changes autodoc to output `.. py:class: MyClass()` with parentheses even if no user-defined __init__ is present.
This is quite deliberate, as if no user-defined `__init__` is present the default is `object.__init__`, which indeed does not take arguments.
2020-05-28 08:36:56 +01:00
Takeshi KOMIYA
a5e3b4a43d Fix #3673: autodoc: bysource order does not work for a module having __all__ 2020-05-23 21:52:11 +09:00
Takeshi KOMIYA
a1293e2825
Merge pull request #7709 from tk0miya/refactor_test_ext_autodoc
refactor: test: Separate tests for autofunction
2020-05-23 02:38:53 +09:00
Takeshi KOMIYA
f13e05a01b refactor: test: Separate tests for autofunction 2020-05-22 23:41:45 +09:00
Takeshi KOMIYA
c5f7ded772
Merge branch '3.x' into 7668_wront_retann 2020-05-22 23:15:47 +09:00
Takeshi KOMIYA
38a21d7dac Fix #7676: autodoc: typo in the default value of autodoc_member_order 2020-05-17 01:47:32 +09:00
Takeshi KOMIYA
fcfdc19624 refactor: autodoc: Remove magic mock from singledispatch processing 2020-05-16 22:55:24 +09:00
Jakob Lykke Andersen
97accc931d
Merge pull request #7663 from jakobandersen/astext
Fix astext() for two Sphinx nodes
2020-05-16 10:09:22 +02:00
Takeshi KOMIYA
dff45a11b7 Fix #7668: autodoc: wrong retann value is passed to autodoc-proccess-signature 2020-05-16 14:51:18 +09:00
Jakob Lykke Andersen
41971382f8 ... and don't break tests. 2020-05-14 19:41:17 +02:00
Takeshi KOMIYA
3a81ffa79a Fix #7650: autodoc: undecorated signature is shown for decorated functions 2020-05-11 01:11:12 +09:00
Takeshi KOMIYA
caddd3a547 Fix test_ext_autodoc: Set testroot to testcases 2020-05-11 00:37:36 +09:00
Takeshi KOMIYA
29829bd451
Merge pull request #7623 from tk0miya/7362_autofunction_for_builtins
Fix #7362: autodoc: does not render correct signatures for built-in functions
2020-05-09 18:46:13 +09:00
Takeshi KOMIYA
6c65327be7
Merge pull request #7624 from tk0miya/refactor_autodoc2
refactor: autodoc: class processors on autofunction is no longer needed
2020-05-09 18:10:55 +09:00
Takeshi KOMIYA
92e0007179 Fix autodoc: does not render correct signatures for built-in methods 2020-05-09 17:38:28 +09:00
Takeshi KOMIYA
815abf0fea Fix #7362: autodoc: does not render correct signatures for built-in functions 2020-05-09 16:37:03 +09:00
Takeshi KOMIYA
560ccf83ae Fix #7551: autodoc: failed to import nested class 2020-05-07 02:02:02 +09:00
Takeshi KOMIYA
24fe05f14f refactor: autodoc: class processors on autofunction is no longer needed 2020-05-07 01:55:33 +09:00
Takeshi KOMIYA
eef7e4cdd5 test: Rename test_autodoc.py to test_ext_autodoc.py 2020-05-06 13:55:45 +09:00
Takeshi KOMIYA
2ca76d2366 test: Merge test_ext_autodoc.py and test_autodoc.py 2020-05-06 13:47:15 +09:00
Takeshi KOMIYA
eaf495c3c4 A happy new year! 2020-01-01 14:27:43 +09:00
Takeshi KOMIYA
90bf81bd37 test: Use get_doctree() to load doctree files 2019-02-17 20:27:48 +09:00
Takeshi KOMIYA
76e9f57c2e Merge branch '1.8' 2019-01-02 16:16:25 +09:00
Takeshi KOMIYA
1b1ebd2c75 A happy new year! 2019-01-02 16:00:30 +09:00
Jon Dufresne
bade33c7e4 Remove unnecessary encoding cookie from Python source files
In Python 3, the default encoding of source files is utf-8. The encoding
cookie is now unnecessary and redundant so remove it. For more details,
see the docs:

https://docs.python.org/3/howto/unicode.html#the-string-type

> The default encoding for Python source code is UTF-8, so you can
> simply include a Unicode character in a string literal ...

Includes a fix for the flake8 header checks to stop expecting an
encoding cookie.
2018-12-16 12:22:12 -08:00
Takeshi KOMIYA
abcb5bd5ec The default setting for master_doc is changed to 'index' 2018-09-04 01:14:16 +09:00
Takeshi KOMIYA
f7027049b1 Fix flake8 violations 2018-02-19 23:20:56 +09:00
Sergey B Kirpichev
b1c100ca3b autodoc: make full reference for classes, aliased with "alias of"
We do this here only if class belongs to the different module.

Closes sphinx-doc/sphinx#2437
2018-01-13 00:19:19 +03:00