Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion astroid/brain/brain_builtin_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from __future__ import annotations

import itertools
from collections.abc import Iterator
from functools import partial
from typing import Iterator

from astroid import arguments, helpers, inference_tip, nodes, objects, util
from astroid.builder import AstroidBuilder
Expand Down
3 changes: 2 additions & 1 deletion astroid/brain/brain_dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
from __future__ import annotations

import sys
from typing import Generator, Tuple, Union
from collections.abc import Generator
from typing import Tuple, Union

from astroid import context, inference_tip
from astroid.builder import parse
Expand Down
2 changes: 1 addition & 1 deletion astroid/brain/brain_functools.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

from __future__ import annotations

from collections.abc import Iterator
from functools import partial
from itertools import chain
from typing import Iterator

from astroid import BoundMethod, arguments, extract_node, helpers, nodes, objects
from astroid.context import InferenceContext
Expand Down
2 changes: 1 addition & 1 deletion astroid/brain/brain_namedtuple_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

import functools
import keyword
from collections.abc import Iterator
from textwrap import dedent
from typing import Iterator

import astroid
from astroid import arguments, inference_tip, nodes, util
Expand Down
13 changes: 7 additions & 6 deletions astroid/brain/brain_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from __future__ import annotations

import typing
from collections.abc import Iterator
from functools import partial

from astroid import context, extract_node, inference_tip
Expand Down Expand Up @@ -144,7 +145,7 @@ def _looks_like_typing_subscript(node):

def infer_typing_attr(
node: Subscript, ctx: context.InferenceContext | None = None
) -> typing.Iterator[ClassDef]:
) -> Iterator[ClassDef]:
"""Infer a typing.X[...] subscript"""
try:
value = next(node.value.infer()) # type: ignore[union-attr] # value shouldn't be None for Subscript.
Expand Down Expand Up @@ -190,15 +191,15 @@ def _looks_like_typedDict( # pylint: disable=invalid-name

def infer_old_typedDict( # pylint: disable=invalid-name
node: ClassDef, ctx: context.InferenceContext | None = None
) -> typing.Iterator[ClassDef]:
) -> Iterator[ClassDef]:
func_to_add = _extract_single_node("dict")
node.locals["__call__"] = [func_to_add]
return iter([node])


