mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 06:24:27 +08:00
Remove redundant parentheses
This commit is contained in:
@@ -132,7 +132,7 @@ def find_module_pre_py33(string, path=None, fullname=None):
|
|||||||
file = None
|
file = None
|
||||||
if not is_package or is_archive:
|
if not is_package or is_archive:
|
||||||
file = DummyFile(loader, string)
|
file = DummyFile(loader, string)
|
||||||
return (file, module_path, is_package)
|
return file, module_path, is_package
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
raise ImportError("No module named {}".format(string))
|
raise ImportError("No module named {}".format(string))
|
||||||
|
|||||||
@@ -555,7 +555,7 @@ class Definition(BaseDefinition):
|
|||||||
.. todo:: Add full path. This function is should return a
|
.. todo:: Add full path. This function is should return a
|
||||||
`module.class.function` path.
|
`module.class.function` path.
|
||||||
"""
|
"""
|
||||||
position = '' if self.in_builtin_module else '@%s' % (self.line)
|
position = '' if self.in_builtin_module else '@%s' % self.line
|
||||||
return "%s:%s%s" % (self.module_name, self.description, position)
|
return "%s:%s%s" % (self.module_name, self.description, position)
|
||||||
|
|
||||||
@memoize_method
|
@memoize_method
|
||||||
|
|||||||
@@ -432,7 +432,7 @@ def dotted_from_fs_path(fs_path, sys_path):
|
|||||||
# C:\path\to\Lib
|
# C:\path\to\Lib
|
||||||
path = ''
|
path = ''
|
||||||
for s in sys_path:
|
for s in sys_path:
|
||||||
if (fs_path.startswith(s) and len(path) < len(s)):
|
if fs_path.startswith(s) and len(path) < len(s):
|
||||||
path = s
|
path = s
|
||||||
|
|
||||||
# - Window
|
# - Window
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ else:
|
|||||||
return getattr(klass, '__dict__', _sentinel)
|
return getattr(klass, '__dict__', _sentinel)
|
||||||
return _shadowed_dict_newstyle(klass)
|
return _shadowed_dict_newstyle(klass)
|
||||||
|
|
||||||
class _OldStyleClass():
|
class _OldStyleClass:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
_oldstyle_instance_type = type(_OldStyleClass())
|
_oldstyle_instance_type = type(_OldStyleClass())
|
||||||
@@ -122,7 +122,7 @@ def _safe_hasattr(obj, name):
|
|||||||
|
|
||||||
|
|
||||||
def _safe_is_data_descriptor(obj):
|
def _safe_is_data_descriptor(obj):
|
||||||
return (_safe_hasattr(obj, '__set__') or _safe_hasattr(obj, '__delete__'))
|
return _safe_hasattr(obj, '__set__') or _safe_hasattr(obj, '__delete__')
|
||||||
|
|
||||||
|
|
||||||
def getattr_static(obj, attr, default=_sentinel):
|
def getattr_static(obj, attr, default=_sentinel):
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ class MixedName(compiled.CompiledName):
|
|||||||
contexts = list(self.infer())
|
contexts = list(self.infer())
|
||||||
if not contexts:
|
if not contexts:
|
||||||
# This means a start_pos that doesn't exist (compiled objects).
|
# This means a start_pos that doesn't exist (compiled objects).
|
||||||
return (0, 0)
|
return 0, 0
|
||||||
return contexts[0].name.start_pos
|
return contexts[0].name.start_pos
|
||||||
|
|
||||||
@start_pos.setter
|
@start_pos.setter
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ b[int():]
|
|||||||
b[:]
|
b[:]
|
||||||
|
|
||||||
|
|
||||||
class _StrangeSlice():
|
class _StrangeSlice:
|
||||||
def __getitem__(self, sliced):
|
def __getitem__(self, sliced):
|
||||||
return sliced
|
return sliced
|
||||||
|
|
||||||
@@ -128,25 +128,25 @@ f
|
|||||||
# -----------------
|
# -----------------
|
||||||
# unnessecary braces
|
# unnessecary braces
|
||||||
# -----------------
|
# -----------------
|
||||||
a = (1)
|
a = 1
|
||||||
#? int()
|
#? int()
|
||||||
a
|
a
|
||||||
#? int()
|
#? int()
|
||||||
|
1
|
||||||
|
#? int()
|
||||||
(1)
|
(1)
|
||||||
#? int()
|
#? int()
|
||||||
((1))
|
(1 + 1)
|
||||||
#? int()
|
|
||||||
((1)+1)
|
|
||||||
|
|
||||||
u, v = 1, ""
|
u, v = 1, ""
|
||||||
#? int()
|
#? int()
|
||||||
u
|
u
|
||||||
|
|
||||||
((u1, v1)) = 1, ""
|
(u1, v1) = 1, ""
|
||||||
#? int()
|
#? int()
|
||||||
u1
|
u1
|
||||||
#? int()
|
#? int()
|
||||||
(u1)
|
u1
|
||||||
|
|
||||||
(a), b = 1, ''
|
(a), b = 1, ''
|
||||||
#? int()
|
#? int()
|
||||||
@@ -154,15 +154,15 @@ a
|
|||||||
|
|
||||||
def a(): return ''
|
def a(): return ''
|
||||||
#? str()
|
#? str()
|
||||||
(a)()
|
a()
|
||||||
#? str()
|
#? str()
|
||||||
(a)().replace()
|
a().replace()
|
||||||
#? int()
|
#? int()
|
||||||
(tuple).index()
|
tuple.index()
|
||||||
#? int()
|
#? int()
|
||||||
(tuple)().index()
|
tuple().index()
|
||||||
|
|
||||||
class C():
|
class C:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.a = (str()).upper()
|
self.a = (str()).upper()
|
||||||
|
|
||||||
@@ -283,14 +283,14 @@ dic2[index]
|
|||||||
# __getitem__
|
# __getitem__
|
||||||
# -----------------
|
# -----------------
|
||||||
|
|
||||||
class GetItem():
|
class GetItem:
|
||||||
def __getitem__(self, index):
|
def __getitem__(self, index):
|
||||||
return 1.0
|
return 1.0
|
||||||
|
|
||||||
#? float()
|
#? float()
|
||||||
GetItem()[0]
|
GetItem()[0]
|
||||||
|
|
||||||
class GetItem():
|
class GetItem:
|
||||||
def __init__(self, el):
|
def __init__(self, el):
|
||||||
self.el = el
|
self.el = el
|
||||||
|
|
||||||
@@ -300,7 +300,7 @@ class GetItem():
|
|||||||
#? str()
|
#? str()
|
||||||
GetItem("")[1]
|
GetItem("")[1]
|
||||||
|
|
||||||
class GetItemWithList():
|
class GetItemWithList:
|
||||||
def __getitem__(self, index):
|
def __getitem__(self, index):
|
||||||
return [1, 1.0, 's'][index]
|
return [1, 1.0, 's'][index]
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ async def x2():
|
|||||||
#? ['readlines']
|
#? ['readlines']
|
||||||
f.readlines
|
f.readlines
|
||||||
|
|
||||||
class A():
|
class A:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
async def b(c=1, d=2):
|
async def b(c=1, d=2):
|
||||||
return 1
|
return 1
|
||||||
|
|||||||
@@ -23,9 +23,9 @@ a(0):.
|
|||||||
# if/else/elif
|
# if/else/elif
|
||||||
# -----------------
|
# -----------------
|
||||||
|
|
||||||
if (random.choice([0, 1])):
|
if random.choice([0, 1]):
|
||||||
1
|
1
|
||||||
elif(random.choice([0, 1])):
|
elif random.choice([0, 1]):
|
||||||
a = 3
|
a = 3
|
||||||
else:
|
else:
|
||||||
a = ''
|
a = ''
|
||||||
@@ -34,7 +34,7 @@ a
|
|||||||
def func():
|
def func():
|
||||||
if random.choice([0, 1]):
|
if random.choice([0, 1]):
|
||||||
1
|
1
|
||||||
elif(random.choice([0, 1])):
|
elif random.choice([0, 1]):
|
||||||
a = 3
|
a = 3
|
||||||
else:
|
else:
|
||||||
a = ''
|
a = ''
|
||||||
@@ -187,7 +187,7 @@ some_word
|
|||||||
# -----------------
|
# -----------------
|
||||||
|
|
||||||
class A(object): pass
|
class A(object): pass
|
||||||
class B(): pass
|
class B: pass
|
||||||
|
|
||||||
#? ['__init__']
|
#? ['__init__']
|
||||||
A.__init__
|
A.__init__
|
||||||
@@ -201,7 +201,7 @@ int().__init__
|
|||||||
# comments
|
# comments
|
||||||
# -----------------
|
# -----------------
|
||||||
|
|
||||||
class A():
|
class A:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.hello = {} # comment shouldn't be a string
|
self.hello = {} # comment shouldn't be a string
|
||||||
#? dict()
|
#? dict()
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ def find_class():
|
|||||||
#? ['ret']
|
#? ['ret']
|
||||||
TestClass.ret
|
TestClass.ret
|
||||||
|
|
||||||
class FindClass():
|
class FindClass:
|
||||||
#? []
|
#? []
|
||||||
TestClass.ret
|
TestClass.ret
|
||||||
if a:
|
if a:
|
||||||
@@ -125,7 +125,7 @@ strs.second
|
|||||||
TestClass.var_class.var_class.var_class.var_class
|
TestClass.var_class.var_class.var_class.var_class
|
||||||
|
|
||||||
# operations (+, *, etc) shouldn't be InstanceElements - #246
|
# operations (+, *, etc) shouldn't be InstanceElements - #246
|
||||||
class A():
|
class A:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.addition = 1 + 2
|
self.addition = 1 + 2
|
||||||
#? int()
|
#? int()
|
||||||
@@ -219,7 +219,7 @@ class Dude(classgetter()):
|
|||||||
# __call__
|
# __call__
|
||||||
# -----------------
|
# -----------------
|
||||||
|
|
||||||
class CallClass():
|
class CallClass:
|
||||||
def __call__(self):
|
def __call__(self):
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
@@ -256,7 +256,7 @@ V(1).d()
|
|||||||
# -----------------
|
# -----------------
|
||||||
# ordering
|
# ordering
|
||||||
# -----------------
|
# -----------------
|
||||||
class A():
|
class A:
|
||||||
def b(self):
|
def b(self):
|
||||||
#? int()
|
#? int()
|
||||||
a_func()
|
a_func()
|
||||||
@@ -278,8 +278,8 @@ A().a_func()
|
|||||||
# -----------------
|
# -----------------
|
||||||
# nested classes
|
# nested classes
|
||||||
# -----------------
|
# -----------------
|
||||||
class A():
|
class A:
|
||||||
class B():
|
class B:
|
||||||
pass
|
pass
|
||||||
def b(self):
|
def b(self):
|
||||||
return 1.0
|
return 1.0
|
||||||
@@ -287,9 +287,9 @@ class A():
|
|||||||
#? float()
|
#? float()
|
||||||
A().b()
|
A().b()
|
||||||
|
|
||||||
class A():
|
class A:
|
||||||
def b(self):
|
def b(self):
|
||||||
class B():
|
class B:
|
||||||
def b(self):
|
def b(self):
|
||||||
return []
|
return []
|
||||||
return B().b()
|
return B().b()
|
||||||
@@ -304,7 +304,7 @@ A().b()
|
|||||||
def meth(self):
|
def meth(self):
|
||||||
return self.a, self.b
|
return self.a, self.b
|
||||||
|
|
||||||
class WithoutMethod():
|
class WithoutMethod:
|
||||||
a = 1
|
a = 1
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.b = 1.0
|
self.b = 1.0
|
||||||
@@ -312,7 +312,7 @@ class WithoutMethod():
|
|||||||
return self.b
|
return self.b
|
||||||
m = meth
|
m = meth
|
||||||
|
|
||||||
class B():
|
class B:
|
||||||
b = ''
|
b = ''
|
||||||
|
|
||||||
a = WithoutMethod().m()
|
a = WithoutMethod().m()
|
||||||
@@ -348,18 +348,18 @@ getattr(getattr, 1)
|
|||||||
getattr(str, [])
|
getattr(str, [])
|
||||||
|
|
||||||
|
|
||||||
class Base():
|
class Base:
|
||||||
def ret(self, b):
|
def ret(self, b):
|
||||||
return b
|
return b
|
||||||
|
|
||||||
class Wrapper():
|
class Wrapper:
|
||||||
def __init__(self, obj):
|
def __init__(self, obj):
|
||||||
self.obj = obj
|
self.obj = obj
|
||||||
|
|
||||||
def __getattr__(self, name):
|
def __getattr__(self, name):
|
||||||
return getattr(self.obj, name)
|
return getattr(self.obj, name)
|
||||||
|
|
||||||
class Wrapper2():
|
class Wrapper2:
|
||||||
def __getattribute__(self, name):
|
def __getattribute__(self, name):
|
||||||
return getattr(Base(), name)
|
return getattr(Base(), name)
|
||||||
|
|
||||||
@@ -369,7 +369,7 @@ Wrapper(Base()).ret(3)
|
|||||||
#? int()
|
#? int()
|
||||||
Wrapper2(Base()).ret(3)
|
Wrapper2(Base()).ret(3)
|
||||||
|
|
||||||
class GetattrArray():
|
class GetattrArray:
|
||||||
def __getattr__(self, name):
|
def __getattr__(self, name):
|
||||||
return [1]
|
return [1]
|
||||||
|
|
||||||
@@ -380,7 +380,7 @@ GetattrArray().something[0]
|
|||||||
# -----------------
|
# -----------------
|
||||||
# private vars
|
# private vars
|
||||||
# -----------------
|
# -----------------
|
||||||
class PrivateVar():
|
class PrivateVar:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.__var = 1
|
self.__var = 1
|
||||||
#? int()
|
#? int()
|
||||||
@@ -517,7 +517,7 @@ Config.mode2
|
|||||||
class Foo(object):
|
class Foo(object):
|
||||||
a = 3
|
a = 3
|
||||||
def create_class(self):
|
def create_class(self):
|
||||||
class X():
|
class X:
|
||||||
a = self.a
|
a = self.a
|
||||||
self.b = 3.0
|
self.b = 3.0
|
||||||
return X
|
return X
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ foo[1]
|
|||||||
# In class
|
# In class
|
||||||
# -----------------
|
# -----------------
|
||||||
|
|
||||||
class X():
|
class X:
|
||||||
def __init__(self, bar):
|
def __init__(self, bar):
|
||||||
self.bar = bar
|
self.bar = bar
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class Base():
|
class Base:
|
||||||
myfoobar = 3
|
myfoobar = 3
|
||||||
|
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ myfoobar
|
|||||||
# Inheritance
|
# Inheritance
|
||||||
# -----------------
|
# -----------------
|
||||||
|
|
||||||
class Super():
|
class Super:
|
||||||
enabled = True
|
enabled = True
|
||||||
if enabled:
|
if enabled:
|
||||||
yo_dude = 4
|
yo_dude = 4
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ def nothing(a,b,c):
|
|||||||
#? int()
|
#? int()
|
||||||
nothing("")[0]
|
nothing("")[0]
|
||||||
|
|
||||||
class MethodDecoratorAsClass():
|
class MethodDecoratorAsClass:
|
||||||
class_var = 3
|
class_var = 3
|
||||||
@Decorator
|
@Decorator
|
||||||
def func_without_self(arg, arg2):
|
def func_without_self(arg, arg2):
|
||||||
@@ -124,7 +124,7 @@ MethodDecoratorAsClass().func_without_self('')[1]
|
|||||||
MethodDecoratorAsClass().func_with_self(1)
|
MethodDecoratorAsClass().func_with_self(1)
|
||||||
|
|
||||||
|
|
||||||
class SelfVars():
|
class SelfVars:
|
||||||
"""Init decorator problem as an instance, #247"""
|
"""Init decorator problem as an instance, #247"""
|
||||||
@Decorator
|
@Decorator
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@@ -181,7 +181,7 @@ JustAClass.a()
|
|||||||
# illegal decorators
|
# illegal decorators
|
||||||
# -----------------
|
# -----------------
|
||||||
|
|
||||||
class DecoratorWithoutCall():
|
class DecoratorWithoutCall:
|
||||||
def __init__(self, func):
|
def __init__(self, func):
|
||||||
self.func = func
|
self.func = func
|
||||||
|
|
||||||
@@ -200,7 +200,7 @@ f()
|
|||||||
g()
|
g()
|
||||||
|
|
||||||
|
|
||||||
class X():
|
class X:
|
||||||
@str
|
@str
|
||||||
def x(self):
|
def x(self):
|
||||||
pass
|
pass
|
||||||
@@ -220,7 +220,7 @@ def dec(f):
|
|||||||
return f(s)
|
return f(s)
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
class MethodDecorators():
|
class MethodDecorators:
|
||||||
_class_var = 1
|
_class_var = 1
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._method_var = ''
|
self._method_var = ''
|
||||||
@@ -245,7 +245,7 @@ MethodDecorators().class_var()
|
|||||||
MethodDecorators().method_var()
|
MethodDecorators().method_var()
|
||||||
|
|
||||||
|
|
||||||
class Base():
|
class Base:
|
||||||
@not_existing
|
@not_existing
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
@@ -298,7 +298,7 @@ follow_statement(1)
|
|||||||
|
|
||||||
# class decorators should just be ignored
|
# class decorators should just be ignored
|
||||||
@should_ignore
|
@should_ignore
|
||||||
class A():
|
class A:
|
||||||
def ret(self):
|
def ret(self):
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ C.just_a_method
|
|||||||
# -----------------
|
# -----------------
|
||||||
# properties
|
# properties
|
||||||
# -----------------
|
# -----------------
|
||||||
class B():
|
class B:
|
||||||
@property
|
@property
|
||||||
def r(self):
|
def r(self):
|
||||||
return 1
|
return 1
|
||||||
@@ -71,7 +71,7 @@ B().p
|
|||||||
#? []
|
#? []
|
||||||
B().p().
|
B().p().
|
||||||
|
|
||||||
class PropClass():
|
class PropClass:
|
||||||
def __init__(self, a):
|
def __init__(self, a):
|
||||||
self.a = a
|
self.a = a
|
||||||
@property
|
@property
|
||||||
@@ -190,7 +190,7 @@ E.u(1)
|
|||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
|
|
||||||
class Memoize():
|
class Memoize:
|
||||||
def __init__(self, func):
|
def __init__(self, func):
|
||||||
self.func = func
|
self.func = func
|
||||||
|
|
||||||
@@ -205,7 +205,7 @@ class Memoize():
|
|||||||
return self.func(*args, **kwargs)
|
return self.func(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class MemoizeTest():
|
class MemoizeTest:
|
||||||
def __init__(self, x):
|
def __init__(self, x):
|
||||||
self.x = x
|
self.x = x
|
||||||
|
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ def sphinxy_param_type_wrapped(a):
|
|||||||
|
|
||||||
|
|
||||||
# local classes -> github #370
|
# local classes -> github #370
|
||||||
class ProgramNode():
|
class ProgramNode:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def local_classes(node, node2):
|
def local_classes(node, node2):
|
||||||
@@ -75,7 +75,7 @@ def local_classes(node, node2):
|
|||||||
#? ProgramNode2()
|
#? ProgramNode2()
|
||||||
node2
|
node2
|
||||||
|
|
||||||
class ProgramNode2():
|
class ProgramNode2:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@@ -193,7 +193,7 @@ d.upper()
|
|||||||
# class docstrings
|
# class docstrings
|
||||||
# -----------------
|
# -----------------
|
||||||
|
|
||||||
class InInit():
|
class InInit:
|
||||||
def __init__(self, foo):
|
def __init__(self, foo):
|
||||||
"""
|
"""
|
||||||
:type foo: str
|
:type foo: str
|
||||||
@@ -202,7 +202,7 @@ class InInit():
|
|||||||
foo
|
foo
|
||||||
|
|
||||||
|
|
||||||
class InClass():
|
class InClass:
|
||||||
"""
|
"""
|
||||||
:type foo: str
|
:type foo: str
|
||||||
"""
|
"""
|
||||||
@@ -211,7 +211,7 @@ class InClass():
|
|||||||
foo
|
foo
|
||||||
|
|
||||||
|
|
||||||
class InBoth():
|
class InBoth:
|
||||||
"""
|
"""
|
||||||
:type foo: str
|
:type foo: str
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -112,9 +112,9 @@ iter(lst)[0]
|
|||||||
# -----------------
|
# -----------------
|
||||||
# complex including +=
|
# complex including +=
|
||||||
# -----------------
|
# -----------------
|
||||||
class C(): pass
|
class C: pass
|
||||||
class D(): pass
|
class D: pass
|
||||||
class E(): pass
|
class E: pass
|
||||||
lst = [1]
|
lst = [1]
|
||||||
lst.append(1.0)
|
lst.append(1.0)
|
||||||
lst += [C]
|
lst += [C]
|
||||||
@@ -207,7 +207,7 @@ blub()[0]
|
|||||||
# -----------------
|
# -----------------
|
||||||
# returns, the same for classes
|
# returns, the same for classes
|
||||||
# -----------------
|
# -----------------
|
||||||
class C():
|
class C:
|
||||||
def blub(self, b):
|
def blub(self, b):
|
||||||
if 1:
|
if 1:
|
||||||
a = []
|
a = []
|
||||||
|
|||||||
@@ -90,14 +90,14 @@ func.sys
|
|||||||
# classes
|
# classes
|
||||||
# -----------------
|
# -----------------
|
||||||
|
|
||||||
class A():
|
class A:
|
||||||
def __init__(self, a):
|
def __init__(self, a):
|
||||||
#? str()
|
#? str()
|
||||||
a
|
a
|
||||||
|
|
||||||
A("s")
|
A("s")
|
||||||
|
|
||||||
class A():
|
class A:
|
||||||
def __init__(self, a):
|
def __init__(self, a):
|
||||||
#? int()
|
#? int()
|
||||||
a
|
a
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ a
|
|||||||
# isinstance
|
# isinstance
|
||||||
# -----------------
|
# -----------------
|
||||||
|
|
||||||
class A(): pass
|
class A: pass
|
||||||
|
|
||||||
def isinst(x):
|
def isinst(x):
|
||||||
if isinstance(x, A):
|
if isinstance(x, A):
|
||||||
@@ -251,7 +251,7 @@ if False:
|
|||||||
# True objects like modules
|
# True objects like modules
|
||||||
# -----------------
|
# -----------------
|
||||||
|
|
||||||
class X():
|
class X:
|
||||||
pass
|
pass
|
||||||
if X:
|
if X:
|
||||||
a = 1
|
a = 1
|
||||||
|
|||||||
@@ -285,7 +285,7 @@ def memoize(func):
|
|||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
|
|
||||||
class Something():
|
class Something:
|
||||||
@memoize
|
@memoize
|
||||||
def x(self, a, b=1):
|
def x(self, a, b=1):
|
||||||
return a
|
return a
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ for a in get():
|
|||||||
a
|
a
|
||||||
|
|
||||||
|
|
||||||
class Get():
|
class Get:
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
if random.choice([0, 1]):
|
if random.choice([0, 1]):
|
||||||
yield 1
|
yield 1
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ c
|
|||||||
c()
|
c()
|
||||||
|
|
||||||
|
|
||||||
class ClassVar():
|
class ClassVar:
|
||||||
x = 3
|
x = 3
|
||||||
|
|
||||||
#! ['x = 3']
|
#! ['x = 3']
|
||||||
@@ -103,7 +103,7 @@ def f(t=None):
|
|||||||
t = t or 1
|
t = t or 1
|
||||||
|
|
||||||
|
|
||||||
class X():
|
class X:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#! 3 []
|
#! 3 []
|
||||||
@@ -158,7 +158,7 @@ from . import some_variable
|
|||||||
# anonymous classes
|
# anonymous classes
|
||||||
# -----------------
|
# -----------------
|
||||||
def func():
|
def func():
|
||||||
class A():
|
class A:
|
||||||
def b(self):
|
def b(self):
|
||||||
return 1
|
return 1
|
||||||
return A()
|
return A()
|
||||||
@@ -171,7 +171,7 @@ func().b()
|
|||||||
# -----------------
|
# -----------------
|
||||||
|
|
||||||
#! 7 ['class ClassDef']
|
#! 7 ['class ClassDef']
|
||||||
class ClassDef():
|
class ClassDef:
|
||||||
""" abc """
|
""" abc """
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -216,7 +216,7 @@ def dec(dec_param=3):
|
|||||||
def y():
|
def y():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class ClassDec():
|
class ClassDec:
|
||||||
def class_func(func):
|
def class_func(func):
|
||||||
return func
|
return func
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
blub = 1
|
blub = 1
|
||||||
|
|
||||||
class Config2():
|
class Config2:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class BaseClass():
|
class BaseClass:
|
||||||
mode = Config2()
|
mode = Config2()
|
||||||
if isinstance(whaat, int):
|
if isinstance(whaat, int):
|
||||||
mode2 = whaat
|
mode2 = whaat
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ invalid
|
|||||||
# classes
|
# classes
|
||||||
# -----------------
|
# -----------------
|
||||||
|
|
||||||
class BrokenPartsOfClass():
|
class BrokenPartsOfClass:
|
||||||
def foo(self):
|
def foo(self):
|
||||||
# This construct contains two places where Jedi with Python 3 can fail.
|
# This construct contains two places where Jedi with Python 3 can fail.
|
||||||
# It should just ignore those constructs and still execute `bar`.
|
# It should just ignore those constructs and still execute `bar`.
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ def isinstance_func(arr):
|
|||||||
# Names with multiple indices.
|
# Names with multiple indices.
|
||||||
# -----------------
|
# -----------------
|
||||||
|
|
||||||
class Test():
|
class Test:
|
||||||
def __init__(self, testing):
|
def __init__(self, testing):
|
||||||
if isinstance(testing, str):
|
if isinstance(testing, str):
|
||||||
self.testing = testing
|
self.testing = testing
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ a = lambda: 3
|
|||||||
#? ['__closure__']
|
#? ['__closure__']
|
||||||
a.__closure__
|
a.__closure__
|
||||||
|
|
||||||
class C():
|
class C:
|
||||||
def __init__(self, foo=1.0):
|
def __init__(self, foo=1.0):
|
||||||
self.a = lambda: 1
|
self.a = lambda: 1
|
||||||
self.foo = foo
|
self.foo = foo
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ a.real
|
|||||||
a.a
|
a.a
|
||||||
|
|
||||||
a = 3
|
a = 3
|
||||||
class a():
|
class a:
|
||||||
def __init__(self, a):
|
def __init__(self, a):
|
||||||
self.a = a
|
self.a = a
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
Issues with the parser and not the type inference should be part of this file.
|
Issues with the parser and not the type inference should be part of this file.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
class IndentIssues():
|
class IndentIssues:
|
||||||
"""
|
"""
|
||||||
issue jedi-vim#288
|
issue jedi-vim#288
|
||||||
Which is really a fast parser issue. It used to start a new block at the
|
Which is really a fast parser issue. It used to start a new block at the
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
# python >= 3.2
|
# python >= 3.2
|
||||||
|
|
||||||
|
|
||||||
class A():
|
class A:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ Recursion().a
|
|||||||
Recursion().b
|
Recursion().b
|
||||||
|
|
||||||
|
|
||||||
class X():
|
class X:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.recursive = [1, 3]
|
self.recursive = [1, 3]
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ def recursion1(foo):
|
|||||||
recursion1([1,2])[0]
|
recursion1([1,2])[0]
|
||||||
|
|
||||||
|
|
||||||
class FooListComp():
|
class FooListComp:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.recursive = [1]
|
self.recursive = [1]
|
||||||
|
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ import math
|
|||||||
import os
|
import os
|
||||||
#? type(os)
|
#? type(os)
|
||||||
type(math)
|
type(math)
|
||||||
class X(): pass
|
class X: pass
|
||||||
#? type
|
#? type
|
||||||
type(X)
|
type(X)
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ abc = 5
|
|||||||
Abc = 3
|
Abc = 3
|
||||||
|
|
||||||
#< 6 (0,6), (2,4), (5,8), (17,0)
|
#< 6 (0,6), (2,4), (5,8), (17,0)
|
||||||
class Abc():
|
class Abc:
|
||||||
#< (-2,6), (0,4), (3,8), (15,0)
|
#< (-2,6), (0,4), (3,8), (15,0)
|
||||||
Abc
|
Abc
|
||||||
|
|
||||||
@@ -132,7 +132,7 @@ class TestClassVar(object):
|
|||||||
#< (0,8), (-7, 8)
|
#< (0,8), (-7, 8)
|
||||||
class_v
|
class_v
|
||||||
|
|
||||||
class TestInstanceVar():
|
class TestInstanceVar:
|
||||||
def a(self):
|
def a(self):
|
||||||
#< 13 (4,13), (0,13)
|
#< 13 (4,13), (0,13)
|
||||||
self._instance_var = 3
|
self._instance_var = 3
|
||||||
@@ -145,7 +145,7 @@ class TestInstanceVar():
|
|||||||
self()
|
self()
|
||||||
|
|
||||||
|
|
||||||
class NestedClass():
|
class NestedClass:
|
||||||
def __getattr__(self, name):
|
def __getattr__(self, name):
|
||||||
return self
|
return self
|
||||||
|
|
||||||
@@ -249,7 +249,7 @@ if isinstance(j, int):
|
|||||||
# Dynamic Param Search
|
# Dynamic Param Search
|
||||||
# -----------------
|
# -----------------
|
||||||
|
|
||||||
class DynamicParam():
|
class DynamicParam:
|
||||||
def foo(self):
|
def foo(self):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@@ -41,9 +41,9 @@ def parse_test_files_option(opt):
|
|||||||
opt = str(opt)
|
opt = str(opt)
|
||||||
if ':' in opt:
|
if ':' in opt:
|
||||||
(f_name, rest) = opt.split(':', 1)
|
(f_name, rest) = opt.split(':', 1)
|
||||||
return (f_name, list(map(int, rest.split(','))))
|
return f_name, list(map(int, rest.split(',')))
|
||||||
else:
|
else:
|
||||||
return (opt, [])
|
return opt, []
|
||||||
|
|
||||||
|
|
||||||
def pytest_generate_tests(metafunc):
|
def pytest_generate_tests(metafunc):
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
class Cls():
|
class Cls:
|
||||||
class_attr = ''
|
class_attr = ''
|
||||||
def __init__(self, input):
|
def __init__(self, input):
|
||||||
self.instance_attr = 3
|
self.instance_attr = 3
|
||||||
@@ -77,7 +77,7 @@ return_one(''.undefined_attribute)
|
|||||||
[r for r in [1, 2]]
|
[r for r in [1, 2]]
|
||||||
|
|
||||||
# some random error that showed up
|
# some random error that showed up
|
||||||
class NotCalled():
|
class NotCalled:
|
||||||
def match_something(self, param):
|
def match_something(self, param):
|
||||||
seems_to_need_an_assignment = param
|
seems_to_need_an_assignment = param
|
||||||
return [value.match_something() for value in []]
|
return [value.match_something() for value in []]
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ Jedi issues warnings for possible errors if ``__getattr__``,
|
|||||||
# -----------------
|
# -----------------
|
||||||
|
|
||||||
|
|
||||||
class Cls():
|
class Cls:
|
||||||
def __getattr__(self, name):
|
def __getattr__(self, name):
|
||||||
return getattr(str, name)
|
return getattr(str, name)
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@ Inherited().undefined
|
|||||||
# -----------------
|
# -----------------
|
||||||
|
|
||||||
|
|
||||||
class SetattrCls():
|
class SetattrCls:
|
||||||
def __init__(self, dct):
|
def __init__(self, dct):
|
||||||
# Jedi doesn't even try to understand such code
|
# Jedi doesn't even try to understand such code
|
||||||
for k, v in dct.items():
|
for k, v in dct.items():
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
class Base(object):
|
class Base(object):
|
||||||
class Nested():
|
class Nested:
|
||||||
def foo():
|
def foo():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# classmethod
|
# classmethod
|
||||||
class TarFile():
|
class TarFile:
|
||||||
@classmethod
|
@classmethod
|
||||||
def open(cls, name, **kwargs):
|
def open(cls, name, **kwargs):
|
||||||
return cls.taropen(name, **kwargs)
|
return cls.taropen(name, **kwargs)
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ default(x=1)
|
|||||||
# class arguments
|
# class arguments
|
||||||
# -----------------
|
# -----------------
|
||||||
|
|
||||||
class Instance():
|
class Instance:
|
||||||
def __init__(self, foo):
|
def __init__(self, foo):
|
||||||
self.foo = foo
|
self.foo = foo
|
||||||
|
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ mixed2(3, b=5)
|
|||||||
simple(1, **[])
|
simple(1, **[])
|
||||||
#! 12 type-error-star-star
|
#! 12 type-error-star-star
|
||||||
simple(1, **1)
|
simple(1, **1)
|
||||||
class A(): pass
|
class A: pass
|
||||||
#! 12 type-error-star-star
|
#! 12 type-error-star-star
|
||||||
simple(1, **A())
|
simple(1, **A())
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ except (TypeError, NotImplementedError): pass
|
|||||||
# -----------------
|
# -----------------
|
||||||
try:
|
try:
|
||||||
str.not_existing
|
str.not_existing
|
||||||
except ((AttributeError)): pass
|
except (AttributeError): pass
|
||||||
try:
|
try:
|
||||||
#! 4 attribute-error
|
#! 4 attribute-error
|
||||||
str.not_existing
|
str.not_existing
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ else:
|
|||||||
exec source in global_map """, 'blub', 'exec'))
|
exec source in global_map """, 'blub', 'exec'))
|
||||||
|
|
||||||
|
|
||||||
class _GlobalNameSpace():
|
class _GlobalNameSpace:
|
||||||
class SideEffectContainer():
|
class SideEffectContainer:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@@ -80,7 +80,7 @@ def test_numpy_like_non_zero():
|
|||||||
|
|
||||||
|
|
||||||
def test_nested_resolve():
|
def test_nested_resolve():
|
||||||
class XX():
|
class XX:
|
||||||
def x():
|
def x():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -168,7 +168,7 @@ def test_list():
|
|||||||
|
|
||||||
|
|
||||||
def test_slice():
|
def test_slice():
|
||||||
class Foo1():
|
class Foo1:
|
||||||
bar = []
|
bar = []
|
||||||
baz = 'xbarx'
|
baz = 'xbarx'
|
||||||
_assert_interpreter_complete('getattr(Foo1, baz[1:-1]).append',
|
_assert_interpreter_complete('getattr(Foo1, baz[1:-1]).append',
|
||||||
@@ -177,7 +177,7 @@ def test_slice():
|
|||||||
|
|
||||||
|
|
||||||
def test_getitem_side_effects():
|
def test_getitem_side_effects():
|
||||||
class Foo2():
|
class Foo2:
|
||||||
def __getitem__(self, index):
|
def __getitem__(self, index):
|
||||||
# Possible side effects here, should therefore not call this.
|
# Possible side effects here, should therefore not call this.
|
||||||
if True:
|
if True:
|
||||||
@@ -190,7 +190,7 @@ def test_getitem_side_effects():
|
|||||||
|
|
||||||
def test_property_error_oldstyle():
|
def test_property_error_oldstyle():
|
||||||
lst = []
|
lst = []
|
||||||
class Foo3():
|
class Foo3:
|
||||||
@property
|
@property
|
||||||
def bar(self):
|
def bar(self):
|
||||||
lst.append(1)
|
lst.append(1)
|
||||||
@@ -269,7 +269,7 @@ def test_more_complex_instances():
|
|||||||
def foo(self, other):
|
def foo(self, other):
|
||||||
return self
|
return self
|
||||||
|
|
||||||
class Base():
|
class Base:
|
||||||
def wow(self):
|
def wow(self):
|
||||||
return Something()
|
return Something()
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ from parso.python import tree
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
class TestCallAndName():
|
class TestCallAndName:
|
||||||
def get_call(self, source):
|
def get_call(self, source):
|
||||||
# Get the simple_stmt and then the first one.
|
# Get the simple_stmt and then the first one.
|
||||||
node = parse(source).children[0]
|
node = parse(source).children[0]
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ class TestSpeed(TestCase):
|
|||||||
unwanted computation of repr(). Exemple : big pandas data.
|
unwanted computation of repr(). Exemple : big pandas data.
|
||||||
See issue #919.
|
See issue #919.
|
||||||
"""
|
"""
|
||||||
class SlowRepr():
|
class SlowRepr:
|
||||||
"class to test what happens if __repr__ is very slow."
|
"class to test what happens if __repr__ is very slow."
|
||||||
def some_method(self):
|
def some_method(self):
|
||||||
pass
|
pass
|
||||||
|
|||||||
Reference in New Issue
Block a user