Skip to content

Commit

Permalink
Fix - C0412: Imports from package x are not grouped
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre-Sassoulas committed Mar 9, 2019
1 parent 91368a0 commit 82d3eb8
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
14 changes: 7 additions & 7 deletions pylint/checkers/imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@

import astroid
import isort
from astroid import are_exclusive, decorators
from astroid.modutils import get_module_part, is_standard_module

from pylint.checkers import BaseChecker
from pylint.checkers.utils import (
Expand Down Expand Up @@ -114,7 +112,7 @@ def _get_first_import(node, context, name, base, level, alias):
break
if found:
break
if found and not are_exclusive(first, node):
if found and not astroid.are_exclusive(first, node):
return first
return None

Expand Down Expand Up @@ -789,14 +787,16 @@ def _add_imported_module(self, node, importedmodname):
base = os.path.splitext(os.path.basename(module_file))[0]

try:
importedmodname = get_module_part(importedmodname, module_file)
importedmodname = astroid.modutils.get_module_part(
importedmodname, module_file
)
except ImportError:
pass

if context_name == importedmodname:
self.add_message("import-self", node=node)

elif not is_standard_module(importedmodname):
elif not astroid.modutils.is_standard_module(importedmodname):
# if this is not a package __init__ module
if base != "__init__" and context_name not in self._module_pkg:
# record the module's parent, or the module itself if this is
Expand Down Expand Up @@ -897,14 +897,14 @@ def _filter_dependencies_graph(self, internal):
graph[importee].add(importer)
return graph

@decorators.cached
@astroid.decorators.cached
def _external_dependencies_info(self):
"""return cached external dependencies information or build and
cache them
"""
return self._filter_dependencies_graph(internal=False)

@decorators.cached
@astroid.decorators.cached
def _internal_dependencies_info(self):
"""return cached internal dependencies information or build and
cache them
Expand Down
1 change: 1 addition & 0 deletions pylint/extensions/mccabe.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

from mccabe import PathGraph as Mccabe_PathGraph
from mccabe import PathGraphingAstVisitor as Mccabe_PathGraphingAstVisitor

from pylint import checkers
from pylint.checkers.utils import check_messages
from pylint.interfaces import HIGH, IAstroidChecker
Expand Down
5 changes: 3 additions & 2 deletions pylint/test/test_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# For details: https://github.com/PyCQA/pylint/blob/master/COPYING

"""Functional full-module tests for PyLint."""

import collections
import csv
import io
Expand All @@ -22,11 +23,11 @@
import sys

import pytest

import six
from pylint import checkers, interfaces, lint, reporters
from six.moves import configparser

from pylint import checkers, interfaces, lint, reporters


class test_dialect(csv.excel):
if sys.version_info[0] < 3:
Expand Down
11 changes: 5 additions & 6 deletions pylint/testutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,12 @@
import collections
import contextlib
import functools
import os
import sys
import tempfile
import tokenize
from glob import glob
from io import StringIO
from os import getcwd, linesep, sep
from os import close, getcwd, linesep, remove, sep, write
from os.path import abspath, basename, dirname, join, splitext

import astroid
Expand Down Expand Up @@ -286,14 +285,14 @@ def _create_tempfile(content=None):
if content:
if sys.version_info >= (3, 0):
# erff
os.write(file_handle, bytes(content, "ascii"))
write(file_handle, bytes(content, "ascii"))
else:
os.write(file_handle, content)
write(file_handle, content)
try:
yield tmp
finally:
os.close(file_handle)
os.remove(tmp)
close(file_handle)
remove(tmp)


@contextlib.contextmanager
Expand Down

0 comments on commit 82d3eb8

Please sign in to comment.