1
0
forked from VimPlug/jedi

Remove no_unicode_pprint

This commit is contained in:
Dave Halter
2020-07-02 00:54:17 +02:00
parent aab9fd2fbe
commit 1df98c5bd6
3 changed files with 4 additions and 18 deletions

View File

@@ -325,18 +325,6 @@ except NameError:
pass pass
def no_unicode_pprint(dct):
"""
Python 2/3 dict __repr__ may be different, because of unicode differens
(with or without a `u` prefix). Normally in doctests we could use `pprint`
to sort dicts and check for equality, but here we have to write a separate
function to do that.
"""
import pprint
s = pprint.pformat(dct)
print(re.sub("u'", "'", s))
def utf8_repr(func): def utf8_repr(func):
""" """
``__repr__`` methods in Python 2 don't allow unicode objects to be ``__repr__`` methods in Python 2 don't allow unicode objects to be

View File

@@ -128,7 +128,6 @@ class BaseName(object):
to Jedi, :meth:`jedi.Script.infer` should return a list of to Jedi, :meth:`jedi.Script.infer` should return a list of
definition for ``sys``, ``f``, ``C`` and ``x``. definition for ``sys``, ``f``, ``C`` and ``x``.
>>> from jedi._compatibility import no_unicode_pprint
>>> from jedi import Script >>> from jedi import Script
>>> source = ''' >>> source = '''
... import keyword ... import keyword
@@ -154,7 +153,7 @@ class BaseName(object):
so that it is easy to relate the result to the source code. so that it is easy to relate the result to the source code.
>>> defs = sorted(defs, key=lambda d: d.line) >>> defs = sorted(defs, key=lambda d: d.line)
>>> no_unicode_pprint(defs) # doctest: +NORMALIZE_WHITESPACE >>> print(defs) # doctest: +NORMALIZE_WHITESPACE
[<Name full_name='keyword', description='module keyword'>, [<Name full_name='keyword', description='module keyword'>,
<Name full_name='__main__.C', description='class C'>, <Name full_name='__main__.C', description='class C'>,
<Name full_name='__main__.D', description='instance D'>, <Name full_name='__main__.D', description='instance D'>,
@@ -323,7 +322,6 @@ class BaseName(object):
Example: Example:
>>> from jedi._compatibility import no_unicode_pprint
>>> from jedi import Script >>> from jedi import Script
>>> source = ''' >>> source = '''
... def f(): ... def f():
@@ -336,7 +334,7 @@ class BaseName(object):
>>> script = Script(source) # line is maximum by default >>> script = Script(source) # line is maximum by default
>>> defs = script.infer(column=3) >>> defs = script.infer(column=3)
>>> defs = sorted(defs, key=lambda d: d.line) >>> defs = sorted(defs, key=lambda d: d.line)
>>> no_unicode_pprint(defs) # doctest: +NORMALIZE_WHITESPACE >>> print(defs) # doctest: +NORMALIZE_WHITESPACE
[<Name full_name='__main__.f', description='def f'>, [<Name full_name='__main__.f', description='def f'>,
<Name full_name='__main__.C', description='class C'>] <Name full_name='__main__.C', description='class C'>]
>>> str(defs[0].description) # strip literals in python2 >>> str(defs[0].description) # strip literals in python2

View File

@@ -439,7 +439,7 @@ def get_global_filters(context, until_position, origin_scope):
For global name lookups. The filters will handle name resolution For global name lookups. The filters will handle name resolution
themselves, but here we gather possible filters downwards. themselves, but here we gather possible filters downwards.
>>> from jedi._compatibility import u, no_unicode_pprint >>> from jedi._compatibility import u
>>> from jedi import Script >>> from jedi import Script
>>> script = Script(u(''' >>> script = Script(u('''
... x = ['a', 'b', 'c'] ... x = ['a', 'b', 'c']
@@ -455,7 +455,7 @@ def get_global_filters(context, until_position, origin_scope):
First we get the names from the function scope. First we get the names from the function scope.
>>> no_unicode_pprint(filters[0]) # doctest: +ELLIPSIS >>> print(filters[0]) # doctest: +ELLIPSIS
MergedFilter(<ParserTreeFilter: ...>, <GlobalNameFilter: ...>) MergedFilter(<ParserTreeFilter: ...>, <GlobalNameFilter: ...>)
>>> sorted(str(n) for n in filters[0].values()) # doctest: +NORMALIZE_WHITESPACE >>> sorted(str(n) for n in filters[0].values()) # doctest: +NORMALIZE_WHITESPACE
['<TreeNameDefinition: string_name=func start_pos=(3, 4)>', ['<TreeNameDefinition: string_name=func start_pos=(3, 4)>',