def infer_typedDict( # pylint: disable=invalid-name
node: FunctionDef, ctx: context.InferenceContext | None = None
) -> typing.Iterator[ClassDef]:
) -> Iterator[ClassDef]:
"""Replace TypedDict FunctionDef with ClassDef."""
class_def = ClassDef(
name="TypedDict",
Expand Down Expand Up @@ -258,7 +259,7 @@ def full_raiser(origin_func, attr, *args, **kwargs):

def infer_typing_alias(
node: Call, ctx: context.InferenceContext | None = None
) -> typing.Iterator[ClassDef]:
) -> Iterator[ClassDef]:
"""
Infers the call to _alias function
Insert ClassDef, with same name as aliased class,
Expand Down Expand Up @@ -346,7 +347,7 @@ def _looks_like_special_alias(node: Call) -> bool:

def infer_special_alias(
node: Call, ctx: context.InferenceContext | None = None
) -> typing.Iterator[ClassDef]:
) -> Iterator[ClassDef]:
"""Infer call to tuple alias as new subscriptable class typing.Tuple."""
if not (
isinstance(node.parent, Assign)
Expand Down Expand Up @@ -381,7 +382,7 @@ def _looks_like_typing_cast(node: Call) -> bool:

def infer_typing_cast(
node: Call, ctx: context.InferenceContext | None = None
) -> typing.Iterator[NodeNG]:
) -> Iterator[NodeNG]:
"""Infer call to cast() returning same type as casted-from var"""
if not isinstance(node.func, (Name, Attribute)):
raise UseInferenceDefault
Expand Down
5 changes: 4 additions & 1 deletion astroid/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@

""" A few useful function/method decorators."""

from __future__ import annotations

import functools
import inspect
import sys
import warnings
from typing import Callable, TypeVar
from collections.abc import Callable
from typing import TypeVar

import wrapt

Expand Down
3 changes: 2 additions & 1 deletion astroid/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
import functools
import itertools
import operator
from typing import TYPE_CHECKING, Any, Callable, Generator, Iterable, Iterator, TypeVar
from collections.abc import Callable, Generator, Iterable, Iterator
from typing import TYPE_CHECKING, Any, TypeVar

from astroid import bases, decorators, helpers, nodes, protocols, util
from astroid.context import (
Expand Down
3 changes: 2 additions & 1 deletion astroid/inference_tip.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from __future__ import annotations

import typing
from collections.abc import Iterator

import wrapt

Expand All @@ -30,7 +31,7 @@ def clear_inference_tip_cache():
@wrapt.decorator
def _inference_tip_cached(
func: InferFn, instance: None, args: typing.Any, kwargs: typing.Any
) -> typing.Iterator[InferOptions]:
) -> Iterator[InferOptions]:
"""Cache decorator used for inference tips"""
node = args[0]
try:
Expand Down
3 changes: 2 additions & 1 deletion astroid/interpreter/_import/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
import os
import sys
import zipimport
from collections.abc import Sequence
from functools import lru_cache
from pathlib import Path
from typing import NamedTuple, Sequence
from typing import NamedTuple

from astroid.modutils import EXT_LIB_DIRS

Expand Down
13 changes: 2 additions & 11 deletions astroid/nodes/node_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,9 @@
import sys
import typing
import warnings
from collections.abc import Generator, Iterator
from functools import lru_cache
from typing import (
TYPE_CHECKING,
Any,
Callable,
ClassVar,
Generator,
Iterator,
Optional,
TypeVar,
Union,
)
from typing import TYPE_CHECKING, Any, Callable, ClassVar, Optional, TypeVar, Union

from astroid import decorators, mixins, util
from astroid.bases import Instance, _infer_stmts
Expand Down
13 changes: 2 additions & 11 deletions astroid/nodes/node_ng.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,9 @@
import pprint
import sys
import warnings
from collections.abc import Iterator
from functools import singledispatch as _singledispatch
from typing import (
TYPE_CHECKING,
ClassVar,
Iterator,
Tuple,
Type,
TypeVar,
Union,
cast,
overload,
)
from typing import TYPE_CHECKING, ClassVar, Tuple, Type, TypeVar, Union, cast, overload

from astroid import decorators, util
from astroid.exceptions import (
Expand Down
4 changes: 2 additions & 2 deletions astroid/nodes/scoped_nodes/scoped_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
import itertools
import os
import sys
import typing
import warnings
from collections.abc import Iterator
from typing import TYPE_CHECKING, NoReturn, TypeVar, overload

from astroid import bases
Expand Down Expand Up @@ -2959,7 +2959,7 @@ def slots(self):

def grouped_slots(
mro: list[ClassDef],
) -> typing.Iterator[node_classes.NodeNG | None]:
) -> Iterator[node_classes.NodeNG | None]:
# Not interested in object, since it can't have slots.
for cls in mro[:-1]:
try:
Expand Down
3 changes: 2 additions & 1 deletion astroid/nodes/scoped_nodes/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
from __future__ import annotations

import builtins
from typing import TYPE_CHECKING, Sequence
from collections.abc import Sequence
from typing import TYPE_CHECKING

from astroid.manager import AstroidManager

Expand Down
3 changes: 2 additions & 1 deletion astroid/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
from __future__ import annotations

import sys
from typing import Iterator, TypeVar
from collections.abc import Iterator
from typing import TypeVar

from astroid import bases, decorators, util
from astroid.context import InferenceContext
Expand Down
3 changes: 2 additions & 1 deletion astroid/protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
import collections
import itertools
import operator as operator_mod
from typing import Any, Generator
from collections.abc import Generator
from typing import Any

from astroid import arguments, bases, decorators, helpers, nodes, util
from astroid.const import Context
Expand Down
2 changes: 1 addition & 1 deletion astroid/raw_building.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import sys
import types
import warnings
from typing import Iterable
from collections.abc import Iterable

from astroid import bases, nodes
from astroid.manager import AstroidManager
Expand Down
3 changes: 2 additions & 1 deletion astroid/rebuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
import ast
import sys
import token
from collections.abc import Callable, Generator
from io import StringIO
from tokenize import TokenInfo, generate_tokens
from typing import Callable, Generator, TypeVar, Union, cast, overload
from typing import TypeVar, Union, cast, overload

from astroid import nodes
from astroid._ast import ParserModule, get_parser_module, parse_function_type_comment
Expand Down
2 changes: 1 addition & 1 deletion astroid/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import functools
import sys
import warnings
from typing import Callable
from collections.abc import Callable

import pytest

Expand Down
2 changes: 1 addition & 1 deletion pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ unsafe-load-any-extension=no
extension-pkg-whitelist=

# Minimum supported python version
py-version = 3.6.2
py-version = 3.7.2


[REPORTS]
Expand Down
3 changes: 2 additions & 1 deletion tests/unittest_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
import textwrap
import unittest
from abc import ABCMeta
from collections.abc import Callable
from functools import partial
from pathlib import Path
from typing import Any, Callable
from typing import Any
from unittest.mock import patch

import pytest
Expand Down
2 changes: 1 addition & 1 deletion tests/unittest_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import sys
import time
import unittest
from collections.abc import Iterator
from contextlib import contextmanager
from typing import Iterator

import pkg_resources

Expand Down
3 changes: 2 additions & 1 deletion tests/unittest_protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

import contextlib
import unittest
from typing import Any, Callable, Iterator
from collections.abc import Callable, Iterator
from typing import Any

import pytest

Expand Down
2 changes: 1 addition & 1 deletion tests/unittest_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import contextlib
import time
import unittest
from typing import Callable, Iterator
from collections.abc import Callable, Iterator

from astroid import MANAGER, builder, nodes, parse, transforms
from astroid.manager import AstroidManager
Expand Down