mirror of
https://github.com/davidhalter/parso.git
synced 2026-04-26 09:26:01 +08:00
Use Zuban and therefore check untyped code
This commit is contained in:
+14
-4
@@ -44,7 +44,7 @@ Parser Tree Classes
|
||||
|
||||
import re
|
||||
from collections.abc import Mapping
|
||||
from typing import Tuple
|
||||
from typing import Tuple, Any
|
||||
|
||||
from parso.tree import Node, BaseNode, Leaf, ErrorNode, ErrorLeaf, search_ancestor # noqa
|
||||
from parso.python.prefix import split_prefix
|
||||
@@ -67,6 +67,9 @@ _IMPORTS = set(['import_name', 'import_from'])
|
||||
|
||||
class DocstringMixin:
|
||||
__slots__ = ()
|
||||
type: str
|
||||
children: list[Any]
|
||||
parent: Any
|
||||
|
||||
def get_doc_node(self):
|
||||
"""
|
||||
@@ -98,6 +101,7 @@ class PythonMixin:
|
||||
Some Python specific utilities.
|
||||
"""
|
||||
__slots__ = ()
|
||||
children: list[Any]
|
||||
|
||||
def get_name_of_position(self, position):
|
||||
"""
|
||||
@@ -216,7 +220,7 @@ class Name(_LeafWithoutNewlines):
|
||||
type_ = node.type
|
||||
|
||||
if type_ in ('funcdef', 'classdef'):
|
||||
if self == node.name:
|
||||
if self == node.name: # type: ignore[union-attr]
|
||||
return node
|
||||
return None
|
||||
|
||||
@@ -229,7 +233,7 @@ class Name(_LeafWithoutNewlines):
|
||||
if node.type == 'suite':
|
||||
return None
|
||||
if node.type in _GET_DEFINITION_TYPES:
|
||||
if self in node.get_defined_names(include_setitem):
|
||||
if self in node.get_defined_names(include_setitem): # type: ignore[attr-defined]
|
||||
return node
|
||||
if import_name_always and node.type in _IMPORTS:
|
||||
return node
|
||||
@@ -293,6 +297,7 @@ class FStringEnd(PythonLeaf):
|
||||
|
||||
class _StringComparisonMixin:
|
||||
__slots__ = ()
|
||||
value: Any
|
||||
|
||||
def __eq__(self, other):
|
||||
"""
|
||||
@@ -365,7 +370,7 @@ class Scope(PythonBaseNode, DocstringMixin):
|
||||
|
||||
def __repr__(self):
|
||||
try:
|
||||
name = self.name.value
|
||||
name = self.name.value # type: ignore[attr-defined]
|
||||
except AttributeError:
|
||||
name = ''
|
||||
|
||||
@@ -791,6 +796,8 @@ class WithStmt(Flow):
|
||||
|
||||
class Import(PythonBaseNode):
|
||||
__slots__ = ()
|
||||
get_paths: Any
|
||||
_aliases: Any
|
||||
|
||||
def get_path_for_name(self, name):
|
||||
"""
|
||||
@@ -815,6 +822,9 @@ class Import(PythonBaseNode):
|
||||
def is_star_import(self):
|
||||
return self.children[-1] == '*'
|
||||
|
||||
def get_defined_names(self):
|
||||
raise NotImplementedError("Use ImportFrom or ImportName")
|
||||
|
||||
|
||||
class ImportFrom(Import):
|
||||
type = 'import_from'
|
||||
|
||||
Reference in New Issue
Block a user