Commit Graph

54 Commits

Author SHA1 Message Date
Audrey Dutcher
e3321bb3a9 Don't crash when autodocumenting classes with __slots__ = None 2019-06-05 22:27:54 +09:00
Takeshi KOMIYA
277aba935d Close #6325: autodoc: Support attributes in __slots__ 2019-05-22 09:56:46 +09:00
Takeshi KOMIYA
af51e9825a refactor: Move implementation of mock to sphinx.ext.autodoc.mock 2019-02-27 21:42:23 +09:00
Takeshi KOMIYA
453ed5e29a Merge branch 'master' into 5394_meaningful_annotations_for_mock 2019-02-11 01:38:26 +09:00
Takeshi KOMIYA
aabbbe346c Merge branch '1.8' 2019-02-03 17:07:13 +09:00
Takeshi KOMIYA
b6478accb0 Fix #5995: autodoc: autodoc_mock_imports conflict with metaclass 2019-02-02 01:22:57 +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
2597c4174e
Merge pull request #5796 from jdufresne/super
Use Python 3 super() argument-less syntax
2018-12-16 19:46:47 +09:00
Jon Dufresne
2646a88b1b Use os.devnull; replace hard coded value
https://docs.python.org/3/library/os.html#os.devnull
2018-12-15 11:11:43 -08:00
Jon Dufresne
ade973f4e3 Use Python 3 super() argument-less syntax
The form is less verbose and more idiomatic for Python 3 only code.

https://docs.python.org/3/library/functions.html#super
2018-12-15 08:35:55 -08:00
Takeshi KOMIYA
6bc357140d Replace all "unicode" type by "str" 2018-12-15 23:57:43 +09:00
Jon Dufresne
c994f30b25 Define _MockImporter as a MetaPathFinder
The instance is added to sys.meta_path. Per the documentation, this
should be a MetaPathFinder:

https://docs.python.org/3/library/sys.html#sys.meta_path

Correct the _MockImporter.find_module() type signature per typeshed.

0b49ce75b4/stdlib/3/importlib/abc.pyi (L56-L57)
2018-12-09 12:30:56 -08:00
Takeshi KOMIYA
1a50d34520 refactor `mock()` to based on PEP-451 implementation 2018-12-04 23:57:01 +09:00
Takeshi KOMIYA
3c99d00605 Add sphinx.util.typing:unicode to help mypy-3 migration 2018-11-24 23:19:51 +09:00
Jon Dufresne
ce8227c6cf Replace all six.itervalues()/.iteritems() with .values()/.items() 2018-09-23 18:26:31 -07:00
Takeshi KOMIYA
dc44b0d2a9 Merge branch 'master' into HEAD 2018-09-22 22:54:15 +09:00
Takeshi KOMIYA
3a2418a827 refactoring: Drop PY2 and PY3 flags 2018-09-22 21:27:59 +09:00
Takeshi KOMIYA
b18fe13f55 Drop branches for sys.version_info < (3, 4) 2018-09-22 16:31:07 +09:00
Takeshi KOMIYA
9e8434f902 Fix #5436: Autodoc does not work with enum subclasses with properties/methods 2018-09-18 13:01:10 +09:00
Jon Dufresne
490e4aed41 Remove unnecessary object from class definitions
In Python 3, all classes are new-style classes. The object in the
definition is redundant and unnecessary.
2018-09-11 07:07:01 -07:00
Max
4d94c3c97b removed redundant "type: ignore" 2018-09-07 19:10:28 +03:00
Max
c0b5f4712d fix returned type 2018-09-07 15:45:23 +03:00
Max
61f9005b73 _MockModule and _MockObject now display meaningful names in type annotations and superclass names 2018-09-07 15:14:01 +03:00
Takeshi KOMIYA
e07731e7b1 Fix autodoc: ImportError is replaced by AttributeError for deeper module 2018-09-03 22:49:01 +09:00
Takeshi KOMIYA
8c29801f27 Close #2820: autoclass directive supports nested class 2018-07-22 01:06:17 +09:00
Takeshi KOMIYA
3e57ea0a52 Merge branch '1.7' 2018-07-17 00:37:40 +09:00
Takeshi KOMIYA
b1acc54cf9 Fix #5139: autodoc: Enum argument missing if it shares value with another 2018-07-15 18:53:53 +09:00
shimizukawa
eacaaed1c7 Merge branch 1.7 2018-05-25 08:17:19 +09:00
Takeshi KOMIYA
cff194d5dd Fix #4931: autodoc: crashed when subclass of mocked class are processed by napoleon module 2018-05-24 01:39:07 +09:00
Takeshi KOMIYA
506d4c87ef Merge branch '1.7' 2018-05-21 23:07:54 +09:00
Takeshi KOMIYA
3080d24330 Fix #4956: autodoc: Failed to extract document from a subclass of the class on mocked module 2018-05-21 21:53:20 +09:00
Takeshi KOMIYA
9efaf18852 Merge branch '1.7' 2018-03-18 01:21:01 +09:00
Takeshi KOMIYA
70a622b86c Revert "Use typing.TYPE_CHECKING for typehints"
This reverts commit a073e17537.
2018-03-13 23:23:15 +09:00
Takeshi KOMIYA
a2bce15989 Merge branch '1.7' 2018-02-23 23:44:00 +09:00
adam-azarchs
6a2ec96c97 Fix error reporting for parameterless ImportErrors
In some cases, a module may raise an ImportError without any arguments, e.g.

