Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
tristanlatr authored Dec 9, 2024
1 parent 7c772fe commit 2b8eb36
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pydoctor/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ def _compute_mro(self, cls: Class) -> list[ClassOrStr]:
# support documenting typing.py module by using allobject.get.
generic = cls.system.allobjects.get(d:='typing.Generic', d)
if generic in bases and any(generic in _mro for _mro in bases_mros):
# this is cafe since we checked 'generic in bases'.
# this is safe since we checked 'generic in bases'.
bases.remove(generic) # type: ignore[arg-type]

try:
Expand Down
15 changes: 15 additions & 0 deletions pydoctor/test/test_mro.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,21 @@ class C(A, Generic[T], B[T]): ...
assert_mro_equals(mod.contents['C'],
["t.C", "t.A", "t.B", "typing.Generic"])

def test_mro_generic_in_system(capsys:CapSys) -> None:
src = '''
class TypeVar:...
class Generic: ...
T = TypeVar('T')
class A: ...
class B(Generic[T]): ...
class C(A, Generic[T], B[T]): ...
'''
mod = fromText(src, modname='typing')
assert not capsys.readouterr().out
assert_mro_equals(mod.contents['C'],
["typing.C", "typing.A", "typing.B", "typing.Generic"])


def test_mro_generic_4(capsys:CapSys) -> None:
src = '''
from typing import Generic, TypeVar
Expand Down

0 comments on commit 2b8eb36

Please sign in to comment.