mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-08 06:44:46 +08:00
compatibility improvements -> use reduce from functools
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
"""
|
"""
|
||||||
To ensure compatibility from Python ``2.6`` - ``3.3``, a module has been
|
To ensure compatibility from Python ``2.6`` - ``3.3``, a module has been
|
||||||
created. Clearly there is huge need to use conforming syntax. But many changes
|
created. Clearly there is huge need to use conforming syntax.
|
||||||
(e.g. ``property``, ``hasattr`` in ``2.5``) can be rewritten in pure python.
|
|
||||||
"""
|
"""
|
||||||
import sys
|
import sys
|
||||||
import imp
|
import imp
|
||||||
@@ -147,16 +146,13 @@ class Python3Method(object):
|
|||||||
else:
|
else:
|
||||||
return lambda *args, **kwargs: self.func(obj, *args, **kwargs)
|
return lambda *args, **kwargs: self.func(obj, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def use_metaclass(meta, *bases):
|
def use_metaclass(meta, *bases):
|
||||||
""" Create a class with a metaclass. """
|
""" Create a class with a metaclass. """
|
||||||
if not bases:
|
if not bases:
|
||||||
bases = (object,)
|
bases = (object,)
|
||||||
return meta("HackClass", bases, {})
|
return meta("HackClass", bases, {})
|
||||||
|
|
||||||
try:
|
|
||||||
from functools import reduce # Python 3
|
|
||||||
except ImportError:
|
|
||||||
reduce = reduce
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
encoding = sys.stdout.encoding
|
encoding = sys.stdout.encoding
|
||||||
@@ -165,6 +161,7 @@ try:
|
|||||||
except AttributeError:
|
except AttributeError:
|
||||||
encoding = 'ascii'
|
encoding = 'ascii'
|
||||||
|
|
||||||
|
|
||||||
def u(string):
|
def u(string):
|
||||||
"""Cast to unicode DAMMIT!
|
"""Cast to unicode DAMMIT!
|
||||||
Written because Python2 repr always implicitly casts to a string, so we
|
Written because Python2 repr always implicitly casts to a string, so we
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ from __future__ import with_statement
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from jedi._compatibility import reduce
|
from functools import reduce
|
||||||
import jedi
|
import jedi
|
||||||
from jedi import refactoring
|
from jedi import refactoring
|
||||||
|
|
||||||
|
|||||||
@@ -101,7 +101,8 @@ import re
|
|||||||
from ast import literal_eval
|
from ast import literal_eval
|
||||||
|
|
||||||
import jedi
|
import jedi
|
||||||
from jedi._compatibility import unicode, reduce, StringIO, is_py3k
|
from functools import reduce
|
||||||
|
from jedi._compatibility import unicode, StringIO, is_py3k
|
||||||
|
|
||||||
|
|
||||||
TEST_COMPLETIONS = 0
|
TEST_COMPLETIONS = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user