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