mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-11 15:24:18 +00:00
Fix collections ABCs deprecation warning.
Signed-off-by: Jintao Zhang <zhangjintao9020@gmail.com>
This commit is contained in:
parent
7801a17adc
commit
5188a146c2
2 changed files with 14 additions and 4 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
"""Plugin loading and management logic and classes."""
|
"""Plugin loading and management logic and classes."""
|
||||||
import collections
|
|
||||||
import logging
|
import logging
|
||||||
|
import sys
|
||||||
|
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
|
|
||||||
|
|
@ -8,6 +8,11 @@ from flake8 import exceptions
|
||||||
from flake8 import utils
|
from flake8 import utils
|
||||||
from flake8.plugins import notifier
|
from flake8.plugins import notifier
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 3):
|
||||||
|
import collections.abc as collections_abc
|
||||||
|
else:
|
||||||
|
import collections as collections_abc
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
|
|
@ -411,7 +416,7 @@ class PluginTypeManager(object):
|
||||||
def generated_function(plugin): # noqa: D105
|
def generated_function(plugin): # noqa: D105
|
||||||
method = getattr(plugin, method_name, None)
|
method = getattr(plugin, method_name, None)
|
||||||
if method is not None and isinstance(
|
if method is not None and isinstance(
|
||||||
method, collections.Callable
|
method, collections_abc.Callable
|
||||||
):
|
):
|
||||||
return method(optmanager, *args, **kwargs)
|
return method(optmanager, *args, **kwargs)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
"""Tests for flake8.plugins.manager.PluginTypeManager."""
|
"""Tests for flake8.plugins.manager.PluginTypeManager."""
|
||||||
import collections
|
import sys
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
import pytest
|
import pytest
|
||||||
|
|
@ -7,6 +7,11 @@ import pytest
|
||||||
from flake8 import exceptions
|
from flake8 import exceptions
|
||||||
from flake8.plugins import manager
|
from flake8.plugins import manager
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 3):
|
||||||
|
import collections.abc as collections_abc
|
||||||
|
else:
|
||||||
|
import collections as collections_abc
|
||||||
|
|
||||||
TEST_NAMESPACE = "testing.plugin-type-manager"
|
TEST_NAMESPACE = "testing.plugin-type-manager"
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -86,7 +91,7 @@ def test_generate_call_function():
|
||||||
'method_name', optmanager,
|
'method_name', optmanager,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert isinstance(func, collections.Callable)
|
assert isinstance(func, collections_abc.Callable)
|
||||||
assert func(plugin) is optmanager
|
assert func(plugin) is optmanager
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue