use-collections-abc¶
Require collection ABCs to be imported from collections.abc.
Message¶
ABCs must be imported from collections.abc
Valid examples¶
from collections.abc import Container
from collections.abc import Container, Hashable
from collections.abc import (Container, Hashable)
from collections import defaultdict
from collections import abc
import collections
Show more
import collections.abc
import collections.abc.Container
class MyTest(collections.Something):
def test(self):
pass
try:
from collections.abc import Mapping
except ImportError:
from collections import Mapping
try:
from collections.abc import Mapping, Container
except ImportError:
from collections import Mapping, Container
try:
from collections.abc import Mapping, Container
except ImportError:
def fallback_import():
from collections import Mapping, Container
try:
from collections.abc import Mapping, Container
except Exception:
exit()
try:
from collections import defaultdict
except Exception:
exit()
Invalid examples¶
from collections import Container
Suggested fix
from collections.abc import Container
from collections import Container, Hashable
Suggested fix
from collections.abc import Container, Hashable
from collections import (Container, Hashable)
Suggested fix
from collections.abc import (Container, Hashable)
Show more
import collections.Container
Suggested fix
import collections.abc.Container
import collections.Container as cont
Suggested fix
import collections.abc.Container as cont
from collections import defaultdict, Container
Suggested fix
from collections import defaultdict
from collections.abc import Container
from collections import defaultdict
from collections import Container
Suggested fix
from collections import defaultdict
from collections.abc import Container
from collections import defaultdict, Container
from collections import OrderedDict, Mapping
Suggested fix
from collections import defaultdict
from collections.abc import Container
from collections import OrderedDict
from collections.abc import Mapping
class MyTest(collections.Container):
def test(self):
pass
Suggested fix
class MyTest(collections.abc.Container):
def test(self):
pass