File: inheriting_enum_Enum.py

package info (click to toggle)
pytkdocs 0.16.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 784 kB
  • sloc: python: 4,621; makefile: 28; javascript: 13
file content (31 lines) | stat: -rw-r--r-- 1,010 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"""
While recursing on a class inheriting from `enum.Enum`, the class' `__dict__` returns private items
whose values are the `object` builtin for example.

The `object` builtin is a class, so `pytkdocs` is trying to recurse on it,
and tries to get its file path by first getting its module.

The `object` class' module is `builtins`, which does not have a `__file__` attribute,
so trying to access it generates an `AttributeError` error.

Instead of failing, we simply catch the error and set `file_path = ""`.

References:

- Test case: [tests.test_loader.test_inheriting_enum_Enum][].
- Issue reported on commit [5053f81](https://github.com/pawamoy/mkdocstrings/commit/5053f8142913f01358481e4801e5222d88482c35).
- Fixed by commit [48df6bc](https://github.com/pawamoy/pytkdocs/commit/48df6bc9cf878f3ce281fac6ccaf8fe1d4e89c84).
- See other "inheriting" test cases.
"""

import enum


class MyEnum(enum.Enum):
    """My custom enumeration docstring."""

    A = 0
    """Item A."""

    B = 1
    """Item B."""