if not_allowed():
    raise ImportError

In this case, the exception has no args.  This is bad practice, but it happens.

Currently, autodoc will crash with

IndexError: tuple index out of range
2018-02-20 12:22:47 -08:00
Takeshi KOMIYA
f8bb40ab30 Merge branch '1.7' 2018-02-18 12:39:07 +09:00
Takeshi KOMIYA
a073e17537 Use typing.TYPE_CHECKING for typehints 2018-02-14 22:57:38 +09:00
Takeshi KOMIYA
dc2b153835 Update type annotations 2018-02-04 15:14:51 +09:00
Takeshi KOMIYA
9f5c676322 Use flake8-import-order 2018-01-28 01:52:16 +09:00
Rouven Czerwinski
bcdea4da5c autodoc: prefer _MockImporter over other importers in sys.path
In case we want to mock modules which are actually available in the current
environment, we need to add the _MockImporter before other importers. We ran
into this problem in our application, where importing the existing modules
caused side effects which were not fixed by autodoc_mock_imports.
2018-01-27 13:51:00 +01:00
Robin Jarry
c24dffc5a8 autodoc: only mock specified modules with their descendants
Do not mock the ancestors of the specified modules in
autodoc_mock_imports. Only mock the modules themselves and their
descendants (as specified in the docs).

Fix the test configs accordingly.

Signed-off-by: Robin Jarry <robin@jarry.cc>
2018-01-13 17:24:02 +01:00
Takeshi KOMIYA
c2a7984e05 Fix enum34 members are treated as inherited member 2018-01-06 22:10:15 +09:00
Takeshi KOMIYA
c1b3efe203 Fix mypy violation 2018-01-06 21:01:04 +09:00
Takeshi KOMIYA
bf0153d748 autodoc: Refactor get_object_members() 2018-01-01 12:13:30 +09:00
Takeshi KOMIYA
1d64ade749 Refactor: Add import_object() 2018-01-01 12:13:29 +09:00
Takeshi KOMIYA
5562e76585 A happy new year! 2018-01-01 01:10:10 +09:00
Takeshi KOMIYA
b6d6e4cc73 autodoc: Fix error handling for import_module() 2017-12-14 22:55:31 +09:00
Takeshi KOMIYA
9b3ef92d7b autodoc: refactor MockImporter 2017-12-14 15:36:08 +09:00