1
0
forked from VimPlug/jedi

compatibility improvements -> use reduce from functools

This commit is contained in:
Dave Halter
2014-01-14 11:31:01 +01:00
parent 8bf8985247
commit a6e49f2680
3 changed files with 6 additions and 8 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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