Remove redundant parentheses

This commit is contained in:
Hugo
2018-01-04 16:32:52 +02:00
parent a7ac647498
commit 8cf708d0d4
41 changed files with 112 additions and 112 deletions

View File

@@ -132,7 +132,7 @@ def find_module_pre_py33(string, path=None, fullname=None):
file = None
if not is_package or is_archive:
file = DummyFile(loader, string)
return (file, module_path, is_package)
return file, module_path, is_package
except ImportError:
pass
raise ImportError("No module named {}".format(string))

View File

@@ -555,7 +555,7 @@ class Definition(BaseDefinition):
.. todo:: Add full path. This function is should return a
`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)
@memoize_method

View File

@@ -432,7 +432,7 @@ def dotted_from_fs_path(fs_path, sys_path):
# C:\path\to\Lib
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
# - Window

View File

@@ -87,7 +87,7 @@ else:
return getattr(klass, '__dict__', _sentinel)
return _shadowed_dict_newstyle(klass)
class _OldStyleClass():
class _OldStyleClass:
pass
_oldstyle_instance_type = type(_OldStyleClass())
@@ -122,7 +122,7 @@ def _safe_hasattr(obj, name):
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):

View File

@@ -64,7 +64,7 @@ class MixedName(compiled.CompiledName):
contexts = list(self.infer())
if not contexts:
# This means a start_pos that doesn't exist (compiled objects).
return (0, 0)
return 0, 0
return contexts[0].name.start_pos
@start_pos.setter

View File

@@ -43,7 +43,7 @@ b[int():]
b[:]
class _StrangeSlice():
class _StrangeSlice:
def __getitem__(self, sliced):
return sliced
@@ -128,25 +128,25 @@ f
# -----------------
# unnessecary braces
# -----------------
a = (1)
a = 1
#? int()
a
#? int()
1
#? int()
(1)
#? int()
((1))
#? int()
((1)+1)
(1 + 1)
u, v = 1, ""
#? int()
u
((u1, v1)) = 1, ""
(u1, v1) = 1, ""
#? int()
u1
#? int()
(u1)
u1
(a), b = 1, ''
#? int()
@@ -154,15 +154,15 @@ a
def a(): return ''
#? str()
(a)()
a()
#? str()
(a)().replace()
a().replace()
#? int()
(tuple).index()
tuple.index()
#? int()
(tuple)().index()
tuple().index()
class C():
class C:
def __init__(self):
self.a = (str()).upper()
@@ -283,14 +283,14 @@ dic2[index]
# __getitem__
# -----------------
class GetItem():
class GetItem:
def __getitem__(self, index):
return 1.0
#? float()
GetItem()[0]
class GetItem():
class GetItem:
def __init__(self, el):
self.el = el
@@ -300,7 +300,7 @@ class GetItem():
#? str()
GetItem("")[1]
class GetItemWithList():
class GetItemWithList:
def __getitem__(self, index):
return [1, 1.0, 's'][index]

View File

@@ -24,7 +24,7 @@ async def x2():
#? ['readlines']
f.readlines
class A():
class A:
@staticmethod
async def b(c=1, d=2):
return 1

View File

@@ -23,9 +23,9 @@ a(0):.
# if/else/elif
# -----------------
if (random.choice([0, 1])):
if random.choice([0, 1]):
1
elif(random.choice([0, 1])):
elif random.choice([0, 1]):
a = 3
else:
a = ''
@@ -34,7 +34,7 @@ a
def func():
if random.choice([0, 1]):
1
elif(random.choice([0, 1])):
elif random.choice([0, 1]):
a = 3
else:
a = ''
@@ -187,7 +187,7 @@ some_word
# -----------------
class A(object): pass
class B(): pass
class B: pass
#? ['__init__']
A.__init__
@@ -201,7 +201,7 @@ int().__init__
# comments
# -----------------
class A():
class A:
def __init__(self):
self.hello = {} # comment shouldn't be a string
#? dict()

View File

@@ -6,7 +6,7 @@ def find_class():
#? ['ret']
TestClass.ret
class FindClass():
class FindClass:
#? []
TestClass.ret
if a:
@@ -125,7 +125,7 @@ strs.second
TestClass.var_class.var_class.var_class.var_class
# operations (+, *, etc) shouldn't be InstanceElements - #246
class A():
class A:
def __init__(self):
self.addition = 1 + 2
#? int()
@@ -219,7 +219,7 @@ class Dude(classgetter()):
# __call__
# -----------------
class CallClass():
class CallClass:
def __call__(self):
return 1
@@ -256,7 +256,7 @@ V(1).d()
# -----------------
# ordering
# -----------------
class A():
class A:
def b(self):
#? int()
a_func()
@@ -278,8 +278,8 @@ A().a_func()
# -----------------
# nested classes
# -----------------
class A():
class B():
class A:
class B:
pass
def b(self):
return 1.0
@@ -287,9 +287,9 @@ class A():
#? float()
A().b()
class A():
class A:
def b(self):
class B():
class B:
def b(self):
return []
return B().b()
@@ -304,7 +304,7 @@ A().b()
def meth(self):
return self.a, self.b
class WithoutMethod():
class WithoutMethod:
a = 1
def __init__(self):
self.b = 1.0
@@ -312,7 +312,7 @@ class WithoutMethod():
return self.b
m = meth
class B():
class B:
b = ''
a = WithoutMethod().m()
@@ -348,18 +348,18 @@ getattr(getattr, 1)
getattr(str, [])
class Base():
class Base:
def ret(self, b):
return b
class Wrapper():
class Wrapper:
def __init__(self, obj):
self.obj = obj
def __getattr__(self, name):
return getattr(self.obj, name)
class Wrapper2():
class Wrapper2:
def __getattribute__(self, name):
return getattr(Base(), name)
@@ -369,7 +369,7 @@ Wrapper(Base()).ret(3)
#? int()
Wrapper2(Base()).ret(3)
class GetattrArray():
class GetattrArray:
def __getattr__(self, name):
return [1]
@@ -380,7 +380,7 @@ GetattrArray().something[0]
# -----------------
# private vars
# -----------------
class PrivateVar():
class PrivateVar:
def __init__(self):
self.__var = 1
#? int()
@@ -517,7 +517,7 @@ Config.mode2
class Foo(object):
a = 3
def create_class(self):
class X():
class X:
a = self.a
self.b = 3.0
return X

View File

@@ -154,7 +154,7 @@ foo[1]
# In class
# -----------------
class X():
class X:
def __init__(self, bar):
self.bar = bar

View File

@@ -1,4 +1,4 @@
class Base():
class Base:
myfoobar = 3
@@ -35,7 +35,7 @@ myfoobar
# Inheritance
# -----------------
class Super():
class Super:
enabled = True
if enabled:
yo_dude = 4

View File

@@ -106,7 +106,7 @@ def nothing(a,b,c):
#? int()
nothing("")[0]
class MethodDecoratorAsClass():
class MethodDecoratorAsClass:
class_var = 3
@Decorator
def func_without_self(arg, arg2):
@@ -124,7 +124,7 @@ MethodDecoratorAsClass().func_without_self('')[1]
MethodDecoratorAsClass().func_with_self(1)
class SelfVars():
class SelfVars:
"""Init decorator problem as an instance, #247"""
@Decorator
def __init__(self):
@@ -181,7 +181,7 @@ JustAClass.a()
# illegal decorators
# -----------------
class DecoratorWithoutCall():
class DecoratorWithoutCall:
def __init__(self, func):
self.func = func
@@ -200,7 +200,7 @@ f()
g()
class X():
class X:
@str
def x(self):
pass
@@ -220,7 +220,7 @@ def dec(f):
return f(s)
return wrapper
class MethodDecorators():
class MethodDecorators:
_class_var = 1
def __init__(self):
self._method_var = ''
@@ -245,7 +245,7 @@ MethodDecorators().class_var()
MethodDecorators().method_var()
class Base():
class Base:
@not_existing
def __init__(self):
pass
@@ -298,7 +298,7 @@ follow_statement(1)
# class decorators should just be ignored
@should_ignore
class A():
class A:
def ret(self):
return 1

View File

@@ -50,7 +50,7 @@ C.just_a_method
# -----------------
# properties
# -----------------
class B():
class B:
@property
def r(self):
return 1
@@ -71,7 +71,7 @@ B().p
#? []
B().p().
class PropClass():
class PropClass:
def __init__(self, a):
self.a = a
@property
@@ -190,7 +190,7 @@ E.u(1)
from functools import partial
class Memoize():
class Memoize:
def __init__(self, func):
self.func = func
@@ -205,7 +205,7 @@ class Memoize():
return self.func(*args, **kwargs)
class MemoizeTest():
class MemoizeTest:
def __init__(self, x):
self.x = x

View File

@@ -61,7 +61,7 @@ def sphinxy_param_type_wrapped(a):
# local classes -> github #370
class ProgramNode():
class ProgramNode:
pass
def local_classes(node, node2):
@@ -75,7 +75,7 @@ def local_classes(node, node2):
#? ProgramNode2()
node2
class ProgramNode2():
class ProgramNode2:
pass
@@ -193,7 +193,7 @@ d.upper()
# class docstrings
# -----------------
class InInit():
class InInit:
def __init__(self, foo):
"""
:type foo: str
@@ -202,7 +202,7 @@ class InInit():
foo
class InClass():
class InClass:
"""
:type foo: str
"""
@@ -211,7 +211,7 @@ class InClass():
foo
class InBoth():
class InBoth:
"""
:type foo: str
"""

View File

@@ -112,9 +112,9 @@ iter(lst)[0]
# -----------------
# complex including +=
# -----------------
class C(): pass
class D(): pass
class E(): pass
class C: pass
class D: pass
class E: pass
lst = [1]
lst.append(1.0)
lst += [C]
@@ -207,7 +207,7 @@ blub()[0]
# -----------------
# returns, the same for classes
# -----------------
class C():
class C:
def blub(self, b):
if 1:
a = []

View File

@@ -90,14 +90,14 @@ func.sys
# classes
# -----------------
class A():
class A:
def __init__(self, a):
#? str()
a
A("s")
class A():
class A:
def __init__(self, a):
#? int()
a

View File

@@ -191,7 +191,7 @@ a
# isinstance
# -----------------
class A(): pass
class A: pass
def isinst(x):
if isinstance(x, A):
@@ -251,7 +251,7 @@ if False:
# True objects like modules
# -----------------
class X():
class X:
pass
if X:
a = 1

View File

@@ -285,7 +285,7 @@ def memoize(func):
return wrapper
class Something():
class Something:
@memoize
def x(self, a, b=1):
return a

View File

@@ -52,7 +52,7 @@ for a in get():
a
class Get():
class Get:
def __iter__(self):
if random.choice([0, 1]):
yield 1

View File

@@ -83,7 +83,7 @@ c
c()
class ClassVar():
class ClassVar:
x = 3
#! ['x = 3']
@@ -103,7 +103,7 @@ def f(t=None):
t = t or 1
class X():
class X:
pass
#! 3 []
@@ -158,7 +158,7 @@ from . import some_variable
# anonymous classes
# -----------------
def func():
class A():
class A:
def b(self):
return 1
return A()
@@ -171,7 +171,7 @@ func().b()
# -----------------
#! 7 ['class ClassDef']
class ClassDef():
class ClassDef:
""" abc """
pass
@@ -216,7 +216,7 @@ def dec(dec_param=3):
def y():
pass
class ClassDec():
class ClassDec:
def class_func(func):
return func

View File

@@ -1,10 +1,10 @@
blub = 1
class Config2():
class Config2:
pass
class BaseClass():
class BaseClass:
mode = Config2()
if isinstance(whaat, int):
mode2 = whaat

View File

@@ -193,7 +193,7 @@ invalid
# classes
# -----------------
class BrokenPartsOfClass():
class BrokenPartsOfClass:
def foo(self):
# This construct contains two places where Jedi with Python 3 can fail.
# It should just ignore those constructs and still execute `bar`.

View File

@@ -78,7 +78,7 @@ def isinstance_func(arr):
# Names with multiple indices.
# -----------------
class Test():
class Test:
def __init__(self, testing):
if isinstance(testing, str):
self.testing = testing

View File

@@ -54,7 +54,7 @@ a = lambda: 3
#? ['__closure__']
a.__closure__
class C():
class C:
def __init__(self, foo=1.0):
self.a = lambda: 1
self.foo = foo

View File

@@ -157,7 +157,7 @@ a.real
a.a
a = 3
class a():
class a:
def __init__(self, a):
self.a = a

View File

@@ -2,7 +2,7 @@
Issues with the parser and not the type inference should be part of this file.
"""
class IndentIssues():
class IndentIssues:
"""
issue jedi-vim#288
Which is really a fast parser issue. It used to start a new block at the

View File

@@ -3,7 +3,7 @@
# python >= 3.2
class A():
class A:
pass

View File

@@ -14,7 +14,7 @@ Recursion().a
Recursion().b
class X():
class X:
def __init__(self):
self.recursive = [1, 3]
@@ -39,7 +39,7 @@ def recursion1(foo):
recursion1([1,2])[0]
class FooListComp():
class FooListComp:
def __init__(self):
self.recursive = [1]

View File

@@ -61,7 +61,7 @@ import math
import os
#? type(os)
type(math)
class X(): pass
class X: pass
#? type
type(X)

View File

@@ -29,7 +29,7 @@ abc = 5
Abc = 3
#< 6 (0,6), (2,4), (5,8), (17,0)
class Abc():
class Abc:
#< (-2,6), (0,4), (3,8), (15,0)
Abc
@@ -132,7 +132,7 @@ class TestClassVar(object):
#< (0,8), (-7, 8)
class_v
class TestInstanceVar():
class TestInstanceVar:
def a(self):
#< 13 (4,13), (0,13)
self._instance_var = 3
@@ -145,7 +145,7 @@ class TestInstanceVar():
self()
class NestedClass():
class NestedClass:
def __getattr__(self, name):
return self
@@ -249,7 +249,7 @@ if isinstance(j, int):
# Dynamic Param Search
# -----------------
class DynamicParam():
class DynamicParam:
def foo(self):
return

View File

@@ -41,9 +41,9 @@ def parse_test_files_option(opt):
opt = str(opt)
if ':' in opt:
(f_name, rest) = opt.split(':', 1)
return (f_name, list(map(int, rest.split(','))))
return f_name, list(map(int, rest.split(',')))
else:
return (opt, [])
return opt, []
def pytest_generate_tests(metafunc):

View File

@@ -1,4 +1,4 @@
class Cls():
class Cls:
class_attr = ''
def __init__(self, input):
self.instance_attr = 3
@@ -77,7 +77,7 @@ return_one(''.undefined_attribute)
[r for r in [1, 2]]
# some random error that showed up
class NotCalled():
class NotCalled:
def match_something(self, param):
seems_to_need_an_assignment = param
return [value.match_something() for value in []]

View File

@@ -8,7 +8,7 @@ Jedi issues warnings for possible errors if ``__getattr__``,
# -----------------
class Cls():
class Cls:
def __getattr__(self, name):
return getattr(str, name)
@@ -32,7 +32,7 @@ Inherited().undefined
# -----------------
class SetattrCls():
class SetattrCls:
def __init__(self, dct):
# Jedi doesn't even try to understand such code
for k, v in dct.items():

View File

@@ -1,5 +1,5 @@
class Base(object):
class Nested():
class Nested:
def foo():
pass

View File

@@ -1,5 +1,5 @@
# classmethod
class TarFile():
class TarFile:
@classmethod
def open(cls, name, **kwargs):
return cls.taropen(name, **kwargs)

View File

@@ -60,7 +60,7 @@ default(x=1)
# class arguments
# -----------------
class Instance():
class Instance:
def __init__(self, foo):
self.foo = foo

View File

@@ -111,7 +111,7 @@ mixed2(3, b=5)
simple(1, **[])
#! 12 type-error-star-star
simple(1, **1)
class A(): pass
class A: pass
#! 12 type-error-star-star
simple(1, **A())

View File

@@ -44,7 +44,7 @@ except (TypeError, NotImplementedError): pass
# -----------------
try:
str.not_existing
except ((AttributeError)): pass
except (AttributeError): pass
try:
#! 4 attribute-error
str.not_existing

View File

@@ -16,8 +16,8 @@ else:
exec source in global_map """, 'blub', 'exec'))
class _GlobalNameSpace():
class SideEffectContainer():
class _GlobalNameSpace:
class SideEffectContainer:
pass
@@ -80,7 +80,7 @@ def test_numpy_like_non_zero():
def test_nested_resolve():
class XX():
class XX:
def x():
pass
@@ -168,7 +168,7 @@ def test_list():
def test_slice():
class Foo1():
class Foo1:
bar = []
baz = 'xbarx'
_assert_interpreter_complete('getattr(Foo1, baz[1:-1]).append',
@@ -177,7 +177,7 @@ def test_slice():
def test_getitem_side_effects():
class Foo2():
class Foo2:
def __getitem__(self, index):
# Possible side effects here, should therefore not call this.
if True:
@@ -190,7 +190,7 @@ def test_getitem_side_effects():
def test_property_error_oldstyle():
lst = []
class Foo3():
class Foo3:
@property
def bar(self):
lst.append(1)
@@ -269,7 +269,7 @@ def test_more_complex_instances():
def foo(self, other):
return self
class Base():
class Base:
def wow(self):
return Something()

View File

@@ -7,7 +7,7 @@ from parso.python import tree
import pytest
class TestCallAndName():
class TestCallAndName:
def get_call(self, source):
# Get the simple_stmt and then the first one.
node = parse(source).children[0]

View File

@@ -59,7 +59,7 @@ class TestSpeed(TestCase):
unwanted computation of repr(). Exemple : big pandas data.
See issue #919.
"""
class SlowRepr():
class SlowRepr:
"class to test what happens if __repr__ is very slow."
def some_method(self):
pass