[Python-modules-commits] [rope] 01/11: Import rope_0.10.5.orig.tar.gz
Arnaud Fontaine
arnau at moszumanska.debian.org
Thu Apr 13 08:52:43 UTC 2017
This is an automated email from the git hooks/post-receive script.
arnau pushed a commit to branch debian-experimental
in repository rope.
commit 0d2c73dafa27bdee016a7008b8f15afec48ffe20
Author: Arnaud Fontaine <arnau at debian.org>
Date: Thu Apr 13 17:33:19 2017 +0900
Import rope_0.10.5.orig.tar.gz
---
PKG-INFO | 20 +-
README.rst | 14 +-
docs/overview.rst | 123 +++++++
docs/rope.rst | 1 +
PKG-INFO => rope.egg-info/PKG-INFO | 20 +-
rope.egg-info/SOURCES.txt | 141 ++++++++
rope.egg-info/dependency_links.txt | 1 +
rope.egg-info/top_level.txt | 1 +
rope/__init__.py | 3 +-
rope/base/astutils.py | 3 +
rope/base/builtins.py | 24 +-
rope/base/codeanalyze.py | 32 +-
rope/base/default_config.py | 23 +-
rope/base/evaluate.py | 7 +-
rope/base/fscommands.py | 21 +-
rope/base/oi/doa.py | 4 +-
rope/base/oi/runmod.py | 29 +-
rope/base/oi/soi.py | 31 +-
rope/base/oi/type_hinting/__init__.py | 0
rope/base/oi/type_hinting/evaluate.py | 353 +++++++++++++++++++
rope/base/oi/type_hinting/factory.py | 70 ++++
rope/base/oi/type_hinting/interfaces.py | 25 ++
rope/base/oi/type_hinting/providers/__init__.py | 0
rope/base/oi/type_hinting/providers/composite.py | 59 ++++
rope/base/oi/type_hinting/providers/docstrings.py | 193 ++++++++++
rope/base/oi/type_hinting/providers/inheritance.py | 66 ++++
rope/base/oi/type_hinting/providers/interfaces.py | 37 ++
.../oi/type_hinting/providers/numpydocstrings.py | 41 +++
.../providers/pep0484_type_comments.py | 42 +++
rope/base/oi/type_hinting/resolvers/__init__.py | 0
rope/base/oi/type_hinting/resolvers/composite.py | 22 ++
rope/base/oi/type_hinting/resolvers/interfaces.py | 10 +
rope/base/oi/type_hinting/resolvers/types.py | 16 +
rope/base/oi/type_hinting/utils.py | 136 ++++++++
rope/base/project.py | 15 +-
rope/base/pyobjects.py | 2 +-
rope/base/pyobjectsdef.py | 47 ++-
rope/base/stdmods.py | 25 +-
rope/base/{utils.py => utils/__init__.py} | 19 +-
rope/base/utils/datastructures.py | 67 ++++
rope/base/utils/pycompat.py | 45 +++
rope/contrib/finderrors.py | 2 +-
rope/contrib/fixsyntax.py | 2 +-
rope/refactor/extract.py | 28 +-
rope/refactor/importutils/__init__.py | 9 +-
rope/refactor/importutils/module_imports.py | 81 +++--
rope/refactor/move.py | 140 ++++++--
rope/refactor/occurrences.py | 20 +-
rope/refactor/patchedast.py | 105 ++++--
rope/refactor/suites.py | 21 +-
ropetest/__init__.py | 7 +-
ropetest/advanced_oi_test.py | 14 +-
ropetest/builtinstest.py | 5 +-
ropetest/codeanalyzetest.py | 30 +-
ropetest/contrib/__init__.py | 5 +-
ropetest/contrib/autoimporttest.py | 5 +-
ropetest/contrib/changestacktest.py | 6 +-
ropetest/contrib/codeassisttest.py | 6 +-
ropetest/contrib/finderrorstest.py | 6 +-
ropetest/contrib/fixmodnamestest.py | 6 +-
ropetest/objectdbtest.py | 6 +-
ropetest/objectinfertest.py | 9 +-
ropetest/projecttest.py | 18 +-
ropetest/pycoretest.py | 33 +-
ropetest/pyscopestest.py | 5 +-
ropetest/refactor/extracttest.py | 59 +++-
ropetest/refactor/importutilstest.py | 76 +++-
ropetest/refactor/movetest.py | 123 ++++++-
ropetest/refactor/multiprojecttest.py | 10 +-
ropetest/refactor/patchedasttest.py | 168 ++++++++-
ropetest/refactor/renametest.py | 5 +-
ropetest/refactor/restructuretest.py | 5 +-
ropetest/refactor/similarfindertest.py | 9 +-
ropetest/refactor/suitestest.py | 5 +-
ropetest/runmodtest.py | 8 +-
ropetest/simplifytest.py | 5 +-
ropetest/testutils.py | 9 +-
ropetest/type_hinting_test.py | 387 +++++++++++++++++++++
setup.cfg | 5 +
setup.py | 33 +-
80 files changed, 2951 insertions(+), 313 deletions(-)
diff --git a/PKG-INFO b/PKG-INFO
index fc97606..5b135d0 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,8 +1,8 @@
Metadata-Version: 1.1
Name: rope
-Version: 0.10.3
+Version: 0.10.5
Summary: a python refactoring library...
-Home-page: http://rope.sf.net/
+Home-page: https://github.com/python-rope/rope
Author: Ali Gholami Rudi
Author-email: aligrudi at users.sourceforge.net
License: GNU GPL
@@ -24,13 +24,12 @@ Description:
.. _`rope`: https://github.com/python-rope/rope
- New Features
+ Notes
============
- * Under new management! Matěj Cepl <mcepl at cepl.eu> takes it hesitantly
- over
- * Merged all availables pull requests and patches to the main codebase
- * Tests are green again
+ * Nick Smith <nicks at fastmail.fm> takes over maintaining rope. Many thanks to
+ Matěj Cepl for his work maintaining rope for the past few years!!
+ * Full python3 support is in progress... stay tuned
Platform: UNKNOWN
@@ -43,4 +42,11 @@ Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: GNU General Public License (GPL)
Classifier: Natural Language :: English
Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 2
+Classifier: Programming Language :: Python :: 2.6
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3
+Classifier: Programming Language :: Python :: 3.2
+Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.4
Classifier: Topic :: Software Development
diff --git a/README.rst b/README.rst
index 2bdec29..a2d28ea 100644
--- a/README.rst
+++ b/README.rst
@@ -15,13 +15,12 @@ Overview
.. _`rope`: https://github.com/python-rope/rope
-New Features
+Notes
============
-* Under new management! Matěj Cepl <mcepl at cepl.eu> takes it hesitantly
- over
-* Merged all availables pull requests and patches to the main codebase
-* Tests are green again
+* Nick Smith <nicks at fastmail.fm> takes over maintaining rope. Many thanks to
+ Matěj Cepl for his work maintaining rope for the past few years!!
+* Full python3 support is in progress... stay tuned
Getting Started
===============
@@ -49,14 +48,15 @@ googlegroups.com`_.
License
=======
-This program is under the terms of GPL (GNU General Public License).
-Have a look at ``COPYING`` file for more information.
+This program is under the terms of GPL v2 (GNU General Public License).
+Have a look at `COPYING`_ for more information.
.. _`docs/rope.rst`: docs/rope.html
.. _`docs/overview.rst`: docs/overview.html
.. _`docs/contributing.rst`: docs/contributing.html
.. _`docs/library.rst`: docs/library.html
+.. _`COPYING`: COPYING
.. image:: https://secure.travis-ci.org/python-rope/rope.png
:alt: Build Status
diff --git a/docs/overview.rst b/docs/overview.rst
index fe44584..3fb3272 100644
--- a/docs/overview.rst
+++ b/docs/overview.rst
@@ -1209,6 +1209,129 @@ Rope uses this feature by default but you can disable it by editing
``config.py``.
+Type Hinting
+------------
+
+Currently supported type hinting for:
+
+- function parameter type, using function doctring (:type or @type)
+- function return type, using function doctring (:rtype or @rtype)
+- class attribute type, using class docstring (:type or @type). Attribute should by set to None or NotImplemented in class.
+- any assignment, using type comments of PEP 0484 (in limited form).
+
+If rope cannot detect the type of a function argument correctly (due to the
+dynamic nature of Python), you can help it by hinting the type using
+one of the following docstring syntax styles.
+
+
+**Sphinx style**
+
+http://sphinx-doc.org/domains.html#info-field-lists
+
+::
+
+ def myfunction(node, foo):
+ """Do something with a ``node``.
+
+ :type node: ProgramNode
+ :param str foo: foo parameter description
+
+ """
+ node.| # complete here
+
+
+**Epydoc**
+
+http://epydoc.sourceforge.net/manual-fields.html
+
+::
+
+ def myfunction(node):
+ """Do something with a ``node``.
+
+ @type node: ProgramNode
+
+ """
+ node.| # complete here
+
+
+**Numpydoc**
+
+https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt
+
+In order to support the numpydoc format, you need to install the `numpydoc
+<https://pypi.python.org/pypi/numpydoc>`__ package.
+
+::
+
+ def foo(var1, var2, long_var_name='hi'):
+ r"""A one-line summary that does not use variable names or the
+ function name.
+
+ ...
+
+ Parameters
+ ----------
+ var1 : array_like
+ Array_like means all those objects -- lists, nested lists,
+ etc. -- that can be converted to an array. We can also
+ refer to variables like `var1`.
+ var2 : int
+ The type above can either refer to an actual Python type
+ (e.g. ``int``), or describe the type of the variable in more
+ detail, e.g. ``(N,) ndarray`` or ``array_like``.
+ long_variable_name : {'hi', 'ho'}, optional
+ Choices in brackets, default first when optional.
+
+ ...
+
+ """
+ var2.| # complete here
+
+
+**PEP 0484**
+
+https://www.python.org/dev/peps/pep-0484/#type-comments
+
+::
+
+ class Sample(object):
+ def __init__(self):
+ self.x = None # type: random.Random
+ self.x.| # complete here
+
+
+Supported syntax of type hinting
+''''''''''''''''''''''''''''''''
+
+Currently rope supports the following syntax of type-hinting.
+
+Parametrized objects:
+
+- Foo
+- foo.bar.Baz
+- list[Foo] or list[foo.bar.Baz] etc.
+- set[Foo]
+- tuple[Foo]
+- dict[Foo, Bar]
+- collections.Iterable[Foo]
+- collections.Iterator[Foo]
+
+Nested expressions also allowed:
+
+- collections.Iterable[list[Foo]]
+
+TODO:
+
+Callable objects:
+
+- (Foo, Bar) -> Baz
+
+Multiple interfaces implementation:
+
+- Foo | Bar
+
+
Custom Source Folders
=====================
diff --git a/docs/rope.rst b/docs/rope.rst
index b579816..4214945 100644
--- a/docs/rope.rst
+++ b/docs/rope.rst
@@ -44,6 +44,7 @@ Features implemented so far:
* Static and dynamic object analysis
* Handling built-in container types
* Saving object information on disk and validating them
+ * Type hints using docstring or type comments PEP 0484
For more information see `overview.rst`_.
diff --git a/PKG-INFO b/rope.egg-info/PKG-INFO
similarity index 63%
copy from PKG-INFO
copy to rope.egg-info/PKG-INFO
index fc97606..5b135d0 100644
--- a/PKG-INFO
+++ b/rope.egg-info/PKG-INFO
@@ -1,8 +1,8 @@
Metadata-Version: 1.1
Name: rope
-Version: 0.10.3
+Version: 0.10.5
Summary: a python refactoring library...
-Home-page: http://rope.sf.net/
+Home-page: https://github.com/python-rope/rope
Author: Ali Gholami Rudi
Author-email: aligrudi at users.sourceforge.net
License: GNU GPL
@@ -24,13 +24,12 @@ Description:
.. _`rope`: https://github.com/python-rope/rope
- New Features
+ Notes
============
- * Under new management! Matěj Cepl <mcepl at cepl.eu> takes it hesitantly
- over
- * Merged all availables pull requests and patches to the main codebase
- * Tests are green again
+ * Nick Smith <nicks at fastmail.fm> takes over maintaining rope. Many thanks to
+ Matěj Cepl for his work maintaining rope for the past few years!!
+ * Full python3 support is in progress... stay tuned
Platform: UNKNOWN
@@ -43,4 +42,11 @@ Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: GNU General Public License (GPL)
Classifier: Natural Language :: English
Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 2
+Classifier: Programming Language :: Python :: 2.6
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3
+Classifier: Programming Language :: Python :: 3.2
+Classifier: Programming Language :: Python :: 3.3
+Classifier: Programming Language :: Python :: 3.4
Classifier: Topic :: Software Development
diff --git a/rope.egg-info/SOURCES.txt b/rope.egg-info/SOURCES.txt
new file mode 100644
index 0000000..7724865
--- /dev/null
+++ b/rope.egg-info/SOURCES.txt
@@ -0,0 +1,141 @@
+COPYING
+MANIFEST.in
+README.rst
+setup.py
+docs/contributing.rst
+docs/done.rst
+docs/library.rst
+docs/overview.rst
+docs/rope.rst
+docs/dev/issues.rst
+docs/dev/todo.rst
+rope/__init__.py
+rope.egg-info/PKG-INFO
+rope.egg-info/SOURCES.txt
+rope.egg-info/dependency_links.txt
+rope.egg-info/top_level.txt
+rope/base/__init__.py
+rope/base/arguments.py
+rope/base/ast.py
+rope/base/astutils.py
+rope/base/builtins.py
+rope/base/change.py
+rope/base/codeanalyze.py
+rope/base/default_config.py
+rope/base/evaluate.py
+rope/base/exceptions.py
+rope/base/fscommands.py
+rope/base/history.py
+rope/base/libutils.py
+rope/base/prefs.py
+rope/base/project.py
+rope/base/pycore.py
+rope/base/pynames.py
+rope/base/pynamesdef.py
+rope/base/pyobjects.py
+rope/base/pyobjectsdef.py
+rope/base/pyscopes.py
+rope/base/resourceobserver.py
+rope/base/resources.py
+rope/base/simplify.py
+rope/base/stdmods.py
+rope/base/taskhandle.py
+rope/base/worder.py
+rope/base/oi/__init__.py
+rope/base/oi/doa.py
+rope/base/oi/memorydb.py
+rope/base/oi/objectdb.py
+rope/base/oi/objectinfo.py
+rope/base/oi/runmod.py
+rope/base/oi/soa.py
+rope/base/oi/soi.py
+rope/base/oi/transform.py
+rope/base/oi/type_hinting/__init__.py
+rope/base/oi/type_hinting/evaluate.py
+rope/base/oi/type_hinting/factory.py
+rope/base/oi/type_hinting/interfaces.py
+rope/base/oi/type_hinting/utils.py
+rope/base/oi/type_hinting/providers/__init__.py
+rope/base/oi/type_hinting/providers/composite.py
+rope/base/oi/type_hinting/providers/docstrings.py
+rope/base/oi/type_hinting/providers/inheritance.py
+rope/base/oi/type_hinting/providers/interfaces.py
+rope/base/oi/type_hinting/providers/numpydocstrings.py
+rope/base/oi/type_hinting/providers/pep0484_type_comments.py
+rope/base/oi/type_hinting/resolvers/__init__.py
+rope/base/oi/type_hinting/resolvers/composite.py
+rope/base/oi/type_hinting/resolvers/interfaces.py
+rope/base/oi/type_hinting/resolvers/types.py
+rope/base/utils/__init__.py
+rope/base/utils/datastructures.py
+rope/base/utils/pycompat.py
+rope/contrib/__init__.py
+rope/contrib/autoimport.py
+rope/contrib/changestack.py
+rope/contrib/codeassist.py
+rope/contrib/finderrors.py
+rope/contrib/findit.py
+rope/contrib/fixmodnames.py
+rope/contrib/fixsyntax.py
+rope/contrib/generate.py
+rope/refactor/__init__.py
+rope/refactor/change_signature.py
+rope/refactor/encapsulate_field.py
+rope/refactor/extract.py
+rope/refactor/functionutils.py
+rope/refactor/inline.py
+rope/refactor/introduce_factory.py
+rope/refactor/introduce_parameter.py
+rope/refactor/localtofield.py
+rope/refactor/method_object.py
+rope/refactor/move.py
+rope/refactor/multiproject.py
+rope/refactor/occurrences.py
+rope/refactor/patchedast.py
+rope/refactor/rename.py
+rope/refactor/restructure.py
+rope/refactor/similarfinder.py
+rope/refactor/sourceutils.py
+rope/refactor/suites.py
+rope/refactor/topackage.py
+rope/refactor/usefunction.py
+rope/refactor/wildcards.py
+rope/refactor/importutils/__init__.py
+rope/refactor/importutils/actions.py
+rope/refactor/importutils/importinfo.py
+rope/refactor/importutils/module_imports.py
+ropetest/__init__.py
+ropetest/advanced_oi_test.py
+ropetest/builtinstest.py
+ropetest/codeanalyzetest.py
+ropetest/historytest.py
+ropetest/objectdbtest.py
+ropetest/objectinfertest.py
+ropetest/projecttest.py
+ropetest/pycoretest.py
+ropetest/pyscopestest.py
+ropetest/runmodtest.py
+ropetest/simplifytest.py
+ropetest/testutils.py
+ropetest/type_hinting_test.py
+ropetest/contrib/__init__.py
+ropetest/contrib/autoimporttest.py
+ropetest/contrib/changestacktest.py
+ropetest/contrib/codeassisttest.py
+ropetest/contrib/finderrorstest.py
+ropetest/contrib/findittest.py
+ropetest/contrib/fixmodnamestest.py
+ropetest/contrib/generatetest.py
+ropetest/refactor/__init__.py
+ropetest/refactor/change_signature_test.py
+ropetest/refactor/extracttest.py
+ropetest/refactor/importutilstest.py
+ropetest/refactor/inlinetest.py
+ropetest/refactor/movetest.py
+ropetest/refactor/multiprojecttest.py
+ropetest/refactor/patchedasttest.py
+ropetest/refactor/renametest.py
+ropetest/refactor/restructuretest.py
+ropetest/refactor/similarfindertest.py
+ropetest/refactor/suitestest.py
+ropetest/refactor/usefunctiontest.py
\ No newline at end of file
diff --git a/rope.egg-info/dependency_links.txt b/rope.egg-info/dependency_links.txt
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/rope.egg-info/dependency_links.txt
@@ -0,0 +1 @@
+
diff --git a/rope.egg-info/top_level.txt b/rope.egg-info/top_level.txt
new file mode 100644
index 0000000..649b5f0
--- /dev/null
+++ b/rope.egg-info/top_level.txt
@@ -0,0 +1 @@
+rope
diff --git a/rope/__init__.py b/rope/__init__.py
index 624b627..331fada 100644
--- a/rope/__init__.py
+++ b/rope/__init__.py
@@ -1,8 +1,9 @@
"""rope, a python refactoring library"""
INFO = __doc__
-VERSION = '0.10.3'
+VERSION = '0.10.5'
COPYRIGHT = """\
+Copyright (C) 2015-2016 Nicholas Smith
Copyright (C) 2014-2015 Matej Cepl
Copyright (C) 2006-2012 Ali Gholami Rudi
Copyright (C) 2009-2012 Anton Gritsay
diff --git a/rope/base/astutils.py b/rope/base/astutils.py
index 8ace1a9..6c0b3d7 100644
--- a/rope/base/astutils.py
+++ b/rope/base/astutils.py
@@ -40,6 +40,9 @@ class _NodeNameCollector(object):
def _Name(self, node):
self._add_node(node)
+ def _ExceptHandler(self, node):
+ self.names.append((node.name, []))
+
def _Tuple(self, node):
new_levels = []
if self.levels is not None:
diff --git a/rope/base/builtins.py b/rope/base/builtins.py
index 33729d5..b4df062 100644
--- a/rope/base/builtins.py
+++ b/rope/base/builtins.py
@@ -6,7 +6,8 @@ except NameError:
raw_input = input
import rope.base.evaluate
-from rope.base import pynames, pyobjects, arguments, utils, ast
+from rope.base.utils import pycompat
+from rope.base import pynames, pyobjects, arguments, utils
class BuiltinModule(pyobjects.AbstractModule):
@@ -86,6 +87,9 @@ class BuiltinClass(_BuiltinElement, pyobjects.AbstractClass):
result.update(self.initial)
return result
+ def get_module(self):
+ return builtins
+
class BuiltinFunction(_BuiltinElement, pyobjects.AbstractFunction):
@@ -271,7 +275,7 @@ class List(BuiltinClass):
collector('__getitem__', function=self._list_get)
collector('pop', function=self._list_get)
try:
- collector('__getslice__', function=self._self_get)
+ collector('__getslice__', function=self._list_get)
except AttributeError:
pass
@@ -297,6 +301,10 @@ class List(BuiltinClass):
def _list_get(self, context):
if self.holding is not None:
+ args = context.get_arguments(['self', 'key'])
+ if (len(args) > 1 and args[1] is not None and
+ args[1].get_type() == builtins['slice'].get_object()):
+ return get_list(self.holding)
return self.holding
return context.get_per_name()
@@ -414,7 +422,7 @@ class Tuple(BuiltinClass):
if objects:
first = objects[0]
attributes = {
- '__getitem__': BuiltinName(BuiltinFunction(first)),
+ '__getitem__': BuiltinName(BuiltinFunction(first)), # TODO: add slice support
'__getslice__':
BuiltinName(BuiltinFunction(pyobjects.PyObject(self))),
'__new__': BuiltinName(BuiltinFunction(function=self._new_tuple)),
@@ -656,12 +664,12 @@ class Lambda(pyobjects.AbstractFunction):
return 'lambda'
def get_param_names(self, special_args=True):
- result = [node.id for node in self.arguments.args
- if isinstance(node, ast.Name)]
+ result = [pycompat.get_ast_arg_arg(node) for node in self.arguments.args
+ if isinstance(node, pycompat.ast_arg_type)]
if self.arguments.vararg:
- result.append('*' + self.arguments.vararg)
+ result.append('*' + pycompat.get_ast_arg_arg(self.arguments.vararg))
if self.arguments.kwarg:
- result.append('**' + self.arguments.kwarg)
+ result.append('**' + pycompat.get_ast_arg_arg(self.arguments.kwarg))
return result
@property
@@ -801,4 +809,4 @@ _initial_builtins = {
builtin=raw_input)),
}
-builtins = BuiltinModule('__builtin__', initial=_initial_builtins)
+builtins = BuiltinModule(pycompat.builtins.__name__, initial=_initial_builtins)
diff --git a/rope/base/codeanalyze.py b/rope/base/codeanalyze.py
index 0c1f055..1704e9a 100644
--- a/rope/base/codeanalyze.py
+++ b/rope/base/codeanalyze.py
@@ -129,31 +129,31 @@ class _CustomGenerator(object):
i += 1
return result
- _main_chars = re.compile(r'[\'|"|#|\\|\[|\]|\{|\}|\(|\)]')
+ # Matches all backslashes before the token, to detect escaped quotes
+ _main_tokens = re.compile(r'(\\*)((\'\'\'|"""|\'|")|#|\[|\]|\{|\}|\(|\))')
def _analyze_line(self, line):
- char = None
- for match in self._main_chars.finditer(line):
- char = match.group()
- i = match.start()
- if char in '\'"':
+ token = None
+ for match in self._main_tokens.finditer(line):
+ prefix = match.group(1)
+ token = match.group(2)
+ # Skip any tokens which are escaped
+ if len(prefix) % 2 == 1:
+ continue
+ if token in ["'''", '"""', "'", '"']:
if not self.in_string:
- self.in_string = char
- if char * 3 == line[i:i + 3]:
- self.in_string = char * 3
- elif self.in_string == line[i:i + len(self.in_string)] and \
- not (i > 0 and line[i - 1] == '\\' and
- not (i > 1 and line[i - 2] == '\\')):
+ self.in_string = token
+ elif self.in_string == token:
self.in_string = ''
if self.in_string:
continue
- if char == '#':
+ if token == '#':
break
- if char in '([{':
+ if token in '([{':
self.open_count += 1
- elif char in ')]}':
+ elif token in ')]}':
self.open_count -= 1
- if line and char != '#' and line.endswith('\\'):
+ if line and token != '#' and line.endswith('\\'):
self.continuation = True
else:
self.continuation = False
diff --git a/rope/base/default_config.py b/rope/base/default_config.py
index 0ee9937..0bf7750 100644
--- a/rope/base/default_config.py
+++ b/rope/base/default_config.py
@@ -1,4 +1,5 @@
# The default ``config.py``
+# flake8: noqa
def set_prefs(prefs):
@@ -79,16 +80,32 @@ def set_prefs(prefs):
# appear in the importing namespace.
prefs['ignore_bad_imports'] = False
+ # If `True`, rope will insert new module imports as
+ # `from <package> import <module>` by default.
+ prefs['prefer_module_from_imports'] = False
+
# If `True`, rope will transform a comma list of imports into
# multiple separate import statements when organizing
# imports.
prefs['split_imports'] = False
- # If `True`, rope will sort imports alphabetically by module name
- # instead of alphabetically by import statement, with from imports
- # after normal imports.
+ # If `True`, rope will remove all top-level import statements and
+ # reinsert them at the top of the module when making changes.
+ prefs['pull_imports_to_top'] = True
+
+ # If `True`, rope will sort imports alphabetically by module name instead of
+ # alphabetically by import statement, with from imports after normal
+ # imports.
prefs['sort_imports_alphabetically'] = False
+ # Location of implementation of rope.base.oi.type_hinting.interfaces.ITypeHintingFactory
+ # In general case, you don't have to change this value, unless you're an rope expert.
+ # Change this value to inject you own implementations of interfaces
+ # listed in module rope.base.oi.type_hinting.providers.interfaces
+ # For example, you can add you own providers for Django Models, or disable the search
+ # type-hinting in a class hierarchy, etc.
+ prefs['type_hinting_factory'] = 'rope.base.oi.type_hinting.factory.default_type_hinting_factory'
+
def project_opened(project):
"""This function is called after opening the project"""
diff --git a/rope/base/evaluate.py b/rope/base/evaluate.py
index faf0940..f432392 100644
--- a/rope/base/evaluate.py
+++ b/rope/base/evaluate.py
@@ -2,6 +2,7 @@ import rope.base.builtins
import rope.base.pynames
import rope.base.pyobjects
from rope.base import ast, astutils, exceptions, pyobjects, arguments, worder
+from rope.base.utils import pycompat
BadIdentifierError = exceptions.BadIdentifierError
@@ -290,7 +291,11 @@ class StatementEvaluator(object):
self._call_function(node.value, '__getitem__',
[node.slice.value])
elif isinstance(node.slice, ast.Slice):
- self._call_function(node.value, '__getslice__')
+ self._call_function(node.value, '__getitem__',
+ [node.slice])
+
+ def _Slice(self, node):
+ self.result = self._get_builtin_name('slice')
def _call_function(self, node, function_name, other_args=None):
pyname = eval_node(self.scope, node)
diff --git a/rope/base/fscommands.py b/rope/base/fscommands.py
index 8c51e60..3564ed9 100644
--- a/rope/base/fscommands.py
+++ b/rope/base/fscommands.py
@@ -10,6 +10,8 @@ import os
import shutil
import subprocess
+import rope.base.utils.pycompat as pycompat
+
try:
unicode
except NameError:
@@ -261,23 +263,26 @@ def read_str_coding(source):
def _find_coding(text):
- if type(text) == bytes:
- coding = b'coding'
- else:
- coding = "coding"
+ if isinstance(text, pycompat.str):
+ text = text.encode('utf-8')
+ coding = b'coding'
+ to_chr = chr if pycompat.PY3 else lambda x: x
try:
start = text.index(coding) + len(coding)
- if text[start] not in '=:':
+ if text[start] not in b'=:':
return
start += 1
- while start < len(text) and text[start].isspace():
+ while start < len(text) and to_chr(text[start]).isspace():
start += 1
end = start
while end < len(text):
c = text[end]
- if not c.isalnum() and c not in '-_':
+ if not to_chr(c).isalnum() and c not in b'-_':
break
end += 1
- return text[start:end]
+ result = text[start:end]
+ if isinstance(result, bytes):
+ result = result.decode('utf-8')
+ return result
except ValueError:
pass
diff --git a/rope/base/oi/doa.py b/rope/base/oi/doa.py
index de45902..3f314c6 100644
--- a/rope/base/oi/doa.py
+++ b/rope/base/oi/doa.py
@@ -65,7 +65,7 @@ class PythonFileRunner(object):
self.receiving_thread.start()
def _receive_information(self):
- #temp = open('/dev/shm/info', 'w')
+ #temp = open('/dev/shm/info', 'wb')
for data in self.receiver.receive_data():
self.analyze_data(data)
#temp.write(str(data) + '\n')
@@ -128,7 +128,7 @@ class _SocketReceiver(_MessageReceiver):
def receive_data(self):
conn, addr = self.server_socket.accept()
self.server_socket.close()
- my_file = conn.makefile('r')
+ my_file = conn.makefile('rb')
while True:
try:
yield pickle.load(my_file)
diff --git a/rope/base/oi/runmod.py b/rope/base/oi/runmod.py
index 666df74..ba0184c 100644
--- a/rope/base/oi/runmod.py
+++ b/rope/base/oi/runmod.py
@@ -1,12 +1,3 @@
-try:
- execfile
-except NameError:
- def execfile(fn, global_vars, local_vars):
- with open(fn) as f:
- code = compile(f.read(), fn, 'exec')
- exec(code, global_vars, local_vars)
-
-
def __rope_start_everything():
import os
import sys
@@ -19,6 +10,7 @@ def __rope_start_everything():
import inspect
import types
import threading
+ import rope.base.utils.pycompat as pycompat
class _MessageSender(object):
@@ -30,7 +22,7 @@ def __rope_start_everything():
def __init__(self, port):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('127.0.0.1', port))
- self.my_file = s.makefile('w')
+ self.my_file = s.makefile('wb')
def send_data(self, data):
if not self.my_file.closed:
@@ -87,8 +79,9 @@ def __rope_start_everything():
code = frame.f_code
for argname in code.co_varnames[:code.co_argcount]:
try:
- args.append(self._object_to_persisted_form(
- frame.f_locals[argname]))
+ argvalue = self._object_to_persisted_form(
+ frame.f_locals[argname])
+ args.append(argvalue)
except (TypeError, AttributeError):
args.append(('unknown',))
try:
@@ -108,7 +101,6 @@ def __rope_start_everything():
# return False
#return not frame.f_back or
# not self._is_code_inside_project(frame.f_back.f_code)
-
if not self._is_code_inside_project(frame.f_code) and \
(not frame.f_back or
not self._is_code_inside_project(frame.f_back.f_code)):
@@ -136,7 +128,7 @@ def __rope_start_everything():
return ('unknown',)
def _get_persisted_builtin(self, object_):
- if isinstance(object_, (str, unicode)):
+ if isinstance(object_, pycompat.string_types):
return ('builtin', 'str')
if isinstance(object_, list):
holding = None
@@ -148,7 +140,9 @@ def __rope_start_everything():
keys = None
values = None
if len(object_) > 0:
- keys = object_.keys()[0]
+ # @todo - fix it properly, why is __locals__ being
+ # duplicated ?
+ keys = [key for key in object_.keys() if key != '__locals__'][0]
values = object_[keys]
return ('builtin', 'dict',
self._object_to_persisted_form(keys),
@@ -182,7 +176,7 @@ def __rope_start_everything():
return self._get_persisted_code(object_.__func__.__code__)
if isinstance(object_, types.ModuleType):
return self._get_persisted_module(object_)
- if isinstance(object_, (str, unicode, list, dict, tuple, set)):
+ if isinstance(object_, pycompat.string_types + (list, dict, tuple, set)):
return self._get_persisted_builtin(object_)
if isinstance(object_, type):
return self._get_persisted_class(object_)
@@ -215,10 +209,11 @@ def __rope_start_everything():
run_globals.update({'__name__': '__main__',
'__builtins__': __builtins__,
'__file__': file_to_run})
+
if send_info != '-':
data_sender = _FunctionCallDataSender(send_info, project_root)
del sys.argv[1:4]
- execfile(file_to_run, run_globals)
+ pycompat.execfile(file_to_run, run_globals)
if send_info != '-':
data_sender.close()
diff --git a/rope/base/oi/soi.py b/rope/base/oi/soi.py
index 5a11b5e..c05aba9 100644
--- a/rope/base/oi/soi.py
+++ b/rope/base/oi/soi.py
@@ -8,6 +8,7 @@ import rope.base.builtins
import rope.base.pynames
import rope.base.pyobjects
from rope.base import evaluate, utils, arguments
+from rope.base.oi.type_hinting.factory import get_type_hinting_factory
_ignore_inferred = utils.ignore_exception(
@@ -28,7 +29,13 @@ def infer_returned_object(pyfunction, args):
pyfunction.get_param_names(special_args=False))
object_info.function_called(pyfunction, params, result)
return result
- return object_info.get_returned(pyfunction, args)
+ result = object_info.get_returned(pyfunction, args)
+ if result is not None:
+ return result
+ hint_return = get_type_hinting_factory(pyfunction.pycore.project).make_return_provider()
+ type_ = hint_return(pyfunction)
+ if type_ is not None:
+ return rope.base.pyobjects.PyObject(type_)
@_ignore_inferred
@@ -62,9 +69,19 @@ def infer_assigned_object(pyname):
return
for assignment in reversed(pyname.assignments):
result = _infer_assignment(assignment, pyname.module)
- if result is not None:
+ if isinstance(result, rope.base.builtins.BuiltinUnknown) and result.get_name() == 'NotImplementedType':
+ break
+ elif result == rope.base.pyobjects.get_unknown():
+ break
+ elif result is not None:
return result
+ hint_assignment = get_type_hinting_factory(pyname.module.pycore.project).make_assignment_provider()
+ hinting_result = hint_assignment(pyname)
+ if hinting_result is not None:
+ return rope.base.pyobjects.PyObject(hinting_result)
+ return result
+
def get_passed_objects(pyfunction, parameter_index):
object_info = pyfunction.pycore.object_info
@@ -106,8 +123,16 @@ def _infer_returned(pyobject, args):
def _parameter_objects(pyobject):
+ result = []
params = pyobject.get_param_names(special_args=False)
- return [rope.base.pyobjects.get_unknown()] * len(params)
+ hint_param = get_type_hinting_factory(pyobject.pycore.project).make_param_provider()
+ for name in params:
+ type_ = hint_param(pyobject, name)
+ if type_ is not None:
+ result.append(rope.base.pyobjects.PyObject(type_))
+ else:
+ result.append(rope.base.pyobjects.get_unknown())
+ return result
# handling `rope.base.pynames.AssignmentValue`
diff --git a/rope/base/oi/type_hinting/__init__.py b/rope/base/oi/type_hinting/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/rope/base/oi/type_hinting/evaluate.py b/rope/base/oi/type_hinting/evaluate.py
new file mode 100644
index 0000000..3b82eb0
--- /dev/null
+++ b/rope/base/oi/type_hinting/evaluate.py
@@ -0,0 +1,353 @@
+# Based on super lightweight Simple Top-Down Parser from http://effbot.org/zone/simple-top-down-parsing.htm
+# and https://bitbucket.org/emacsway/sqlbuilder/src/default/sqlbuilder/smartsql/contrib/evaluate.py
... 4180 lines suppressed ...
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/rope.git
More information about the Python-modules-commits
mailing list