Coverage for tests/fixtures/inheriting_enum_Enum.py: 100.00%

6 statements  

« prev     ^ index     » next       coverage.py v7.6.12, created at 2025-03-09 17:28 +0100

1""" 

2While recursing on a class inheriting from `enum.Enum`, the class' `__dict__` returns private items 

3whose values are the `object` builtin for example. 

4 

5The `object` builtin is a class, so `pytkdocs` is trying to recurse on it, 

6and tries to get its file path by first getting its module. 

7 

8The `object` class' module is `builtins`, which does not have a `__file__` attribute, 

9so trying to access it generates an `AttributeError` error. 

10 

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

12 

13References: 

14 

15- Test case: [tests.test_loader.test_inheriting_enum_Enum][]. 

16- Issue reported on commit [5053f81](https://github.com/pawamoy/mkdocstrings/commit/5053f8142913f01358481e4801e5222d88482c35). 

17- Fixed by commit [48df6bc](https://github.com/pawamoy/pytkdocs/commit/48df6bc9cf878f3ce281fac6ccaf8fe1d4e89c84). 

18- See other "inheriting" test cases. 

19""" 

20 

21import enum 

22 

23 

24class MyEnum(enum.Enum): 

25 """My custom enumeration docstring.""" 

26 

27 A = 0 

28 """Item A.""" 

29 

30 B = 1 

31 """Item B."""