Exemplo n.º 1
0
    def check_alias(self, node: AnyImport) -> None:
        for alias in node.names:
            if alias.asname == alias.name:
                self._error_callback(
                    SameAliasImportViolation(node, text=alias.name), )

            for name in (alias.name, alias.asname):
                if name is None:
                    continue

                blacklisted = name in constants.VAGUE_IMPORTS_BLACKLIST
                with_from = name.startswith('from_')
                with_to = name.startswith('to_')

                if blacklisted or with_from or with_to or len(name) == 1:
                    self._error_callback(
                        VagueImportViolation(node, text=alias.name), )
Exemplo n.º 2
0
 def check_alias(self, node: AnyImport) -> None:
     for alias in node.names:
         if alias.asname == alias.name:
             self._error_callback(
                 SameAliasImportViolation(node, text=alias.name), )
Exemplo n.º 3
0
 def _check_same_alias(self, node: AnyImport) -> None:
     for alias in node.names:
         if alias.asname == alias.name and self._options.i_control_code:
             self._error_callback(
                 SameAliasImportViolation(node, text=alias.name), )
Exemplo n.º 4
0
 def check_alias(self, node: AnyImport) -> None:
     for alias in node.names:
         if alias.asname == alias.name:
             self.delegate.add_violation(
                 SameAliasImportViolation(node, text=alias.name),
             )