|
15 | 15 | import os
|
16 | 16 | import sys
|
17 | 17 | import warnings
|
18 |
| -from collections.abc import Iterator |
| 18 | +from collections.abc import Generator, Iterator |
19 | 19 | from typing import TYPE_CHECKING, NoReturn, TypeVar, overload
|
20 | 20 |
|
21 | 21 | from astroid import bases
|
@@ -2014,11 +2014,8 @@ def __init__(
|
2014 | 2014 | :type: list(Keyword) or None
|
2015 | 2015 | """
|
2016 | 2016 |
|
2017 |
| - self.bases = [] |
2018 |
| - """What the class inherits from. |
2019 |
| -
|
2020 |
| - :type: list(NodeNG) |
2021 |
| - """ |
| 2017 | + self.bases: list[NodeNG] = [] |
| 2018 | + """What the class inherits from.""" |
2022 | 2019 |
|
2023 | 2020 | self.body = []
|
2024 | 2021 | """The contents of the class body.
|
@@ -2375,14 +2372,14 @@ def basenames(self):
|
2375 | 2372 | """
|
2376 | 2373 | return [bnode.as_string() for bnode in self.bases]
|
2377 | 2374 |
|
2378 |
| - def ancestors(self, recurs=True, context=None): |
| 2375 | + def ancestors( |
| 2376 | + self, recurs: bool = True, context: InferenceContext | None = None |
| 2377 | + ) -> Generator[ClassDef, None, None]: |
2379 | 2378 | """Iterate over the base classes in prefixed depth first order.
|
2380 | 2379 |
|
2381 | 2380 | :param recurs: Whether to recurse or return direct ancestors only.
|
2382 |
| - :type recurs: bool |
2383 | 2381 |
|
2384 | 2382 | :returns: The base classes
|
2385 |
| - :rtype: iterable(NodeNG) |
2386 | 2383 | """
|
2387 | 2384 | # FIXME: should be possible to choose the resolution order
|
2388 | 2385 | # FIXME: inference make infinite loops possible here
|
|
0 commit comments