mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 21:11:28 +07:00
PY-80971 Drop the legacy python-skeletons stubs
GitOrigin-RevId: bdd71af6a628d1b9fc03680a33088cc26857b2d0
This commit is contained in:
committed by
intellij-monorepo-bot
parent
478629edc9
commit
c48402b4cb
@@ -1,7 +0,0 @@
|
||||
The current maintainer:
|
||||
|
||||
* Andrey Vlasovskikh <andrey.vlasovskikh@jetbrains.com>
|
||||
|
||||
Contributors:
|
||||
|
||||
TODO: The list of contributors
|
||||
@@ -1,13 +0,0 @@
|
||||
Copyright 2013 The python-skeletons authors
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -1,244 +0,0 @@
|
||||
Python Skeletons
|
||||
================
|
||||
|
||||
_This proposal is a draft._
|
||||
|
||||
Python skeletons are Python files that contain API definitions of existing
|
||||
libraries extended for static analysis tools.
|
||||
|
||||
Rationale
|
||||
---------
|
||||
|
||||
Python is a dynamic language less suitable for static code analysis than static
|
||||
languages like C or Java. Although Python static analysis tools can extract
|
||||
some information from Python source code without executing it, this information
|
||||
is often very shallow and incomplete.
|
||||
|
||||
Dynamic features of Python are very useful for user code. But using these
|
||||
features in APIs of third-party libraries and the standard library is not
|
||||
always a good idea. Tools (and users, in fact) need clear definitions of APIs.
|
||||
Often library API definitions are quite static and easy to grasp (defined
|
||||
using `class`, `def`), but types of function parameters and return values
|
||||
usually are not specified. Sometimes API definitions involve metaprogramming.
|
||||
|
||||
As there is not enough information in API definition code of libraries,
|
||||
developers of static analysis tools collect extended API data themselves and
|
||||
store it in their own formats. For example, PyLint uses imperative AST
|
||||
transformations of API modules in order to extend them with hard-coded data.
|
||||
PyCharm extends APIs via its proprietary database of declarative type
|
||||
annotations. The absence of a common extended API information format makes it
|
||||
hard for developers and users of tools to collect and share data.
|
||||
|
||||
|
||||
Proposal
|
||||
--------
|
||||
|
||||
The proposal is to create a common database of extended API definitions as a
|
||||
collection of Python files called skeletons. Static analysis tools already
|
||||
understand Python code, so it should be easy to start extracting API
|
||||
definitions from these Python skeleton files. Regular function and class
|
||||
definitions can be extended with additional docstrings and decorators, e.g. for
|
||||
providing types of function parameters and return values. Static analysis tools
|
||||
may use a subset of information contained in skeleton files needed for their
|
||||
operation. Using Python files instead of a custom API definition format will
|
||||
also make it easier for users to populate the skeletons database.
|
||||
|
||||
Declarative Python API definitions for static analysis tools cannot cover all
|
||||
dynamic tricks used in real APIs of libraries: some of them still require
|
||||
library-specific code analysis. Nevertheless the skeletons database is enough
|
||||
for many libraries.
|
||||
|
||||
The proposed [python-skeletons](https://github.com/JetBrains/python-skeletons)
|
||||
repository is hosted on GitHub.
|
||||
|
||||
|
||||
Conventions
|
||||
-----------
|
||||
|
||||
Skeletons should contain syntactically correct Python code, preferably compatible
|
||||
with Python 2.6-3.3.
|
||||
|
||||
Skeletons should respect [PEP-8](http://www.python.org/dev/peps/pep-0008/) and
|
||||
[PEP-257](http://www.python.org/dev/peps/pep-0257/) style guides.
|
||||
|
||||
If you need to reference the members of the original module of a skeleton, you
|
||||
should import it explicitly. For example, in a skeleton for the `foo` module:
|
||||
|
||||
```python
|
||||
import foo
|
||||
|
||||
|
||||
class C(foo.B):
|
||||
def bar():
|
||||
"""Do bar and return Bar.
|
||||
|
||||
:rtype: foo.Bar
|
||||
"""
|
||||
return foo.Bar()
|
||||
```
|
||||
Modules can be referenced in docstring without explicit imports.
|
||||
|
||||
The body of a function in a skeleton file should consist of a single `return`
|
||||
statement that returns a simple value of the declared return type (e.g. `0`
|
||||
for `int`, `False` for `bool`, `Foo()` for `Foo`). If the function returns
|
||||
something non-trivial, its may consist of a `pass` statement.
|
||||
|
||||
|
||||
### Types
|
||||
|
||||
There is no standard notation for specifying types in Python code. We would
|
||||
like this standard to emerge, see the related work below.
|
||||
|
||||
The current understanding is that a standard for optional type annotations in
|
||||
Python could use the syntax of function annotations in Python 3 and decorators
|
||||
as a fallback in Python 2. The type system should be relatively simple, but it
|
||||
has to include parametric (generic) types for collections and probably more.
|
||||
|
||||
As a temporary solution, we propose a simple way of specifying types in
|
||||
skeletons using Sphinx docstrings using the following notation:
|
||||
|
||||
Foo # Class Foo visible in the current scope
|
||||
x.y.Bar # Class Bar from x.y module
|
||||
Foo | Bar # Foo or Bar
|
||||
(Foo, Bar) # Tuple of Foo and Bar
|
||||
list[Foo] # List of Foo elements
|
||||
dict[Foo, Bar] # Dict from Foo to Bar
|
||||
T # Generic type (T-Z are reserved for generics)
|
||||
T <= Foo # Generic type with upper bound Foo
|
||||
Foo[T] # Foo parameterized with T
|
||||
(Foo, Bar) -> Baz # Function of Foo and Bar that returns Baz
|
||||
|
||||
There are several shortcuts available:
|
||||
|
||||
unknown # Unknown type
|
||||
None # type(None)
|
||||
string # Py2: str | unicode, Py3: str
|
||||
bytestring # Py2: str | unicode, Py3: bytes
|
||||
bytes # Py2: str, Py3: bytes
|
||||
unicode # Py2: unicode, Py3: str
|
||||
|
||||
The syntax is a subject to change. It is almost compatible to Python (except
|
||||
function types), but its semantics differs from Python (no `|`, no implicitly
|
||||
visible names, no generic types). So you cannot use these expressions in
|
||||
Python 3 function annotations.
|
||||
|
||||
If you want to create a parameterized class, you should define its parameters
|
||||
in the mock return type of a constructor:
|
||||
|
||||
```python
|
||||
class C(object):
|
||||
"""Some collection C that can contain values of T."""
|
||||
|
||||
def __init__(self, value):
|
||||
"""Initialize C.
|
||||
|
||||
:type value: T
|
||||
:rtype: C[T]
|
||||
"""
|
||||
pass
|
||||
|
||||
def get(self):
|
||||
"""Return the contained value.
|
||||
|
||||
:rtype: T
|
||||
"""
|
||||
pass
|
||||
```
|
||||
|
||||
|
||||
### Versioning
|
||||
|
||||
The recommended way of checking the version of Python is:
|
||||
|
||||
```python
|
||||
import sys
|
||||
|
||||
|
||||
if sys.version_info >= (2, 7) and sys.version_info < (3,):
|
||||
def from_27_until_30():
|
||||
pass
|
||||
```
|
||||
|
||||
A skeleton should document the most recently released version of a library. Use
|
||||
deprecation warnings for functions that have been removed from the API.
|
||||
|
||||
Skeletons for built-in symbols is an exception. There are two modules:
|
||||
`__builtin__` for Python 2 and `builtins` for Python 3.
|
||||
|
||||
|
||||
Related Work
|
||||
------------
|
||||
|
||||
The JavaScript community is also interested in formalizing API definitions and
|
||||
specifying types. They have come up with several JavaScript dialects that
|
||||
support optional types: TypeScript, Dart. There is a JavaScript initiative
|
||||
similar to the proposed Python skeletons called
|
||||
[DefinitelyTyped](https://github.com/borisyankov/DefinitelyTyped). The idea is
|
||||
to use TypeScript API stubs for various JavaScript libraries.
|
||||
|
||||
There are many approaches to specifying types in Python, none of them is widely
|
||||
adopted at the moment:
|
||||
|
||||
* A series of old (2005) posts by GvR:
|
||||
[1](http://www.artima.com/weblogs/viewpost.jsp?thread=85551),
|
||||
[2](http://www.artima.com/weblogs/viewpost.jsp?thread=86641),
|
||||
[3](http://www.artima.com/weblogs/viewpost.jsp?thread=87182)
|
||||
* String-based [python-rightarrow](https://github.com/kennknowles/python-rightarrow)
|
||||
library
|
||||
* Expression-based [typeannotations](https://github.com/ceronman/typeannotations)
|
||||
library for Python 3
|
||||
* [mypy](http://www.mypy-lang.org/) Python dialect
|
||||
* [pytypes](https://github.com/pytypes/pytypes): Optional typing for Python proposal
|
||||
* [Proposal: Use mypy syntax for function annotations](https://mail.python.org/pipermail/python-ideas/2014-August/028618.html) by GvR
|
||||
|
||||
See also the notes on function annotations in
|
||||
[PEP-8](http://www.python.org/dev/peps/pep-0008/).
|
||||
|
||||
|
||||
PyCharm / IntelliJ IDEA
|
||||
-----------------------
|
||||
|
||||
PyCharm 3 and the Python plugin 3.x for IntelliJ IDEA can extract the following
|
||||
information from the skeletons:
|
||||
|
||||
* Parameters of functions and methods
|
||||
* Return types and parameter types of functions and methods
|
||||
* Types of assignment targets
|
||||
* Extra module members
|
||||
* Extra class members
|
||||
* TODO
|
||||
|
||||
PyCharm 3 comes with a snapshot of the Python skeletons repository (Python
|
||||
plugin 3.0.1 for IntelliJ IDEA still doesn't include this repository). You
|
||||
**should not** modify it, because it will be updated with the PyCharm / Python
|
||||
plugin for IntelliJ IDEA installation. If you want to change the skeletons, clone
|
||||
the skeletons GitHub repository into your PyCharm/IntelliJ IDEA config directory:
|
||||
|
||||
```bash
|
||||
cd <config directory>
|
||||
git clone https://github.com/JetBrains/python-skeletons.git
|
||||
```
|
||||
|
||||
where `<config directory>` is:
|
||||
|
||||
* PyCharm
|
||||
* macOS: `~/Library/Application Support/JetBrains/PyCharmXX`
|
||||
* Linux: `~/.config/JetBrains/PyCharmXX`
|
||||
* Windows: `<User home>\AppData\Roaming\JetBrains\PyCharmXX`
|
||||
* IntelliJ IDEA
|
||||
* macOS: `~/Library/Application Support/JetBrains/IntelliJIdeaXX`
|
||||
* Linux: `~/.config/JetBrains/IntelliJIdeaXX`
|
||||
* Windows: `<User home>\AppData\Roaming\JetBrains\IntelliJIdeaXX`
|
||||
|
||||
Please send your PyCharm/IntelliJ-related bug reports and feature requests to
|
||||
[PyCharm issue tracker](https://youtrack.jetbrains.com/issues/PY).
|
||||
|
||||
|
||||
Feedback
|
||||
--------
|
||||
|
||||
If you want to contribute, send your pull requests to the Python skeletons
|
||||
repository on GitHub. Please make sure, that you follow the conventions above.
|
||||
|
||||
Use [code-quality](http://mail.python.org/mailman/listinfo/code-quality)
|
||||
mailing list to discuss Python skeletons.
|
||||
@@ -1,126 +0,0 @@
|
||||
"""Skeleton for 'StringIO' stdlib module."""
|
||||
|
||||
|
||||
import StringIO as _StringIO
|
||||
|
||||
|
||||
class StringIO(object):
|
||||
"""Reads and writes a string buffer (also known as memory files)."""
|
||||
|
||||
def __init__(self, buffer=None):
|
||||
"""When a StringIO object is created, it can be initialized to an existing
|
||||
string by passing the string to the constructor.
|
||||
|
||||
:type buffer: T <= bytes | unicode
|
||||
:rtype: _StringIO.StringIO[T]
|
||||
"""
|
||||
self.closed = False
|
||||
|
||||
def getvalue(self):
|
||||
"""Retrieve the entire contents of the "file" at any time before the
|
||||
StringIO object's close() method is called.
|
||||
|
||||
:rtype: T
|
||||
"""
|
||||
pass
|
||||
|
||||
def close(self):
|
||||
"""Free the memory buffer.
|
||||
|
||||
:rtype: None
|
||||
"""
|
||||
pass
|
||||
|
||||
def flush(self):
|
||||
"""Flush the internal buffer.
|
||||
|
||||
:rtype: None
|
||||
"""
|
||||
pass
|
||||
|
||||
def isatty(self):
|
||||
"""Return True if the file is connected to a tty(-like) device,
|
||||
else False.
|
||||
|
||||
:rtype: bool
|
||||
"""
|
||||
return False
|
||||
|
||||
def __iter__(self):
|
||||
"""Return an iterator over lines.
|
||||
|
||||
:rtype: _StringIO.StringIO[T]
|
||||
"""
|
||||
return self
|
||||
|
||||
def next(self):
|
||||
"""Returns the next input line.
|
||||
|
||||
:rtype: T
|
||||
"""
|
||||
pass
|
||||
|
||||
def read(self, size=-1):
|
||||
"""Read at most size bytes or characters from the buffer.
|
||||
|
||||
:type size: numbers.Integral
|
||||
:rtype: T
|
||||
"""
|
||||
pass
|
||||
|
||||
def readline(self, size=-1):
|
||||
"""Read one entire line from the buffer.
|
||||
|
||||
:type size: numbers.Integral
|
||||
:rtype: T
|
||||
"""
|
||||
pass
|
||||
|
||||
def readlines(self, sizehint=-1):
|
||||
"""Read until EOF using readline() and return a list containing the
|
||||
lines thus read.
|
||||
|
||||
:type sizehint: numbers.Integral
|
||||
:rtype: list[T]
|
||||
"""
|
||||
pass
|
||||
|
||||
def seek(self, offset, whence=0):
|
||||
"""Set the buffer's current position, like stdio's fseek().
|
||||
|
||||
:type offset: numbers.Integral
|
||||
:type whence: numbers.Integral
|
||||
:rtype: None
|
||||
"""
|
||||
pass
|
||||
|
||||
def tell(self):
|
||||
"""Return the buffer's current position, like stdio's ftell().
|
||||
|
||||
:rtype: int
|
||||
"""
|
||||
pass
|
||||
|
||||
def truncate(self, size=-1):
|
||||
"""Truncate the buffer's size.
|
||||
|
||||
:type size: numbers.Integral
|
||||
:rtype: None
|
||||
"""
|
||||
pass
|
||||
|
||||
def write(self, str):
|
||||
""""Write bytes or a string to the buffer.
|
||||
|
||||
:type str: T
|
||||
:rtype: None
|
||||
"""
|
||||
pass
|
||||
|
||||
def writelines(self, sequence):
|
||||
"""Write a sequence of bytes or strings to the buffer.
|
||||
|
||||
:type sequence: collections.Iterable[T]
|
||||
:rtype: None
|
||||
"""
|
||||
pass
|
||||
@@ -1,98 +0,0 @@
|
||||
# _pytest.mark
|
||||
class MarkGenerator(object):
|
||||
|
||||
def __getattr__(self, item):
|
||||
"""
|
||||
This class may have any attribute, so this method should exist
|
||||
"""
|
||||
pass
|
||||
|
||||
def skipif(self,condition, reason=None):
|
||||
"""skip the given test function if eval(self,condition) results in a True
|
||||
value.
|
||||
|
||||
Optionally specify a reason for better reporting.
|
||||
|
||||
Evaluation happens within the module global context.
|
||||
Example: ``skipif(self,'sys.platform == "win32"')`` skips the test if
|
||||
we are on the win32 platform.
|
||||
|
||||
see http://doc.pytest.org/en/latest/skipping.html
|
||||
"""
|
||||
|
||||
def skip(self,reason=None):
|
||||
"""skip the given test function, optionally specify a reason for better reporting.
|
||||
|
||||
see http://doc.pytest.org/en/latest/skipping.html
|
||||
"""
|
||||
|
||||
def xfail(self,condition=None, reason=None, raises=None, run=True, strict=False):
|
||||
"""mark the the test function as an expected failure if eval(self,condition)
|
||||
has a True value.
|
||||
|
||||
Optionally specify a reason for better reporting and run=False if
|
||||
you don't even want to execute the test function.
|
||||
|
||||
See http://doc.pytest.org/en/latest/skipping.html
|
||||
"""
|
||||
|
||||
def parametrize(self,argnames, argvalues, indirect=False, ids=None, scope=None):
|
||||
""" Add new invocations to the underlying test function using the list
|
||||
of argvalues for the given argnames. Parametrization is performed
|
||||
during the collection phase. If you need to setup expensive resources
|
||||
see about setting indirect to do it rather at test setup time.
|
||||
|
||||
:arg argnames: a comma-separated string denoting one or more argument
|
||||
names, or a list/tuple of argument strings.
|
||||
|
||||
:arg argvalues: The list of argvalues determines how often a
|
||||
test is invoked with different argument values. If only one
|
||||
argname was specified argvalues is a list of values. If N
|
||||
argnames were specified, argvalues must be a list of N-tuples,
|
||||
where each tuple-element specifies a value for its respective
|
||||
argname.
|
||||
|
||||
:arg indirect: The list of argnames or boolean. A list of arguments'
|
||||
names (self,subset of argnames). If True the list contains all names from
|
||||
the argnames. Each argvalue corresponding to an argname in this list will
|
||||
be passed as request.param to its respective argname fixture
|
||||
function so that it can perform more expensive setups during the
|
||||
setup phase of a test rather than at collection time.
|
||||
|
||||
:arg ids: list of string ids, or a callable.
|
||||
If strings, each is corresponding to the argvalues so that they are
|
||||
part of the test id. If None is given as id of specific test, the
|
||||
automatically generated id for that argument will be used.
|
||||
If callable, it should take one argument (self,a single argvalue) and return
|
||||
a string or return None. If None, the automatically generated id for that
|
||||
argument will be used.
|
||||
If no ids are provided they will be generated automatically from
|
||||
the argvalues.
|
||||
|
||||
:arg scope: if specified it denotes the scope of the parameters.
|
||||
The scope is used for grouping tests by parameter instances.
|
||||
It will also override any fixture-function defined scope, allowing
|
||||
to set a dynamic scope using test context or configuration.
|
||||
"""
|
||||
|
||||
def usefixtures(self,*fixturenames):
|
||||
"""mark tests as needing all of the specified fixtures.
|
||||
|
||||
see http://doc.pytest.org/en/latest/fixture.html#usefixtures
|
||||
"""
|
||||
|
||||
def tryfirst(self,f):
|
||||
"""mark a hook implementation function such that the plugin machinery
|
||||
will try to call it first/as early as possible.
|
||||
"""
|
||||
|
||||
def trylast(self,f):
|
||||
"""mark a hook implementation function such that the plugin machinery
|
||||
will try to call it last/as late as possible.
|
||||
"""
|
||||
|
||||
def hookwrapper(self,f):
|
||||
"""A hook wrapper is a generator function which yields exactly once.
|
||||
When pytest invokes hooks it first executes hook wrappers and passes
|
||||
the same arguments as to the regular hooks.
|
||||
"""
|
||||
@@ -1,6 +0,0 @@
|
||||
from alembic.operations import Operations
|
||||
from alembic.environment import EnvironmentContext
|
||||
|
||||
op = Operations()
|
||||
context = EnvironmentContext()
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
# coding=utf-8
|
||||
"""
|
||||
Python Behave skeletons (https://pythonhosted.org/behave/)
|
||||
"""
|
||||
|
||||
|
||||
def given(pattern):
|
||||
"""Decorates a function, so that it will become a new step
|
||||
definition.
|
||||
:param pattern pattern to match, may be regular expression or something else depends on step matcher
|
||||
"""
|
||||
pass
|
||||
|
||||
def when(pattern):
|
||||
"""Decorates a function, so that it will become a new step
|
||||
definition.
|
||||
:param pattern pattern to match, may be regular expression or something else depends on step matcher
|
||||
"""
|
||||
pass
|
||||
|
||||
def then(pattern):
|
||||
"""Decorates a function, so that it will become a new step
|
||||
definition.
|
||||
:param pattern pattern to match, may be regular expression or something else depends on step matcher
|
||||
"""
|
||||
pass
|
||||
|
||||
def step(pattern):
|
||||
"""Decorates a function, so that it will become a new step
|
||||
definition.
|
||||
:param pattern pattern to match, may be regular expression or something else depends on step matcher
|
||||
"""
|
||||
pass
|
||||
def Given(pattern):
|
||||
"""Decorates a function, so that it will become a new step
|
||||
definition.
|
||||
:param pattern pattern to match, may be regular expression or something else depends on step matcher
|
||||
"""
|
||||
pass
|
||||
|
||||
def When(pattern):
|
||||
"""Decorates a function, so that it will become a new step
|
||||
definition.
|
||||
:param pattern pattern to match, may be regular expression or something else depends on step matcher
|
||||
"""
|
||||
pass
|
||||
|
||||
def Then(pattern):
|
||||
"""Decorates a function, so that it will become a new step
|
||||
definition.
|
||||
:param pattern pattern to match, may be regular expression or something else depends on step matcher
|
||||
"""
|
||||
pass
|
||||
|
||||
def Step(pattern):
|
||||
"""Decorates a function, so that it will become a new step
|
||||
definition.
|
||||
:param pattern pattern to match, may be regular expression or something else depends on step matcher
|
||||
"""
|
||||
pass
|
||||
@@ -1,131 +0,0 @@
|
||||
"""Skeleton for 'cStringIO' stdlib module."""
|
||||
|
||||
|
||||
import cStringIO
|
||||
|
||||
|
||||
def StringIO(s=None):
|
||||
"""Return a StringIO-like stream for reading or writing.
|
||||
|
||||
:type s: T <= bytes | unicode
|
||||
:rtype: cStringIO.OutputType[T]
|
||||
"""
|
||||
return cStringIO.OutputType(s)
|
||||
|
||||
|
||||
class OutputType(object):
|
||||
def __init__(self, s):
|
||||
"""Create an OutputType object.
|
||||
|
||||
:rtype: cStringIO.OutputType[T <= bytes | unicode]
|
||||
"""
|
||||
pass
|
||||
|
||||
def getvalue(self):
|
||||
"""Retrieve the entire contents of the "file" at any time before the
|
||||
StringIO object's close() method is called.
|
||||
|
||||
:rtype: T
|
||||
"""
|
||||
pass
|
||||
|
||||
def close(self):
|
||||
"""Free the memory buffer.
|
||||
|
||||
:rtype: None
|
||||
"""
|
||||
pass
|
||||
|
||||
def flush(self):
|
||||
"""Flush the internal buffer.
|
||||
|
||||
:rtype: None
|
||||
"""
|
||||
pass
|
||||
|
||||
def isatty(self):
|
||||
"""Return True if the file is connected to a tty(-like) device,
|
||||
else False.
|
||||
|
||||
:rtype: bool
|
||||
"""
|
||||
return False
|
||||
|
||||
def __iter__(self):
|
||||
"""Return an iterator over lines.
|
||||
|
||||
:rtype: cStringIO.OutputType[T]
|
||||
"""
|
||||
return self
|
||||
|
||||
def next(self):
|
||||
"""Returns the next input line.
|
||||
|
||||
:rtype: T
|
||||
"""
|
||||
pass
|
||||
|
||||
def read(self, size=-1):
|
||||
"""Read at most size bytes or characters from the buffer.
|
||||
|
||||
:type size: numbers.Integral
|
||||
:rtype: T
|
||||
"""
|
||||
pass
|
||||
|
||||
def readline(self, size=-1):
|
||||
"""Read one entire line from the buffer.
|
||||
|
||||
:type size: numbers.Integral
|
||||
:rtype: T
|
||||
"""
|
||||
pass
|
||||
|
||||
def readlines(self, sizehint=-1):
|
||||
"""Read until EOF using readline() and return a list containing the
|
||||
lines thus read.
|
||||
|
||||
:type sizehint: numbers.Integral
|
||||
:rtype: list[T]
|
||||
"""
|
||||
return []
|
||||
|
||||
def seek(self, offset, whence=0):
|
||||
"""Set the buffer's current position, like stdio's fseek().
|
||||
|
||||
:type offset: numbers.Integral
|
||||
:type whence: numbers.Integral
|
||||
:rtype: None
|
||||
"""
|
||||
pass
|
||||
|
||||
def tell(self):
|
||||
"""Return the buffer's current position, like stdio's ftell().
|
||||
|
||||
:rtype: int
|
||||
"""
|
||||
return 0
|
||||
|
||||
def truncate(self, size=-1):
|
||||
"""Truncate the buffer's size.
|
||||
|
||||
:type size: numbers.Integral
|
||||
:rtype: None
|
||||
"""
|
||||
pass
|
||||
|
||||
def write(self, str):
|
||||
""""Write bytes or a string to the buffer.
|
||||
|
||||
:type str: T
|
||||
:rtype: None
|
||||
"""
|
||||
pass
|
||||
|
||||
def writelines(self, sequence):
|
||||
"""Write a sequence of bytes or strings to the buffer.
|
||||
|
||||
:type sequence: collections.Iterable[T]
|
||||
:rtype: None
|
||||
"""
|
||||
pass
|
||||
@@ -1,19 +0,0 @@
|
||||
"""Skeleton for 'copy' stdlib module."""
|
||||
|
||||
|
||||
def copy(x):
|
||||
"""Return a shallow copy of x.
|
||||
|
||||
:type x: T
|
||||
:rtype: T
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def deepcopy(x):
|
||||
"""Return a deep copy of x.
|
||||
|
||||
:type x: T
|
||||
:rtype: T
|
||||
"""
|
||||
pass
|
||||
@@ -1,5 +0,0 @@
|
||||
"""Skeleton for 'nose' module.
|
||||
|
||||
Project: nose 1.3 <https://nose.readthedocs.org/>
|
||||
Skeleton by: Andrey Vlasovskikh <andrey.vlasovskikh@jetbrains.com>
|
||||
"""
|
||||
@@ -1,181 +0,0 @@
|
||||
"""Skeleton for 'nose.tools' module.
|
||||
|
||||
Project: nose 1.3 <https://nose.readthedocs.org/>
|
||||
Skeleton by: Andrey Vlasovskikh <andrey.vlasovskikh@jetbrains.com>
|
||||
"""
|
||||
|
||||
|
||||
import sys
|
||||
|
||||
|
||||
def assert_equal(first, second, msg=None):
|
||||
"""Fail if the two objects are unequal as determined by the '==' operator.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def assert_not_equal(first, second, msg=None):
|
||||
"""Fail if the two objects are equal as determined by the '==' operator.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def assert_true(expr, msg=None):
|
||||
"""Check that the expression is true."""
|
||||
pass
|
||||
|
||||
|
||||
def assert_false(expr, msg=None):
|
||||
"""Check that the expression is false."""
|
||||
pass
|
||||
|
||||
|
||||
if sys.version_info >= (2, 7):
|
||||
def assert_is(expr1, expr2, msg=None):
|
||||
"""Just like assert_true(a is b), but with a nicer default message."""
|
||||
pass
|
||||
|
||||
def assert_is_not(expr1, expr2, msg=None):
|
||||
"""Just like assert_true(a is not b), but with a nicer default message.
|
||||
"""
|
||||
pass
|
||||
|
||||
def assert_is_none(obj, msg=None):
|
||||
"""Same as assert_true(obj is None), with a nicer default message.
|
||||
"""
|
||||
pass
|
||||
|
||||
def assert_is_not_none(obj, msg=None):
|
||||
"""Included for symmetry with assert_is_none."""
|
||||
pass
|
||||
|
||||
def assert_in(member, container, msg=None):
|
||||
"""Just like assert_true(a in b), but with a nicer default message."""
|
||||
pass
|
||||
|
||||
def assert_not_in(member, container, msg=None):
|
||||
"""Just like assert_true(a not in b), but with a nicer default message.
|
||||
"""
|
||||
pass
|
||||
|
||||
def assert_is_instance(obj, cls, msg=None):
|
||||
"""Same as assert_true(isinstance(obj, cls)), with a nicer default
|
||||
message.
|
||||
"""
|
||||
pass
|
||||
|
||||
def assert_not_is_instance(obj, cls, msg=None):
|
||||
"""Included for symmetry with assert_is_instance."""
|
||||
pass
|
||||
|
||||
|
||||
def assert_raises(excClass, callableObj=None, *args, **kwargs):
|
||||
"""Fail unless an exception of class excClass is thrown by callableObj when
|
||||
invoked with arguments args and keyword arguments kwargs.
|
||||
|
||||
If called with callableObj omitted or None, will return a
|
||||
context object used like this::
|
||||
|
||||
with assert_raises(SomeException):
|
||||
do_something()
|
||||
|
||||
:rtype: unittest.case._AssertRaisesContext | None
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
if sys.version_info >= (2, 7):
|
||||
def assert_raises_regexp(expected_exception, expected_regexp,
|
||||
callable_obj=None, *args, **kwargs):
|
||||
"""Asserts that the message in a raised exception matches a regexp.
|
||||
|
||||
:rtype: unittest.case._AssertRaisesContext | None
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def assert_almost_equal(first, second, places=None, msg=None, delta=None):
|
||||
"""Fail if the two objects are unequal as determined by their difference
|
||||
rounded to the given number of decimal places (default 7) and comparing to
|
||||
zero, or by comparing that the between the two objects is more than the
|
||||
given delta.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def assert_not_almost_equal(first, second, places=None, msg=None, delta=None):
|
||||
"""Fail if the two objects are equal as determined by their difference
|
||||
rounded to the given number of decimal places (default 7) and comparing to
|
||||
zero, or by comparing that the between the two objects is less than the
|
||||
given delta.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
if sys.version_info >= (2, 7):
|
||||
def assert_greater(a, b, msg=None):
|
||||
"""Just like assert_true(a > b), but with a nicer default message."""
|
||||
pass
|
||||
|
||||
def assert_greater_equal(a, b, msg=None):
|
||||
"""Just like assert_true(a >= b), but with a nicer default message."""
|
||||
pass
|
||||
|
||||
def assert_less(a, b, msg=None):
|
||||
"""Just like assert_true(a < b), but with a nicer default message."""
|
||||
pass
|
||||
|
||||
def assert_less_equal(a, b, msg=None):
|
||||
"""Just like self.assertTrue(a <= b), but with a nicer default
|
||||
message.
|
||||
"""
|
||||
pass
|
||||
|
||||
def assert_regexp_matches(text, expected_regexp, msg=None):
|
||||
"""Fail the test unless the text matches the regular expression."""
|
||||
pass
|
||||
|
||||
def assert_not_regexp_matches(text, unexpected_regexp, msg=None):
|
||||
"""Fail the test if the text matches the regular expression."""
|
||||
pass
|
||||
|
||||
def assert_items_equal(expected_seq, actual_seq, msg=None):
|
||||
"""An unordered sequence specific comparison. It asserts that
|
||||
actual_seq and expected_seq have the same element counts.
|
||||
"""
|
||||
pass
|
||||
|
||||
def assert_dict_contains_subset(expected, actual, msg=None):
|
||||
"""Checks whether actual is a superset of expected."""
|
||||
pass
|
||||
|
||||
def assert_multi_line_equal(first, second, msg=None):
|
||||
"""Assert that two multi-line strings are equal."""
|
||||
pass
|
||||
|
||||
def assert_sequence_equal(seq1, seq2, msg=None, seq_type=None):
|
||||
"""An equality assertion for ordered sequences (like lists and tuples).
|
||||
"""
|
||||
pass
|
||||
|
||||
def assert_list_equal(list1, list2, msg=None):
|
||||
"""A list-specific equality assertion."""
|
||||
pass
|
||||
|
||||
def assert_tuple_equal(tuple1, tuple2, msg=None):
|
||||
"""A tuple-specific equality assertion."""
|
||||
pass
|
||||
|
||||
def assert_set_equal(set1, set2, msg=None):
|
||||
"""A set-specific equality assertion."""
|
||||
pass
|
||||
|
||||
def assert_dict_equal(d1, d2, msg=None):
|
||||
"""A dict-specific equality assertion."""
|
||||
pass
|
||||
|
||||
|
||||
assert_equals = assert_equal
|
||||
assert_not_equals = assert_not_equal
|
||||
assert_almost_equals = assert_almost_equal
|
||||
assert_not_almost_equals = assert_not_almost_equal
|
||||
@@ -1,10 +0,0 @@
|
||||
"""Skeleton for 'numpy' module.
|
||||
|
||||
Project: NumPy 1.8.0 <http://www.numpy.org//>
|
||||
"""
|
||||
|
||||
from . import core
|
||||
from .core import *
|
||||
|
||||
__all__ = []
|
||||
__all__.extend(core.__all__)
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,819 +0,0 @@
|
||||
class ndarray(object):
|
||||
"""
|
||||
ndarray(shape, dtype=float, buffer=None, offset=0,
|
||||
strides=None, order=None)
|
||||
|
||||
An array object represents a multidimensional, homogeneous array
|
||||
of fixed-size items. An associated data-type object describes the
|
||||
format of each element in the array (its byte-order, how many bytes it
|
||||
occupies in memory, whether it is an integer, a floating point number,
|
||||
or something else, etc.)
|
||||
|
||||
Arrays should be constructed using `array`, `zeros` or `empty` (refer
|
||||
to the See Also section below). The parameters given here refer to
|
||||
a low-level method (`ndarray(...)`) for instantiating an array.
|
||||
|
||||
For more information, refer to the `numpy` module and examine the
|
||||
the methods and attributes of an array.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
(for the __new__ method; see Notes below)
|
||||
|
||||
shape : tuple of ints
|
||||
Shape of created array.
|
||||
dtype : data-type, optional
|
||||
Any object that can be interpreted as a numpy data type.
|
||||
buffer : object exposing buffer interface, optional
|
||||
Used to fill the array with data.
|
||||
offset : int, optional
|
||||
Offset of array data in buffer.
|
||||
strides : tuple of ints, optional
|
||||
Strides of data in memory.
|
||||
order : {'C', 'F'}, optional
|
||||
Row-major or column-major order.
|
||||
|
||||
Attributes
|
||||
----------
|
||||
T : ndarray
|
||||
Transpose of the array.
|
||||
data : buffer
|
||||
The array's elements, in memory.
|
||||
dtype : dtype object
|
||||
Describes the format of the elements in the array.
|
||||
flags : dict
|
||||
Dictionary containing information related to memory use, e.g.,
|
||||
'C_CONTIGUOUS', 'OWNDATA', 'WRITEABLE', etc.
|
||||
flat : numpy.flatiter object
|
||||
Flattened version of the array as an iterator. The iterator
|
||||
allows assignments, e.g., ``x.flat = 3`` (See `ndarray.flat` for
|
||||
assignment examples; TODO).
|
||||
imag : ndarray
|
||||
Imaginary part of the array.
|
||||
real : ndarray
|
||||
Real part of the array.
|
||||
size : int
|
||||
Number of elements in the array.
|
||||
itemsize : int
|
||||
The memory use of each array element in bytes.
|
||||
nbytes : int
|
||||
The total number of bytes required to store the array data,
|
||||
i.e., ``itemsize * size``.
|
||||
ndim : int
|
||||
The array's number of dimensions.
|
||||
shape : tuple of ints
|
||||
Shape of the array.
|
||||
strides : tuple of ints
|
||||
The step-size required to move from one element to the next in
|
||||
memory. For example, a contiguous ``(3, 4)`` array of type
|
||||
``int16`` in C-order has strides ``(8, 2)``. This implies that
|
||||
to move from element to element in memory requires jumps of 2 bytes.
|
||||
To move from row-to-row, one needs to jump 8 bytes at a time
|
||||
(``2 * 4``).
|
||||
ctypes : ctypes object
|
||||
Class containing properties of the array needed for interaction
|
||||
with ctypes.
|
||||
base : ndarray
|
||||
If the array is a view into another array, that array is its `base`
|
||||
(unless that array is also a view). The `base` array is where the
|
||||
array data is actually stored.
|
||||
|
||||
See Also
|
||||
--------
|
||||
array : Construct an array.
|
||||
zeros : Create an array, each element of which is zero.
|
||||
empty : Create an array, but leave its allocated memory unchanged (i.e.,
|
||||
it contains "garbage").
|
||||
dtype : Create a data-type.
|
||||
|
||||
Notes
|
||||
-----
|
||||
There are two modes of creating an array using ``__new__``:
|
||||
|
||||
1. If `buffer` is None, then only `shape`, `dtype`, and `order`
|
||||
are used.
|
||||
2. If `buffer` is an object exposing the buffer interface, then
|
||||
all keywords are interpreted.
|
||||
|
||||
No ``__init__`` method is needed because the array is fully initialized
|
||||
after the ``__new__`` method.
|
||||
|
||||
Examples
|
||||
--------
|
||||
These examples illustrate the low-level `ndarray` constructor. Refer
|
||||
to the `See Also` section above for easier ways of constructing an
|
||||
ndarray.
|
||||
|
||||
First mode, `buffer` is None:
|
||||
|
||||
>>> np.ndarray(shape=(2,2), dtype=float, order='F')
|
||||
array([[ -1.13698227e+002, 4.25087011e-303],
|
||||
[ 2.88528414e-306, 3.27025015e-309]]) #random
|
||||
|
||||
Second mode:
|
||||
|
||||
>>> np.ndarray((2,), buffer=np.array([1,2,3]),
|
||||
... offset=np.int_().itemsize,
|
||||
... dtype=int) # offset = 1*itemsize, i.e. skip first element
|
||||
array([2, 3])
|
||||
"""
|
||||
pass
|
||||
|
||||
def __mul__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__mul__(y) <==> x*y
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __neg__(self, *args, **kwargs): # real signature unknown
|
||||
"""
|
||||
x.__neg__() <==> -x
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __rmul__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__rmul__(y) <==> y*x
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __abs__(self): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__abs__() <==> abs(x)
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __add__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__add__(y) <==> x+y
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __radd__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__radd__(y) <==> y+x
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __copy__(self, order=None): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
a.__copy__([order])
|
||||
|
||||
Return a copy of the array.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
order : {'C', 'F', 'A'}, optional
|
||||
If order is 'C' (False) then the result is contiguous (default).
|
||||
If order is 'Fortran' (True) then the result has fortran order.
|
||||
If order is 'Any' (None) then the result has fortran order
|
||||
only if the array already is in fortran order.
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __div__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__div__(y) <==> x/y
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __rdiv__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__rdiv__(y) <==> y/x
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __truediv__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__truediv__(y) <==> x/y
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __rtruediv__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__rtruediv__(y) <==> y/x
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __floordiv__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__floordiv__(y) <==> x//y
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __rfloordiv__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__rfloordiv__(y) <==> y//x
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __mod__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__mod__(y) <==> x%y
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __rmod__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__rmod__(y) <==> y%x
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __lshift__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__lshift__(y) <==> x<<y
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __rlshift__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__rlshift__(y) <==> y<<x
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __rshift__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__rshift__(y) <==> x>>y
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __rrshift__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__rrshift__(y) <==> y>>x
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __and__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__and__(y) <==> x&y
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __rand__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__rand__(y) <==> y&x
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __or__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__or__(y) <==> x|y
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __pos__(self, *args, **kwargs): # real signature unknown
|
||||
"""
|
||||
x.__pos__() <==> +x
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __ror__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__ror__(y) <==> y|x
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __xor__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__xor__(y) <==> x^y
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __rxor__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__rxor__(y) <==> y^x
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __ge__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__ge__(y) <==> x>=y
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __rge__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__rge__(y) <==> y>=x
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __eq__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__eq__(y) <==> x==y
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __req__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__req__(y) <==> y==x
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __sub__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__sub__(y) <==> x-y
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __rsub__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__rsub__(y) <==> y-x
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __lt__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__lt__(y) <==> x<y
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __rlt__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__rlt__(y) <==> y<x
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __le__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__le__(y) <==> x<=y
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __rle__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__rle__(y) <==> y<=x
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __gt__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__gt__(y) <==> x>y
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __rgt__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__rgt__(y) <==> y>x
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __ne__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__ne__(y) <==> x!=y
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __rne__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__rne__(y) <==> y!=x
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __iadd__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__iadd__(y) <==> x+=y
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __riadd__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__riadd__(y) <==> y+=x
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __isub__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__isub__(y) <==> x-=y
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __risub__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__risub__(y) <==> y-=x
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __imul__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__imul__(y) <==> x*=y
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __rimul__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__rimul__(y) <==> y*=x
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __idiv__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__idiv__(y) <==> x/=y
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __ridiv__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__ridiv__(y) <==> y/=x
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __itruediv__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__itruediv__(y) <==> x/y
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __ritruediv__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__ritruediv__(y) <==> y/x
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __ifloordiv__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__ifloordiv__(y) <==> x//y
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __rifloordiv__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__rifloordiv__(y) <==> y//x
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __imod__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__imod__(y) <==> x%=y
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __rimod__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__rimod__(y) <==> y%=x
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __ipow__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__ipow__(y) <==> x**=y
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __ripow__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__ripow__(y) <==> y**=x
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __ilshift__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__ilshift__(y) <==> x<<=y
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __rilshift__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__rilshift__(y) <==> y<<=x
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __irshift__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__irshift__(y) <==> x>>=y
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __rirshift__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__rirshift__(y) <==> y>>=x
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __iand__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__iand__(y) <==> x&=y
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __riand__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__riand__(y) <==> y&=x
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __invert__(self, *args, **kwargs): # real signature unknown
|
||||
"""
|
||||
x.__invert__() <==> ~x
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __ior__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__ior__(y) <==> x|=y
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __rior__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__rior__(y) <==> y|=x
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __ixor__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__ixor__(y) <==> x^=y
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __rixor__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__rixor__(y) <==> y^=x
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __pow__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__pow__(y) <==> x**y
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
|
||||
def __divmod__(self, y): # real signature unknown; restored from __doc__
|
||||
"""
|
||||
x.__divmod__(y) <==> x%y
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
"""
|
||||
pass
|
||||
@@ -1,9 +0,0 @@
|
||||
"""Skeleton for py.path.
|
||||
|
||||
Project: py 1.4.31 <https://bitbucket.org/pytest-dev/py>
|
||||
Skeleton by: Aleks Bunin <github@compuix.com>
|
||||
"""
|
||||
|
||||
from . import path
|
||||
from . import error
|
||||
import py.error as error
|
||||
@@ -1 +0,0 @@
|
||||
from errno import *
|
||||
@@ -1,629 +0,0 @@
|
||||
""" unified file system api """
|
||||
|
||||
|
||||
# py.path.common
|
||||
class NeverRaised(Exception):
|
||||
pass
|
||||
|
||||
class PathBase(object):
|
||||
""" shared implementation for filesystem path objects."""
|
||||
|
||||
def basename(self):
|
||||
""" basename part of path. """
|
||||
|
||||
def dirname(self):
|
||||
""" dirname part of path. """
|
||||
|
||||
def purebasename(self):
|
||||
""" pure base name of the path."""
|
||||
|
||||
def ext(self):
|
||||
""" extension of the path (including the '.')."""
|
||||
|
||||
def dirpath(self, *args, **kwargs):
|
||||
""" return the directory path joined with any given path arguments. """
|
||||
|
||||
def read_binary(self):
|
||||
""" read and return a bytestring from reading the path. """
|
||||
|
||||
def read_text(self, encoding):
|
||||
""" read and return a Unicode string from reading the path. """
|
||||
|
||||
|
||||
def read(self, mode='r'):
|
||||
""" read and return a bytestring from reading the path. """
|
||||
|
||||
def readlines(self, cr=1):
|
||||
""" read and return a list of lines from the path. if cr is False, the
|
||||
newline will be removed from the end of each line. """
|
||||
|
||||
def load(self):
|
||||
""" (deprecated) return object unpickled from self.read() """
|
||||
|
||||
def move(self, target):
|
||||
""" move this path to target. """
|
||||
|
||||
def __repr__(self):
|
||||
""" return a string representation of this path. """
|
||||
|
||||
def check(self, **kw):
|
||||
""" check a path for existence and properties.
|
||||
|
||||
Without arguments, return True if the path exists, otherwise False.
|
||||
|
||||
valid checkers::
|
||||
|
||||
file=1 # is a file
|
||||
file=0 # is not a file (may not even exist)
|
||||
dir=1 # is a dir
|
||||
link=1 # is a link
|
||||
exists=1 # exists
|
||||
|
||||
You can specify multiple checker definitions, for example::
|
||||
|
||||
path.check(file=1, link=1) # a link pointing to a file
|
||||
"""
|
||||
|
||||
def fnmatch(self, pattern):
|
||||
"""return true if the basename/fullname matches the glob-'pattern'.
|
||||
|
||||
valid pattern characters::
|
||||
|
||||
* matches everything
|
||||
? matches any single character
|
||||
[seq] matches any character in seq
|
||||
[!seq] matches any char not in seq
|
||||
|
||||
If the pattern contains a path-separator then the full path
|
||||
is used for pattern matching and a '*' is prepended to the
|
||||
pattern.
|
||||
|
||||
if the pattern doesn't contain a path-separator the pattern
|
||||
is only matched against the basename.
|
||||
"""
|
||||
|
||||
def relto(self, relpath):
|
||||
""" return a string which is the relative part of the path
|
||||
to the given 'relpath'.
|
||||
"""
|
||||
|
||||
def ensure_dir(self, *args):
|
||||
""" ensure the path joined with args is a directory. """
|
||||
|
||||
def bestrelpath(self, dest):
|
||||
""" return a string which is a relative path from self
|
||||
(assumed to be a directory) to dest such that
|
||||
self.join(bestrelpath) == dest and if not such
|
||||
path can be determined return dest.
|
||||
"""
|
||||
|
||||
def exists(self):
|
||||
""" check a path for existence """
|
||||
|
||||
def isdir(self):
|
||||
""" check a directory for existence. """
|
||||
|
||||
def isfile(self):
|
||||
""" check a file for existence. """
|
||||
|
||||
def parts(self, reverse=False):
|
||||
""" return a root-first list of all ancestor directories
|
||||
plus the path itself.
|
||||
"""
|
||||
|
||||
def common(self, other):
|
||||
""" return the common part shared with the other path
|
||||
or None if there is no common part.
|
||||
"""
|
||||
|
||||
def visit(self, fil=None, rec=None, ignore=NeverRaised, bf=False, sort=False):
|
||||
""" yields all paths below the current one
|
||||
|
||||
fil is a filter (glob pattern or callable), if not matching the
|
||||
path will not be yielded, defaulting to None (everything is
|
||||
returned)
|
||||
|
||||
rec is a filter (glob pattern or callable) that controls whether
|
||||
a node is descended, defaulting to None
|
||||
|
||||
ignore is an Exception class that is ignoredwhen calling dirlist()
|
||||
on any of the paths (by default, all exceptions are reported)
|
||||
|
||||
bf if True will cause a breadthfirst search instead of the
|
||||
default depthfirst. Default: False
|
||||
|
||||
sort if True will sort entries within each directory level.
|
||||
"""
|
||||
|
||||
def samefile(self, other):
|
||||
""" return True if other refers to the same stat object as self. """
|
||||
|
||||
|
||||
# py.path.local
|
||||
class PosixPath(PathBase):
|
||||
def chown(self, user, group, rec=0):
|
||||
""" change ownership to the given user and group.
|
||||
user and group may be specified by a number or
|
||||
by a name. if rec is True change ownership
|
||||
recursively.
|
||||
"""
|
||||
|
||||
def readlink(self):
|
||||
""" return value of a symbolic link. """
|
||||
|
||||
def mklinkto(self, oldname):
|
||||
""" posix style hard link to another name. """
|
||||
|
||||
def mksymlinkto(self, value, absolute=1):
|
||||
""" create a symbolic link with the given value (pointing to another name). """
|
||||
|
||||
|
||||
class LocalPath(PosixPath):
|
||||
""" object oriented interface to os.path and other local filesystem
|
||||
related information.
|
||||
"""
|
||||
class ImportMismatchError(ImportError):
|
||||
""" raised on pyimport() if there is a mismatch of __file__'s"""
|
||||
|
||||
def __init__(self, path=None, expanduser=False):
|
||||
""" Initialize and return a local Path instance.
|
||||
|
||||
Path can be relative to the current directory.
|
||||
If path is None it defaults to the current working directory.
|
||||
If expanduser is True, tilde-expansion is performed.
|
||||
Note that Path instances always carry an absolute path.
|
||||
Note also that passing in a local path object will simply return
|
||||
the exact same path object. Use new() to get a new copy.
|
||||
"""
|
||||
|
||||
def samefile(self, other):
|
||||
""" return True if 'other' references the same file as 'self'.
|
||||
"""
|
||||
|
||||
def remove(self, rec=1, ignore_errors=False):
|
||||
""" remove a file or directory (or a directory tree if rec=1).
|
||||
if ignore_errors is True, errors while removing directories will
|
||||
be ignored.
|
||||
"""
|
||||
|
||||
def computehash(self, hashtype="md5", chunksize=524288):
|
||||
""" return hexdigest of hashvalue for this file. """
|
||||
|
||||
def new(self, **kw):
|
||||
""" create a modified version of this path.
|
||||
the following keyword arguments modify various path parts::
|
||||
|
||||
a:/some/path/to/a/file.ext
|
||||
xx drive
|
||||
xxxxxxxxxxxxxxxxx dirname
|
||||
xxxxxxxx basename
|
||||
xxxx purebasename
|
||||
xxx ext
|
||||
"""
|
||||
|
||||
def dirpath(self, *args, **kwargs):
|
||||
""" return the directory path joined with any given path arguments. """
|
||||
|
||||
def join(self, *args, **kwargs):
|
||||
""" return a new path by appending all 'args' as path
|
||||
components. if abs=1 is used restart from root if any
|
||||
of the args is an absolute path.
|
||||
"""
|
||||
|
||||
def open(self, mode='r', ensure=False, encoding=None):
|
||||
""" return an opened file with the given mode.
|
||||
|
||||
If ensure is True, create parent directories if needed.
|
||||
"""
|
||||
|
||||
def islink(self):
|
||||
pass
|
||||
|
||||
def check(self, **kw):
|
||||
pass
|
||||
|
||||
def listdir(self, fil=None, sort=None):
|
||||
""" list directory contents, possibly filter by the given fil func
|
||||
and possibly sorted.
|
||||
"""
|
||||
|
||||
def size(self):
|
||||
""" return size of the underlying file object """
|
||||
|
||||
def mtime(self):
|
||||
""" return last modification time of the path. """
|
||||
|
||||
def copy(self, target, mode=False, stat=False):
|
||||
""" copy path to target.
|
||||
|
||||
If mode is True, will copy copy permission from path to target.
|
||||
If stat is True, copy permission, last modification
|
||||
time, last access time, and flags from path to target.
|
||||
"""
|
||||
|
||||
def rename(self, target):
|
||||
""" rename this path to target. """
|
||||
|
||||
def dump(self, obj, bin=1):
|
||||
""" pickle object into path location"""
|
||||
|
||||
def mkdir(self, *args):
|
||||
""" create & return the directory joined with args. """
|
||||
|
||||
def write_binary(self, data, ensure=False):
|
||||
""" write binary data into path. If ensure is True create
|
||||
missing parent directories.
|
||||
"""
|
||||
|
||||
def write_text(self, data, encoding, ensure=False):
|
||||
""" write text data into path using the specified encoding.
|
||||
If ensure is True create missing parent directories.
|
||||
"""
|
||||
|
||||
def write(self, data, mode='w', ensure=False):
|
||||
""" write data into path. If ensure is True create
|
||||
missing parent directories.
|
||||
"""
|
||||
|
||||
def ensure(self, *args, **kwargs):
|
||||
""" ensure that an args-joined path exists (by default as
|
||||
a file). if you specify a keyword argument 'dir=True'
|
||||
then the path is forced to be a directory path.
|
||||
"""
|
||||
|
||||
def stat(self, raising=True):
|
||||
""" Return an os.stat() tuple. """
|
||||
|
||||
def lstat(self):
|
||||
""" Return an os.lstat() tuple. """
|
||||
|
||||
def setmtime(self, mtime=None):
|
||||
""" set modification time for the given path. if 'mtime' is None
|
||||
(the default) then the file's mtime is set to current time.
|
||||
|
||||
Note that the resolution for 'mtime' is platform dependent.
|
||||
"""
|
||||
|
||||
def chdir(self):
|
||||
""" change directory to self and return old current directory """
|
||||
|
||||
def realpath(self):
|
||||
""" return a new path which contains no symbolic links."""
|
||||
|
||||
def atime(self):
|
||||
""" return last access time of the path. """
|
||||
|
||||
def chmod(self, mode, rec=0):
|
||||
""" change permissions to the given mode. If mode is an
|
||||
integer it directly encodes the os-specific modes.
|
||||
if rec is True perform recursively.
|
||||
"""
|
||||
|
||||
def pypkgpath(self):
|
||||
""" return the Python package path by looking for the last
|
||||
directory upwards which still contains an __init__.py.
|
||||
Return None if a pkgpath can not be determined.
|
||||
"""
|
||||
|
||||
def pyimport(self, modname=None, ensuresyspath=True):
|
||||
""" return path as an imported python module.
|
||||
|
||||
If modname is None, look for the containing package
|
||||
and construct an according module name.
|
||||
The module will be put/looked up in sys.modules.
|
||||
if ensuresyspath is True then the root dir for importing
|
||||
the file (taking __init__.py files into account) will
|
||||
be prepended to sys.path if it isn't there already.
|
||||
If ensuresyspath=="append" the root dir will be appended
|
||||
if it isn't already contained in sys.path.
|
||||
if ensuresyspath is False no modification of syspath happens.
|
||||
"""
|
||||
|
||||
def sysexec(self, *argv, **popen_opts):
|
||||
""" return stdout text from executing a system child process,
|
||||
where the 'self' path points to executable.
|
||||
The process is directly invoked and not through a system shell.
|
||||
"""
|
||||
|
||||
def sysfind(cls, name, checker=None, paths=None):
|
||||
""" return a path object found by looking at the systems
|
||||
underlying PATH specification. If the checker is not None
|
||||
it will be invoked to filter matching paths. If a binary
|
||||
cannot be found, None is returned
|
||||
Note: This is probably not working on plain win32 systems
|
||||
but may work on cygwin.
|
||||
"""
|
||||
|
||||
def get_temproot(cls):
|
||||
""" return the system's temporary directory
|
||||
(where tempfiles are usually created in)
|
||||
"""
|
||||
|
||||
def mkdtemp(cls, rootdir=None):
|
||||
""" return a Path object pointing to a fresh new temporary directory
|
||||
(which we created ourself).
|
||||
"""
|
||||
|
||||
def make_numbered_dir(cls, prefix='session-', rootdir=None, keep=3,
|
||||
lock_timeout = 172800): # two days
|
||||
""" return unique directory with a number greater than the current
|
||||
maximum one. The number is assumed to start directly after prefix.
|
||||
if keep is true directories with a number less than (maxnum-keep)
|
||||
will be removed.
|
||||
"""
|
||||
|
||||
local = LocalPath
|
||||
|
||||
|
||||
# py.path.cacheutil
|
||||
|
||||
"""
|
||||
This module contains multithread-safe cache implementations.
|
||||
|
||||
All Caches have
|
||||
|
||||
getorbuild(key, builder)
|
||||
delentry(key)
|
||||
|
||||
methods and allow configuration when instantiating the cache class.
|
||||
"""
|
||||
|
||||
class BasicCache(object):
|
||||
""" BasicCache class.
|
||||
"""
|
||||
|
||||
|
||||
class BuildcostAccessCache(BasicCache):
|
||||
""" A BuildTime/Access-counting cache implementation.
|
||||
the weight of a value is computed as the product of
|
||||
|
||||
num-accesses-of-a-value * time-to-build-the-value
|
||||
|
||||
The values with the least such weights are evicted
|
||||
if the cache maxentries threshold is superceded.
|
||||
For implementation flexibility more than one object
|
||||
might be evicted at a time.
|
||||
"""
|
||||
|
||||
|
||||
class AgingCache(BasicCache):
|
||||
""" This cache prunes out cache entries that are too old.
|
||||
"""
|
||||
|
||||
|
||||
# py.path.svnwc
|
||||
|
||||
class SvnPathBase(PathBase):
|
||||
""" Base implementation for SvnPath implementations. """
|
||||
|
||||
def new(self, **kw):
|
||||
""" create a modified version of this path. A 'rev' argument
|
||||
indicates a new revision.
|
||||
the following keyword arguments modify various path parts::
|
||||
|
||||
http://host.com/repo/path/file.ext
|
||||
|-----------------------| dirname
|
||||
|------| basename
|
||||
|--| purebasename
|
||||
|--| ext
|
||||
"""
|
||||
|
||||
def join(self, *args):
|
||||
""" return a new Path (with the same revision) which is composed
|
||||
of the self Path followed by 'args' path components.
|
||||
"""
|
||||
|
||||
def propget(self, name):
|
||||
""" return the content of the given property. """
|
||||
|
||||
def proplist(self):
|
||||
""" list all property names. """
|
||||
|
||||
def size(self):
|
||||
""" Return the size of the file content of the Path. """
|
||||
|
||||
def mtime(self):
|
||||
""" Return the last modification time of the file. """
|
||||
|
||||
|
||||
class SvnWCCommandPath(PathBase):
|
||||
""" path implementation offering access/modification to svn working copies.
|
||||
It has methods similar to the functions in os.path and similar to the
|
||||
commands of the svn client.
|
||||
"""
|
||||
|
||||
def dump(self, obj):
|
||||
""" pickle object into path location"""
|
||||
|
||||
def svnurl(self):
|
||||
""" return current SvnPath for this WC-item. """
|
||||
|
||||
def switch(self, url):
|
||||
""" switch to given URL. """
|
||||
|
||||
def checkout(self, url=None, rev=None):
|
||||
""" checkout from url to local wcpath. """
|
||||
|
||||
def update(self, rev='HEAD', interactive=True):
|
||||
""" update working copy item to given revision. (None -> HEAD). """
|
||||
|
||||
def write(self, content, mode='w'):
|
||||
""" write content into local filesystem wc. """
|
||||
|
||||
def dirpath(self, *args):
|
||||
""" return the directory Path of the current Path. """
|
||||
|
||||
def ensure(self, *args, **kwargs):
|
||||
""" ensure that an args-joined path exists (by default as
|
||||
a file). if you specify a keyword argument 'directory=True'
|
||||
then the path is forced to be a directory path.
|
||||
"""
|
||||
|
||||
def mkdir(self, *args):
|
||||
""" create & return the directory joined with args. """
|
||||
|
||||
def add(self):
|
||||
""" add ourself to svn """
|
||||
|
||||
def remove(self, rec=1, force=1):
|
||||
""" remove a file or a directory tree. 'rec'ursive is
|
||||
ignored and considered always true (because of
|
||||
underlying svn semantics.
|
||||
"""
|
||||
|
||||
def copy(self, target):
|
||||
""" copy path to target."""
|
||||
|
||||
def rename(self, target):
|
||||
""" rename this path to target. """
|
||||
|
||||
def lock(self):
|
||||
""" set a lock (exclusive) on the resource """
|
||||
|
||||
def unlock(self):
|
||||
""" unset a previously set lock """
|
||||
|
||||
def cleanup(self):
|
||||
""" remove any locks from the resource """
|
||||
|
||||
def status(self, updates=0, rec=0, externals=0):
|
||||
""" return (collective) Status object for this file. """
|
||||
|
||||
def diff(self, rev=None):
|
||||
""" return a diff of the current path against revision rev (defaulting
|
||||
to the last one).
|
||||
"""
|
||||
|
||||
def blame(self):
|
||||
""" return a list of tuples of three elements:
|
||||
(revision, commiter, line)
|
||||
"""
|
||||
|
||||
def commit(self, msg='', rec=1):
|
||||
""" commit with support for non-recursive commits """
|
||||
|
||||
def propset(self, name, value, *args):
|
||||
""" set property name to value on this path. """
|
||||
|
||||
def propget(self, name):
|
||||
""" get property name on this path. """
|
||||
|
||||
def propdel(self, name):
|
||||
""" delete property name on this path. """
|
||||
|
||||
def proplist(self, rec=0):
|
||||
""" return a mapping of property names to property values.
|
||||
If rec is True, then return a dictionary mapping sub-paths to such mappings.
|
||||
"""
|
||||
|
||||
def revert(self, rec=0):
|
||||
""" revert the local changes of this path. if rec is True, do so
|
||||
recursively. """
|
||||
|
||||
def new(self, **kw):
|
||||
""" create a modified version of this path. A 'rev' argument
|
||||
indicates a new revision.
|
||||
the following keyword arguments modify various path parts:
|
||||
|
||||
http://host.com/repo/path/file.ext
|
||||
|-----------------------| dirname
|
||||
|------| basename
|
||||
|--| purebasename
|
||||
|--| ext
|
||||
"""
|
||||
|
||||
def join(self, *args, **kwargs):
|
||||
""" return a new Path (with the same revision) which is composed
|
||||
of the self Path followed by 'args' path components.
|
||||
"""
|
||||
|
||||
def info(self, usecache=1):
|
||||
""" return an Info structure with svn-provided information. """
|
||||
|
||||
def listdir(self, fil=None, sort=None):
|
||||
""" return a sequence of Paths.
|
||||
|
||||
listdir will return either a tuple or a list of paths
|
||||
depending on implementation choices.
|
||||
"""
|
||||
|
||||
def open(self, mode='r'):
|
||||
""" return an opened file with the given mode. """
|
||||
|
||||
def log(self, rev_start=None, rev_end=1, verbose=False):
|
||||
""" return a list of LogEntry instances for this path.
|
||||
rev_start is the starting revision (defaulting to the first one).
|
||||
rev_end is the last revision (defaulting to HEAD).
|
||||
if verbose is True, then the LogEntry instances also know which files changed.
|
||||
"""
|
||||
|
||||
|
||||
class SvnAuth(object):
|
||||
""" container for auth information for Subversion """
|
||||
|
||||
|
||||
svnwc = SvnWCCommandPath
|
||||
|
||||
|
||||
# py.path.svnurl
|
||||
|
||||
class SvnCommandPath(SvnPathBase):
|
||||
""" path implementation that offers access to (possibly remote) subversion
|
||||
repositories. """
|
||||
|
||||
|
||||
def open(self, mode='r'):
|
||||
""" return an opened file with the given mode. """
|
||||
|
||||
def dirpath(self, *args, **kwargs):
|
||||
""" return the directory path of the current path joined
|
||||
with any given path arguments.
|
||||
"""
|
||||
|
||||
# modifying methods (cache must be invalidated)
|
||||
def mkdir(self, *args, **kwargs):
|
||||
""" create & return the directory joined with args.
|
||||
pass a 'msg' keyword argument to set the commit message.
|
||||
"""
|
||||
|
||||
def copy(self, target, msg='copied by py lib invocation'):
|
||||
""" copy path to target with checkin message msg."""
|
||||
|
||||
def rename(self, target, msg="renamed by py lib invocation"):
|
||||
""" rename this path to target with checkin message msg. """
|
||||
|
||||
def remove(self, rec=1, msg='removed by py lib invocation'):
|
||||
""" remove a file or directory (or a directory tree if rec=1) with
|
||||
checkin message msg."""
|
||||
|
||||
def export(self, topath):
|
||||
""" export to a local path
|
||||
|
||||
topath should not exist prior to calling this, returns a
|
||||
py.path.local instance
|
||||
"""
|
||||
|
||||
def ensure(self, *args, **kwargs):
|
||||
""" ensure that an args-joined path exists (by default as
|
||||
a file). If you specify a keyword argument 'dir=True'
|
||||
then the path is forced to be a directory path.
|
||||
"""
|
||||
|
||||
# end of modifying methods
|
||||
|
||||
def info(self):
|
||||
""" return an Info structure with svn-provided information. """
|
||||
|
||||
def listdir(self, fil=None, sort=None):
|
||||
""" list directory contents, possibly filter by the given fil func
|
||||
and possibly sorted.
|
||||
"""
|
||||
|
||||
def log(self, rev_start=None, rev_end=1, verbose=False):
|
||||
""" return a list of LogEntry instances for this path.
|
||||
rev_start is the starting revision (defaulting to the first one).
|
||||
rev_end is the last revision (defaulting to HEAD).
|
||||
if verbose is True, then the LogEntry instances also know which files changed.
|
||||
"""
|
||||
|
||||
svnurl = SvnCommandPath
|
||||
@@ -1,348 +0,0 @@
|
||||
"""Skeleton for 'pytest'.
|
||||
|
||||
Project: pytest 3.0.0 <http://doc.pytest.org>
|
||||
Skeleton by: Bruno Oliveira <nicoddemus@gmail.com>
|
||||
|
||||
Exposing everything that can be extracted from `pytest_namespace` hook
|
||||
in standard pytest modules, using original docstrings.
|
||||
"""
|
||||
|
||||
|
||||
def freeze_includes():
|
||||
"""
|
||||
Returns a list of module names used by py.test that should be
|
||||
included by cx_freeze.
|
||||
"""
|
||||
|
||||
|
||||
# _pytest.main
|
||||
class collect:
|
||||
|
||||
class Item:
|
||||
""" a basic test invocation item. Note that for a single function
|
||||
there might be multiple test invocation items.
|
||||
"""
|
||||
|
||||
class Collector:
|
||||
""" Collector instances create children through collect()
|
||||
and thus iteratively build a tree.
|
||||
"""
|
||||
|
||||
class File:
|
||||
""" base class for collecting tests from a file. """
|
||||
|
||||
class Session:
|
||||
"""
|
||||
"""
|
||||
|
||||
# _pytest.python
|
||||
class Module:
|
||||
""" Collector for test classes and functions. """
|
||||
|
||||
class Class:
|
||||
""" Collector for test methods. """
|
||||
|
||||
class Instance:
|
||||
"""
|
||||
"""
|
||||
|
||||
class Function:
|
||||
""" a Function Item is responsible for setting up and executing a
|
||||
Python test function.
|
||||
"""
|
||||
|
||||
class Generator:
|
||||
"""
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def _fillfuncargs(function):
|
||||
""" fill missing funcargs for a test function. """
|
||||
|
||||
|
||||
|
||||
|
||||
# _pytest.pdb
|
||||
def set_trace():
|
||||
""" invoke PDB set_trace debugging, dropping any IO capturing. """
|
||||
|
||||
# _pytest.mark
|
||||
class mark:
|
||||
|
||||
def __getattr__(self, item):
|
||||
"""
|
||||
This class may have any attribute, so this method should exist
|
||||
"""
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def skipif(condition, reason=None):
|
||||
"""skip the given test function if eval(condition) results in a True
|
||||
value.
|
||||
|
||||
Optionally specify a reason for better reporting.
|
||||
|
||||
Evaluation happens within the module global context.
|
||||
Example: ``skipif('sys.platform == "win32"')`` skips the test if
|
||||
we are on the win32 platform.
|
||||
|
||||
see http://doc.pytest.org/en/latest/skipping.html
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def skip(reason=None):
|
||||
"""skip the given test function, optionally specify a reason for better reporting.
|
||||
|
||||
see http://doc.pytest.org/en/latest/skipping.html
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def xfail(condition=None, reason=None, raises=None, run=True, strict=False):
|
||||
"""mark the the test function as an expected failure if eval(condition)
|
||||
has a True value.
|
||||
|
||||
Optionally specify a reason for better reporting and run=False if
|
||||
you don't even want to execute the test function.
|
||||
|
||||
See http://doc.pytest.org/en/latest/skipping.html
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def parametrize(argnames, argvalues, indirect=False, ids=None, scope=None):
|
||||
""" Add new invocations to the underlying test function using the list
|
||||
of argvalues for the given argnames. Parametrization is performed
|
||||
during the collection phase. If you need to setup expensive resources
|
||||
see about setting indirect to do it rather at test setup time.
|
||||
|
||||
:arg argnames: a comma-separated string denoting one or more argument
|
||||
names, or a list/tuple of argument strings.
|
||||
|
||||
:arg argvalues: The list of argvalues determines how often a
|
||||
test is invoked with different argument values. If only one
|
||||
argname was specified argvalues is a list of values. If N
|
||||
argnames were specified, argvalues must be a list of N-tuples,
|
||||
where each tuple-element specifies a value for its respective
|
||||
argname.
|
||||
|
||||
:arg indirect: The list of argnames or boolean. A list of arguments'
|
||||
names (subset of argnames). If True the list contains all names from
|
||||
the argnames. Each argvalue corresponding to an argname in this list will
|
||||
be passed as request.param to its respective argname fixture
|
||||
function so that it can perform more expensive setups during the
|
||||
setup phase of a test rather than at collection time.
|
||||
|
||||
:arg ids: list of string ids, or a callable.
|
||||
If strings, each is corresponding to the argvalues so that they are
|
||||
part of the test id. If None is given as id of specific test, the
|
||||
automatically generated id for that argument will be used.
|
||||
If callable, it should take one argument (a single argvalue) and return
|
||||
a string or return None. If None, the automatically generated id for that
|
||||
argument will be used.
|
||||
If no ids are provided they will be generated automatically from
|
||||
the argvalues.
|
||||
|
||||
:arg scope: if specified it denotes the scope of the parameters.
|
||||
The scope is used for grouping tests by parameter instances.
|
||||
It will also override any fixture-function defined scope, allowing
|
||||
to set a dynamic scope using test context or configuration.
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def usefixtures(*fixturenames):
|
||||
"""mark tests as needing all of the specified fixtures.
|
||||
|
||||
see http://doc.pytest.org/en/latest/fixture.html#usefixtures
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def tryfirst(f):
|
||||
"""mark a hook implementation function such that the plugin machinery
|
||||
will try to call it first/as early as possible.
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def trylast(f):
|
||||
"""mark a hook implementation function such that the plugin machinery
|
||||
will try to call it last/as late as possible.
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def hookwrapper(f):
|
||||
"""A hook wrapper is a generator function which yields exactly once.
|
||||
When pytest invokes hooks it first executes hook wrappers and passes
|
||||
the same arguments as to the regular hooks.
|
||||
"""
|
||||
|
||||
|
||||
# _pytest.python
|
||||
def raises(ExpectedException, *args, **kwargs):
|
||||
""" assert that a code block/function call raises @ExpectedException and
|
||||
raise a failure exception otherwise.
|
||||
|
||||
:type ExpectedException: T
|
||||
|
||||
This helper produces a ``py.code.ExceptionInfo()`` object.
|
||||
|
||||
If using Python 2.5 or above, you may use this function as a
|
||||
context manager::
|
||||
|
||||
>>> with raises(ZeroDivisionError):
|
||||
... 1/0
|
||||
|
||||
Or you can specify a callable by passing a to-be-called lambda::
|
||||
|
||||
>>> raises(ZeroDivisionError, lambda: 1/0)
|
||||
<ExceptionInfo ...>
|
||||
|
||||
or you can specify an arbitrary callable with arguments::
|
||||
|
||||
>>> def f(x): return 1/x
|
||||
...
|
||||
>>> raises(ZeroDivisionError, f, 0)
|
||||
<ExceptionInfo ...>
|
||||
>>> raises(ZeroDivisionError, f, x=0)
|
||||
<ExceptionInfo ...>
|
||||
|
||||
A third possibility is to use a string to be executed::
|
||||
|
||||
>>> raises(ZeroDivisionError, "f(0)")
|
||||
<ExceptionInfo ...>
|
||||
|
||||
Performance note:
|
||||
-----------------
|
||||
|
||||
Similar to caught exception objects in Python, explicitly clearing
|
||||
local references to returned ``py.code.ExceptionInfo`` objects can
|
||||
help the Python interpreter speed up its garbage collection.
|
||||
|
||||
Clearing those references breaks a reference cycle
|
||||
(``ExceptionInfo`` --> caught exception --> frame stack raising
|
||||
the exception --> current frame stack --> local variables -->
|
||||
``ExceptionInfo``) which makes Python keep all objects referenced
|
||||
from that cycle (including all local variables in the current
|
||||
frame) alive until the next cyclic garbage collection run. See the
|
||||
official Python ``try`` statement documentation for more detailed
|
||||
information.
|
||||
|
||||
"""
|
||||
|
||||
|
||||
def fixture(scope="function", params=None, autouse=False, ids=None, name=None):
|
||||
""" (return a) decorator to mark a fixture factory function.
|
||||
|
||||
This decorator can be used (with or or without parameters) to define
|
||||
a fixture function. The name of the fixture function can later be
|
||||
referenced to cause its invocation ahead of running tests: test
|
||||
modules or classes can use the pytest.mark.usefixtures(fixturename)
|
||||
marker. Test functions can directly use fixture names as input
|
||||
arguments in which case the fixture instance returned from the fixture
|
||||
function will be injected.
|
||||
|
||||
:arg scope: the scope for which this fixture is shared, one of
|
||||
"function" (default), "class", "module", "session" or "invocation".
|
||||
|
||||
:arg params: an optional list of parameters which will cause multiple
|
||||
invocations of the fixture function and all of the tests
|
||||
using it.
|
||||
|
||||
:arg autouse: if True, the fixture func is activated for all tests that
|
||||
can see it. If False (the default) then an explicit
|
||||
reference is needed to activate the fixture.
|
||||
|
||||
:arg ids: list of string ids each corresponding to the params
|
||||
so that they are part of the test id. If no ids are provided
|
||||
they will be generated automatically from the params.
|
||||
|
||||
:arg name: the name of the fixture. This defaults to the name of the
|
||||
decorated function. If a fixture is used in the same module in
|
||||
which it is defined, the function name of the fixture will be
|
||||
shadowed by the function arg that requests the fixture; one way
|
||||
to resolve this is to name the decorated function
|
||||
``fixture_<fixturename>`` and then use
|
||||
``@pytest.fixture(name='<fixturename>')``.
|
||||
"""
|
||||
|
||||
|
||||
def yield_fixture(scope="function", params=None, autouse=False, ids=None, name=None):
|
||||
""" (return a) decorator to mark a yield-fixture factory function.
|
||||
|
||||
.. deprecated:: 3.0
|
||||
Use :py:func:`pytest.fixture` directly instead.
|
||||
"""
|
||||
import warnings
|
||||
warnings.warn(DeprecationWarning('Use @pytest.fixture directly instead.'))
|
||||
|
||||
|
||||
# _pytest.recwarn
|
||||
def deprecated_call(func, *args, **kwargs):
|
||||
""" assert that calling ``func(*args, **kwargs)``
|
||||
triggers a DeprecationWarning.
|
||||
"""
|
||||
|
||||
|
||||
# _pytest.runner
|
||||
def exit(msg):
|
||||
""" exit testing process as if KeyboardInterrupt was triggered. """
|
||||
|
||||
exit.Exception = Exception
|
||||
|
||||
|
||||
def skip(msg=""):
|
||||
""" skip an executing test with the given message. Note: it's usually
|
||||
better to use the pytest.mark.skipif marker to declare a test to be
|
||||
skipped under certain conditions like mismatching platforms or
|
||||
dependencies. See the pytest_skipping plugin for details.
|
||||
"""
|
||||
skip.Exception = Exception
|
||||
|
||||
|
||||
def fail(msg="", pytrace=True):
|
||||
""" explicitely fail an currently-executing test with the given Message.
|
||||
|
||||
:arg pytrace: if false the msg represents the full failure information
|
||||
and no python traceback will be reported.
|
||||
"""
|
||||
fail.Exception = Exception
|
||||
|
||||
|
||||
def importorskip(modname, minversion=None):
|
||||
""" return imported module if it has at least "minversion" as its
|
||||
__version__ attribute. If no minversion is specified the a skip
|
||||
is only triggered if the module can not be imported.
|
||||
Note that version comparison only works with simple version strings
|
||||
like "1.2.3" but not "1.2.3.dev1" or others.
|
||||
"""
|
||||
|
||||
# _pytest.skipping
|
||||
def xfail(reason=""):
|
||||
""" xfail an executing test or setup functions with the given reason.
|
||||
"""
|
||||
|
||||
|
||||
def approx(expected, rel=None, abs=None):
|
||||
"""
|
||||
Assert that two numbers (or two sets of numbers) are equal to each other
|
||||
within some tolerance.
|
||||
|
||||
The ``approx`` class performs floating-point comparisons using a syntax
|
||||
that's as intuitive as possible::
|
||||
|
||||
>>> from pytest import approx
|
||||
>>> 0.1 + 0.2 == approx(0.3)
|
||||
True
|
||||
|
||||
http://doc.pytest.org/en/latest/builtin.html#comparing-floating-point-numbers
|
||||
"""
|
||||
|
||||
|
||||
def register_assert_rewrite(*names):
|
||||
"""Register a module name to be rewritten on import.
|
||||
|
||||
This function will make sure that this module or all modules inside
|
||||
the package will get their assert statements rewritten.
|
||||
Thus you should make sure to call this before the module is
|
||||
actually imported, usually in your __init__.py if you are a plugin
|
||||
using a package.
|
||||
|
||||
:raise TypeError: if the given module names are not strings.
|
||||
"""
|
||||
@@ -1,106 +0,0 @@
|
||||
"""Skeleton for 'struct' stdlib module."""
|
||||
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import sys
|
||||
|
||||
|
||||
def pack(fmt, *values):
|
||||
"""Return a string containing the values packed according to the given
|
||||
format.
|
||||
|
||||
:type fmt: bytes | unicode
|
||||
:rtype: bytes
|
||||
"""
|
||||
return b''
|
||||
|
||||
|
||||
def unpack(fmt, string):
|
||||
"""Unpack the string according to the given format.
|
||||
|
||||
:type fmt: bytes | unicode
|
||||
:type string: bytestring
|
||||
:rtype: tuple
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def pack_into(fmt, buffer, offset, *values):
|
||||
""""Pack the values according to the given format, write the packed
|
||||
bytes into the writable buffer starting at offset.
|
||||
|
||||
:type fmt: bytes | unicode
|
||||
:type offset: int | long
|
||||
:rtype: bytes
|
||||
"""
|
||||
return b''
|
||||
|
||||
def unpack_from(fmt, buffer, offset=0):
|
||||
"""Unpack the buffer according to the given format.
|
||||
|
||||
:type fmt: bytes | unicode
|
||||
:type offset: int | long
|
||||
:rtype: tuple
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def calcsize(fmt):
|
||||
"""Return the size of the struct (and hence of the string) corresponding to
|
||||
the given format.
|
||||
|
||||
:type fmt: bytes | unicode
|
||||
:rtype: int
|
||||
"""
|
||||
return 0
|
||||
|
||||
|
||||
class Struct(object):
|
||||
"""Struct object which writes and reads binary data according to the format
|
||||
string.
|
||||
|
||||
:param format: The format string used to construct this Struct object.
|
||||
:type format: bytes | unicode
|
||||
|
||||
:param size: The calculated size of the struct corresponding to format.
|
||||
:type size: int
|
||||
"""
|
||||
|
||||
def __init__(self, format):
|
||||
"""Create a new Struct object.
|
||||
|
||||
:type format: bytes | unicode
|
||||
"""
|
||||
self.format = format
|
||||
self.size = 0
|
||||
|
||||
def pack(self, *values):
|
||||
"""Identical to the pack() function, using the compiled format.
|
||||
|
||||
:rtype: bytes
|
||||
"""
|
||||
return b''
|
||||
|
||||
def pack_into(self, buffer, offset, *values):
|
||||
"""Identical to the pack_into() function, using the compiled format.
|
||||
|
||||
:type offset: int | long
|
||||
:rtype: bytes
|
||||
"""
|
||||
return b''
|
||||
|
||||
def unpack(self, string):
|
||||
"""Identical to the unpack() function, using the compiled format.
|
||||
|
||||
:type string: bytestring
|
||||
:rtype: tuple
|
||||
"""
|
||||
pass
|
||||
|
||||
def unpack_from(self, buffer, offset=0):
|
||||
"""Identical to the unpack_from() function, using the compiled format.
|
||||
|
||||
:type offset: int | long
|
||||
:rtype: tuple
|
||||
"""
|
||||
pass
|
||||
@@ -417,10 +417,6 @@
|
||||
|
||||
<macro implementation="com.jetbrains.python.sdk.InterpreterDirectoryMacro"/>
|
||||
|
||||
<!-- User skeletons -->
|
||||
<codeInsight.lineMarkerProvider language="Python"
|
||||
implementationClass="com.jetbrains.python.codeInsight.userSkeletons.PyUserSkeletonsLineMarkerProvider"/>
|
||||
|
||||
<!-- TestRunnerService -->
|
||||
<moduleService serviceImplementation="com.jetbrains.python.testing.TestRunnerService$ModuleService"/>
|
||||
<applicationService serviceImplementation="com.jetbrains.python.testing.TestRunnerService$AppService"/>
|
||||
|
||||
@@ -968,8 +968,6 @@ python.project.view.remote.libraries=Remote Libraries
|
||||
python.project.view.py.skeletons=Binary Skeletons
|
||||
python.project.view.typeshed.stubs=Typeshed Stubs
|
||||
python.project.view.bundled.stubs=Bundled Stubs
|
||||
python.project.view.user.skeletons.node=Extended Definitions
|
||||
|
||||
|
||||
python.packaging.installing.error.failed.to.find.specification=Failed to find specification for {0}
|
||||
python.packaging.installing.packaging.tools=Installing packaging tools\u2026
|
||||
|
||||
@@ -571,11 +571,6 @@
|
||||
<!-- IPython -->
|
||||
<pyReferenceResolveProvider implementation="com.jetbrains.python.psi.resolve.PyIPythonBuiltinReferenceResolveProvider"/>
|
||||
|
||||
<!-- User skeletons -->
|
||||
<pyModuleMembersProvider implementation="com.jetbrains.python.codeInsight.userSkeletons.PyUserSkeletonsModuleMembersProvider"/>
|
||||
<pyClassMembersProvider implementation="com.jetbrains.python.codeInsight.userSkeletons.PyUserSkeletonsClassMembersProvider"/>
|
||||
<typeProvider implementation="com.jetbrains.python.codeInsight.userSkeletons.PyUserSkeletonsTypeProvider"/>
|
||||
|
||||
<pyReferenceResolveProvider implementation="com.jetbrains.python.psi.resolve.PythonBuiltinReferenceResolveProvider"/>
|
||||
<pyReferenceResolveProvider implementation="com.jetbrains.python.psi.resolve.PythonOverridingBuiltinReferenceResolveProvider"/>
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ import com.intellij.util.ProcessingContext;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.jetbrains.python.PyNames;
|
||||
import com.jetbrains.python.PyTokenTypes;
|
||||
import com.jetbrains.python.codeInsight.userSkeletons.PyUserSkeletonsUtil;
|
||||
import com.jetbrains.python.psi.PyClass;
|
||||
import com.jetbrains.python.psi.PyReferenceExpression;
|
||||
import com.jetbrains.python.psi.impl.PyBuiltinCache;
|
||||
@@ -120,9 +119,6 @@ public final class PyStructuralTypeAttributesCompletionContributor extends Compl
|
||||
|
||||
final Set<PyClass> suitableClasses = new HashSet<>();
|
||||
for (PyClass candidate : candidates) {
|
||||
if (PyUserSkeletonsUtil.isUnderUserSkeletonsDirectory(candidate.getContainingFile())) {
|
||||
continue;
|
||||
}
|
||||
final Set<String> inherited = getAllInheritedAttributeNames(candidate, context, ancestorsCache);
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("All attributes of " + debugClassCoordinates(candidate) + ": " + inherited);
|
||||
|
||||
@@ -1,95 +0,0 @@
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.jetbrains.python.codeInsight.userSkeletons;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.jetbrains.python.codeInsight.PyCustomMember;
|
||||
import com.jetbrains.python.psi.PyClass;
|
||||
import com.jetbrains.python.psi.PyFunction;
|
||||
import com.jetbrains.python.psi.PyTargetExpression;
|
||||
import com.jetbrains.python.psi.PyUtil;
|
||||
import com.jetbrains.python.psi.resolve.PyResolveContext;
|
||||
import com.jetbrains.python.psi.types.PyClassMembersProviderBase;
|
||||
import com.jetbrains.python.psi.types.PyClassType;
|
||||
import com.jetbrains.python.psi.types.PyOverridingAncestorsClassMembersProvider;
|
||||
import com.jetbrains.python.psi.types.TypeEvalContext;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public final class PyUserSkeletonsClassMembersProvider extends PyClassMembersProviderBase implements PyOverridingAncestorsClassMembersProvider {
|
||||
@Override
|
||||
public @NotNull Collection<PyCustomMember> getMembers(@NotNull PyClassType classType, PsiElement location, @NotNull TypeEvalContext context) {
|
||||
final PyClass cls = classType.getPyClass();
|
||||
final PyClass skeleton = PyUserSkeletonsUtil.getUserSkeletonWithContext(cls, context);
|
||||
if (skeleton != null) {
|
||||
return getClassMembers(skeleton, classType.isDefinition());
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable PsiElement resolveMember(@NotNull PyClassType type,
|
||||
@NotNull String name,
|
||||
@Nullable PsiElement location,
|
||||
@NotNull PyResolveContext resolveContext) {
|
||||
final PyClass cls = type.getPyClass();
|
||||
final PyClass skeleton = PyUserSkeletonsUtil.getUserSkeletonWithContext(cls, resolveContext.getTypeEvalContext());
|
||||
if (skeleton != null) {
|
||||
return findClassMember(skeleton, name, type.isDefinition());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static PsiElement findClassMember(@NotNull PyClass cls, @NotNull String name, boolean isDefinition) {
|
||||
final PyFunction function = cls.findMethodByName(name, false, null);
|
||||
if (function != null) {
|
||||
final PyUtil.MethodFlags methodFlags = PyUtil.MethodFlags.of(function);
|
||||
final boolean instanceMethod = methodFlags == null || methodFlags.isInstanceMethod();
|
||||
if (isDefinition ^ instanceMethod) {
|
||||
return function;
|
||||
}
|
||||
}
|
||||
if (!isDefinition) {
|
||||
final PyTargetExpression instanceAttribute = cls.findInstanceAttribute(name, false);
|
||||
if (instanceAttribute != null) {
|
||||
return instanceAttribute;
|
||||
}
|
||||
}
|
||||
final PyTargetExpression classAttribute = cls.findClassAttribute(name, false, null);
|
||||
if (classAttribute != null) {
|
||||
return classAttribute;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Collection<PyCustomMember> getClassMembers(@NotNull PyClass cls, boolean isDefinition) {
|
||||
final List<PyCustomMember> result = new ArrayList<>();
|
||||
for (PyFunction function : cls.getMethods()) {
|
||||
final String name = function.getName();
|
||||
final PyUtil.MethodFlags methodFlags = PyUtil.MethodFlags.of(function);
|
||||
final boolean instanceMethod = methodFlags == null || methodFlags.isInstanceMethod();
|
||||
if (name != null && (isDefinition ^ instanceMethod)) {
|
||||
result.add(new PyCustomMember(name, function));
|
||||
}
|
||||
}
|
||||
if (!isDefinition) {
|
||||
for (PyTargetExpression attribute : cls.getInstanceAttributes()) {
|
||||
final String name = attribute.getName();
|
||||
if (name != null) {
|
||||
result.add(new PyCustomMember(name, attribute));
|
||||
}
|
||||
}
|
||||
}
|
||||
for (PyTargetExpression attribute : cls.getClassAttributes()) {
|
||||
final String name = attribute.getName();
|
||||
if (name != null) {
|
||||
result.add(new PyCustomMember(name, attribute));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.jetbrains.python.codeInsight.userSkeletons;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFileSystemItem;
|
||||
import com.jetbrains.python.codeInsight.PyCustomMember;
|
||||
import com.jetbrains.python.psi.PyElement;
|
||||
import com.jetbrains.python.psi.PyFile;
|
||||
import com.jetbrains.python.psi.resolve.PyResolveContext;
|
||||
import com.jetbrains.python.psi.types.PyModuleMembersProvider;
|
||||
import com.jetbrains.python.psi.types.TypeEvalContext;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public final class PyUserSkeletonsModuleMembersProvider extends PyModuleMembersProvider {
|
||||
@Override
|
||||
public @Nullable PsiElement resolveMember(@NotNull PyFile module, @NotNull String name, @NotNull PyResolveContext resolveContext) {
|
||||
final PyFile moduleSkeleton = PyUserSkeletonsUtil.getUserSkeleton(module);
|
||||
if (moduleSkeleton != null) {
|
||||
return moduleSkeleton.getElementNamed(name);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @NotNull Collection<PyCustomMember> getMembersByQName(@NotNull PyFile module, @NotNull String qName, @NotNull TypeEvalContext context) {
|
||||
final PyFile moduleSkeleton = PyUserSkeletonsUtil.getUserSkeletonForModuleQName(qName, module);
|
||||
if (moduleSkeleton != null) {
|
||||
final List<PyCustomMember> results = new ArrayList<>();
|
||||
for (PyElement element : moduleSkeleton.iterateNames()) {
|
||||
if (element instanceof PsiFileSystemItem) {
|
||||
continue;
|
||||
}
|
||||
final String name = element.getName();
|
||||
if (name != null) {
|
||||
results.add(new PyCustomMember(name, element));
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.jetbrains.python.codeInsight.userSkeletons;
|
||||
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.jetbrains.python.psi.PyCallable;
|
||||
import com.jetbrains.python.psi.PyFunction;
|
||||
import com.jetbrains.python.psi.PyNamedParameter;
|
||||
import com.jetbrains.python.psi.PyTargetExpression;
|
||||
import com.jetbrains.python.psi.types.PyType;
|
||||
import com.jetbrains.python.psi.types.PyTypeProviderBase;
|
||||
import com.jetbrains.python.psi.types.PyTypeUtil;
|
||||
import com.jetbrains.python.psi.types.TypeEvalContext;
|
||||
import com.jetbrains.python.pyi.PyiUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public final class PyUserSkeletonsTypeProvider extends PyTypeProviderBase {
|
||||
@Override
|
||||
public Ref<PyType> getParameterType(@NotNull PyNamedParameter param, @NotNull PyFunction func, @NotNull TypeEvalContext context) {
|
||||
if (PyiUtil.isInsideStub(param)) {
|
||||
return null;
|
||||
}
|
||||
final String name = param.getName();
|
||||
if (name != null) {
|
||||
final PyFunction functionSkeleton = PyUserSkeletonsUtil.getUserSkeletonWithContext(func, context);
|
||||
if (functionSkeleton != null) {
|
||||
final PyNamedParameter paramSkeleton = functionSkeleton.getParameterList().findParameterByName(name);
|
||||
if (paramSkeleton != null) {
|
||||
final PyType type = context.getType(paramSkeleton);
|
||||
if (type != null) {
|
||||
return Ref.create(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Ref<PyType> getReturnType(@NotNull PyCallable callable, @NotNull TypeEvalContext context) {
|
||||
if (PyiUtil.isInsideStub(callable)) {
|
||||
return null;
|
||||
}
|
||||
final PyCallable callableSkeleton = PyUserSkeletonsUtil.getUserSkeletonWithContext(callable, context);
|
||||
if (callableSkeleton != null) {
|
||||
return Ref.create(context.getReturnType(callableSkeleton));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Ref<PyType> getReferenceType(@NotNull PsiElement target, @NotNull TypeEvalContext context, @Nullable PsiElement anchor) {
|
||||
if (PyiUtil.isInsideStub(target)) {
|
||||
return null;
|
||||
}
|
||||
if (target instanceof PyTargetExpression) {
|
||||
final PyTargetExpression targetSkeleton = PyUserSkeletonsUtil.getUserSkeletonWithContext((PyTargetExpression)target, context);
|
||||
if (targetSkeleton != null) {
|
||||
return PyTypeUtil.notNullToRef(context.getType(targetSkeleton));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable PyType getCallableType(@NotNull PyCallable callable, @NotNull TypeEvalContext context) {
|
||||
if (PyiUtil.isInsideStub(callable)) {
|
||||
return null;
|
||||
}
|
||||
final PyCallable callableSkeleton = PyUserSkeletonsUtil.getUserSkeletonWithContext(callable, context);
|
||||
if (callableSkeleton != null) {
|
||||
return context.getType(callableSkeleton);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,240 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.jetbrains.python.codeInsight.userSkeletons;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.StandardFileSystems;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiDirectory;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.GlobalSearchScopesCore;
|
||||
import com.intellij.psi.util.QualifiedName;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.jetbrains.python.PythonHelpersLocator;
|
||||
import com.jetbrains.python.codeInsight.controlflow.ScopeOwner;
|
||||
import com.jetbrains.python.codeInsight.dataflow.scope.ScopeUtil;
|
||||
import com.jetbrains.python.psi.*;
|
||||
import com.jetbrains.python.psi.resolve.*;
|
||||
import com.jetbrains.python.psi.types.PyClassLikeType;
|
||||
import com.jetbrains.python.psi.types.PyType;
|
||||
import com.jetbrains.python.psi.types.TypeEvalContext;
|
||||
import com.jetbrains.python.sdk.PythonSdkUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public final class PyUserSkeletonsUtil {
|
||||
public static final String USER_SKELETONS_DIR = "python-skeletons";
|
||||
private static final Logger LOG = Logger.getInstance(PyUserSkeletonsUtil.class);
|
||||
public static final Key<Boolean> HAS_SKELETON = Key.create("PyUserSkeleton.hasSkeleton");
|
||||
|
||||
private static final ImmutableSet<String> STDLIB_SKELETONS = ImmutableSet.of(
|
||||
"asyncio",
|
||||
"multiprocessing",
|
||||
"os",
|
||||
"_csv.py",
|
||||
"copy.py",
|
||||
"cStringIO.py",
|
||||
"decimal.py",
|
||||
"io.py",
|
||||
"itertools.py",
|
||||
"logging.py",
|
||||
"pathlib.py",
|
||||
"pickle.py",
|
||||
"StringIO.py",
|
||||
"struct.py",
|
||||
"sys.py"
|
||||
);
|
||||
|
||||
private static @Nullable VirtualFile ourUserSkeletonsDirectory;
|
||||
private static boolean ourNoSkeletonsErrorReported = false;
|
||||
|
||||
private static @NotNull List<String> getPossibleUserSkeletonsPaths() {
|
||||
final List<String> result = new ArrayList<>();
|
||||
result.add(PathManager.getConfigPath() + File.separator + USER_SKELETONS_DIR);
|
||||
result.add(PythonHelpersLocator.findPathStringInHelpers(USER_SKELETONS_DIR));
|
||||
return result;
|
||||
}
|
||||
|
||||
public static @Nullable VirtualFile getUserSkeletonsDirectory() {
|
||||
if (ourUserSkeletonsDirectory == null) {
|
||||
for (String path : getPossibleUserSkeletonsPaths()) {
|
||||
ourUserSkeletonsDirectory = StandardFileSystems.local().findFileByPath(path);
|
||||
if (ourUserSkeletonsDirectory != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!ourNoSkeletonsErrorReported && ourUserSkeletonsDirectory == null) {
|
||||
ourNoSkeletonsErrorReported = true;
|
||||
LOG.warn("python-skeletons directory not found in paths: " + getPossibleUserSkeletonsPaths());
|
||||
}
|
||||
return ourUserSkeletonsDirectory;
|
||||
}
|
||||
|
||||
public static boolean isUnderUserSkeletonsDirectory(@NotNull PsiFile file) {
|
||||
final VirtualFile virtualFile = file.getVirtualFile();
|
||||
if (virtualFile == null) {
|
||||
return false;
|
||||
}
|
||||
return isUnderUserSkeletonsDirectory(virtualFile);
|
||||
}
|
||||
|
||||
public static boolean isUnderUserSkeletonsDirectory(final @NotNull VirtualFile virtualFile) {
|
||||
final VirtualFile skeletonsDir = getUserSkeletonsDirectory();
|
||||
return skeletonsDir != null && VfsUtilCore.isAncestor(skeletonsDir, virtualFile, false);
|
||||
}
|
||||
|
||||
public static @NotNull GlobalSearchScope getUserSkeletonsDirectoryScope(@NotNull Project project) {
|
||||
VirtualFile userSkeletonsDirectory = getUserSkeletonsDirectory();
|
||||
if (userSkeletonsDirectory != null) {
|
||||
return new GlobalSearchScopesCore.DirectoryScope(project, userSkeletonsDirectory, true);
|
||||
}
|
||||
else {
|
||||
return GlobalSearchScope.EMPTY_SCOPE;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isStandardLibrarySkeleton(@NotNull VirtualFile virtualFile) {
|
||||
final VirtualFile skeletonsDir = getUserSkeletonsDirectory();
|
||||
if (skeletonsDir == null) {
|
||||
return false;
|
||||
}
|
||||
final String relativePath = VfsUtilCore.getRelativePath(virtualFile, skeletonsDir, '/');
|
||||
// not under skeletons directory
|
||||
if (relativePath == null) {
|
||||
return false;
|
||||
}
|
||||
final String firstComponent = ContainerUtil.getFirstItem(StringUtil.split(relativePath, "/"));
|
||||
return STDLIB_SKELETONS.contains(firstComponent);
|
||||
}
|
||||
|
||||
public static @Nullable <T extends PyElement> T getUserSkeleton(@NotNull T element) {
|
||||
return getUserSkeletonWithContext(element, null);
|
||||
}
|
||||
public static @Nullable <T extends PyElement> T getUserSkeletonWithContext(@NotNull T element, final @Nullable TypeEvalContext context) {
|
||||
final PsiFile file = element.getContainingFile();
|
||||
if (file instanceof PyFile) {
|
||||
final PyFile skeletonFile = getUserSkeletonForFile((PyFile)file);
|
||||
if (skeletonFile != null && skeletonFile != file) {
|
||||
final PsiElement skeletonElement = getUserSkeleton(element, skeletonFile, context);
|
||||
if (element.getClass().isInstance(skeletonElement) && skeletonElement != element) {
|
||||
//noinspection unchecked
|
||||
return (T)skeletonElement;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static @Nullable PyFile getUserSkeletonForModuleQName(@NotNull String qName, @NotNull PsiElement foothold) {
|
||||
final Sdk sdk = PythonSdkUtil.findPythonSdk(foothold);
|
||||
if (sdk != null) {
|
||||
final Project project = foothold.getProject();
|
||||
final PythonSdkPathCache cache = PythonSdkPathCache.getInstance(project, sdk);
|
||||
final QualifiedName cacheQName = QualifiedName.fromDottedString(USER_SKELETONS_DIR + "." + qName);
|
||||
final List<PsiElement> results = cache.get(cacheQName);
|
||||
if (results != null) {
|
||||
final PsiElement element = results.isEmpty() ? null : results.get(0);
|
||||
if (element instanceof PyFile) {
|
||||
return (PyFile)element;
|
||||
}
|
||||
}
|
||||
final VirtualFile directory = getUserSkeletonsDirectory();
|
||||
if (directory != null) {
|
||||
final PsiDirectory psiDirectory = PsiManager.getInstance(project).findDirectory(directory);
|
||||
PsiElement fileSkeleton = PyResolveImportUtil.resolveModuleAt(QualifiedName.fromDottedString(qName), psiDirectory,
|
||||
PyResolveImportUtil.fromFoothold(foothold))
|
||||
.stream().findFirst().orElse(null);
|
||||
if (fileSkeleton instanceof PsiDirectory) {
|
||||
fileSkeleton = PyUtil.getPackageElement((PsiDirectory)fileSkeleton, foothold);
|
||||
}
|
||||
if (fileSkeleton instanceof PyFile) {
|
||||
cache.put(cacheQName, Collections.singletonList(fileSkeleton));
|
||||
return (PyFile)fileSkeleton;
|
||||
}
|
||||
}
|
||||
cache.put(cacheQName, Collections.emptyList());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static @Nullable PsiElement getUserSkeleton(@NotNull PyElement element, @NotNull PyFile skeletonFile, @Nullable TypeEvalContext context) {
|
||||
if (element instanceof PyFile) {
|
||||
return skeletonFile;
|
||||
}
|
||||
final ScopeOwner owner = ScopeUtil.getScopeOwner(element);
|
||||
final String name = element.getName();
|
||||
if (owner != null && name != null) {
|
||||
assert owner != element;
|
||||
final PsiElement originalOwner = getUserSkeleton(owner, skeletonFile, context);
|
||||
if (originalOwner instanceof PyClass classOwner) {
|
||||
final var fallbackContext = TypeEvalContext.codeInsightFallback(classOwner.getProject());
|
||||
final PyType type = fallbackContext.getType(classOwner);
|
||||
if (type instanceof PyClassLikeType classType) {
|
||||
final PyClassLikeType instanceType = classType.toInstance();
|
||||
final PyResolveContext resolveContext = PyResolveContext.defaultContext(ObjectUtils.notNull(context, fallbackContext));
|
||||
final List<? extends RatedResolveResult> resolveResults = instanceType.resolveMember(name, null, AccessDirection.READ,
|
||||
resolveContext, false);
|
||||
if (resolveResults != null && !resolveResults.isEmpty()) {
|
||||
return resolveResults.get(0).getElement();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (originalOwner instanceof PyFile) {
|
||||
return ((PyFile)originalOwner).getElementNamed(name);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static @Nullable PyFile getUserSkeletonForFile(@NotNull PyFile file) {
|
||||
final Boolean hasSkeleton = file.getUserData(HAS_SKELETON);
|
||||
if (hasSkeleton != null && !hasSkeleton) {
|
||||
return null;
|
||||
}
|
||||
final VirtualFile moduleVirtualFile = file.getVirtualFile();
|
||||
if (moduleVirtualFile != null) {
|
||||
String moduleName = QualifiedNameFinder.findShortestImportableName(file, moduleVirtualFile);
|
||||
if (moduleName != null) {
|
||||
final QualifiedName qName = QualifiedName.fromDottedString(moduleName);
|
||||
final QualifiedName restored = QualifiedNameFinder.canonizeQualifiedName(file, qName, null);
|
||||
if (restored != null) {
|
||||
moduleName = restored.toString();
|
||||
}
|
||||
final PyFile skeletonFile = getUserSkeletonForModuleQName(moduleName, file);
|
||||
file.putUserData(HAS_SKELETON, skeletonFile != null);
|
||||
return skeletonFile;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,6 @@ import com.intellij.util.concurrency.annotations.RequiresReadLock
|
||||
import com.jetbrains.python.codeInsight.typing.PyTypeShed
|
||||
import com.jetbrains.python.codeInsight.typing.isInInlinePackage
|
||||
import com.jetbrains.python.codeInsight.typing.isInStubPackage
|
||||
import com.jetbrains.python.codeInsight.userSkeletons.PyUserSkeletonsUtil
|
||||
import com.jetbrains.python.facet.PythonPathContributingFacet
|
||||
import com.jetbrains.python.module.PyModuleService
|
||||
import com.jetbrains.python.psi.LanguageLevel
|
||||
@@ -245,10 +244,8 @@ fun relativeResultsForStubsFromRoots(name: QualifiedName, context: PyQualifiedNa
|
||||
|
||||
private fun resolveWithRelativeLevel(name: QualifiedName, context: PyQualifiedNameResolveContext): List<PsiElement> {
|
||||
val footholdFile = context.footholdFile
|
||||
if (context.relativeLevel >= 0 && footholdFile != null && !PyUserSkeletonsUtil.isUnderUserSkeletonsDirectory(footholdFile)) {
|
||||
return resolveModuleAt(name, context.containingDirectory,
|
||||
context) + relativeResultsForStubsFromRoots(
|
||||
name, context)
|
||||
if (context.relativeLevel >= 0 && footholdFile != null) {
|
||||
return resolveModuleAt(name, context.containingDirectory, context) + relativeResultsForStubsFromRoots(name, context)
|
||||
}
|
||||
return emptyList()
|
||||
}
|
||||
@@ -276,7 +273,6 @@ private fun resultsFromRoots(name: QualifiedName, context: PyQualifiedNameResolv
|
||||
val results = if (isModuleSource) moduleResults else sdkResults
|
||||
val effectiveSdk = sdk ?: context.effectiveSdk
|
||||
if (!root.isValid ||
|
||||
root == PyUserSkeletonsUtil.getUserSkeletonsDirectory() ||
|
||||
effectiveSdk != null && PyTypeShed.isInside(root) && !PyTypeShed.maySearchForStubInRoot(name, root, effectiveSdk)) {
|
||||
return@RootVisitor true
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ import com.intellij.psi.search.GlobalSearchScopesCore;
|
||||
import com.intellij.psi.util.QualifiedName;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.jetbrains.python.PyNames;
|
||||
import com.jetbrains.python.codeInsight.userSkeletons.PyUserSkeletonsUtil;
|
||||
import com.jetbrains.python.psi.resolve.QualifiedNameFinder;
|
||||
import com.jetbrains.python.sdk.PythonSdkUtil;
|
||||
import one.util.streamex.StreamEx;
|
||||
@@ -49,7 +48,6 @@ public final class PySearchScopeBuilder {
|
||||
private static final Set<String> THIRD_PARTY_PACKAGE_ROOT_NAMES = Set.of(PyNames.SITE_PACKAGES, PyNames.DIST_PACKAGES);
|
||||
|
||||
private boolean myExcludeStdlibTests = false;
|
||||
private boolean myExcludePythonSkeletonsStubs = false;
|
||||
private boolean myExcludeThirdPartyBundledDeps = false;
|
||||
private boolean myExcludeThirdPartyTests = false;
|
||||
private final @NotNull Project myProject;
|
||||
@@ -84,15 +82,6 @@ public final class PySearchScopeBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Excludes the legacy <a href="https://github.com/JetBrains/python-skeletons">python-skeletons</a> (aka "user skeletons")
|
||||
* stubs from the resulting scope.
|
||||
*/
|
||||
public @NotNull PySearchScopeBuilder excludePythonSkeletonsStubs() {
|
||||
myExcludePythonSkeletonsStubs = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Excludes "vendored" dependencies bundled with third-party packages from the resulting scope, e.g. the content of "pip/_vendor".
|
||||
*/
|
||||
@@ -117,9 +106,6 @@ public final class PySearchScopeBuilder {
|
||||
if (myExcludeStdlibTests) {
|
||||
scope = scope.intersectWith(GlobalSearchScope.notScope(buildStdlibTestsScope()));
|
||||
}
|
||||
if (myExcludePythonSkeletonsStubs) {
|
||||
scope = scope.intersectWith(GlobalSearchScope.notScope(buildPythonSkeletonsStubsScope()));
|
||||
}
|
||||
if (myExcludeThirdPartyTests || myExcludeThirdPartyBundledDeps) {
|
||||
scope = scope.intersectWith(GlobalSearchScope.notScope(new QualifiedNameFinder.QualifiedNameBasedScope(myProject) {
|
||||
@Override
|
||||
@@ -154,10 +140,6 @@ public final class PySearchScopeBuilder {
|
||||
return GlobalSearchScope.EMPTY_SCOPE;
|
||||
}
|
||||
|
||||
private @NotNull GlobalSearchScope buildPythonSkeletonsStubsScope() {
|
||||
return PyUserSkeletonsUtil.getUserSkeletonsDirectoryScope(myProject);
|
||||
}
|
||||
|
||||
private static @Nullable Sdk findPythonSdkForElement(@NotNull PsiElement element) {
|
||||
Project project = element.getProject();
|
||||
Module module = ModuleUtilCore.findModuleForPsiElement(element);
|
||||
|
||||
@@ -41,7 +41,6 @@ public class PySearchUtilBase {
|
||||
public static @NotNull GlobalSearchScope defaultSuggestionScope(@NotNull PsiElement anchor) {
|
||||
return PySearchScopeBuilder.forPythonSdkOf(anchor)
|
||||
.excludeStandardLibraryTests()
|
||||
.excludePythonSkeletonsStubs()
|
||||
.excludeThirdPartyPackageTests()
|
||||
.excludeThirdPartyPackageBundledDependencies()
|
||||
.build();
|
||||
|
||||
@@ -3,8 +3,10 @@ package com.jetbrains.python.pyi;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.jetbrains.python.codeInsight.PyCustomMember;
|
||||
import com.jetbrains.python.codeInsight.userSkeletons.PyUserSkeletonsClassMembersProvider;
|
||||
import com.jetbrains.python.psi.PyClass;
|
||||
import com.jetbrains.python.psi.PyFunction;
|
||||
import com.jetbrains.python.psi.PyTargetExpression;
|
||||
import com.jetbrains.python.psi.PyUtil;
|
||||
import com.jetbrains.python.psi.resolve.PyResolveContext;
|
||||
import com.jetbrains.python.psi.types.PyClassMembersProviderBase;
|
||||
import com.jetbrains.python.psi.types.PyClassType;
|
||||
@@ -13,8 +15,10 @@ import com.jetbrains.python.psi.types.TypeEvalContext;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public final class PyiClassMembersProvider extends PyClassMembersProviderBase implements PyOverridingAncestorsClassMembersProvider {
|
||||
@Override
|
||||
@@ -22,7 +26,7 @@ public final class PyiClassMembersProvider extends PyClassMembersProviderBase im
|
||||
final PyClass cls = classType.getPyClass();
|
||||
final PsiElement pythonStub = PyiUtil.getPythonStub(cls);
|
||||
if (pythonStub instanceof PyClass) {
|
||||
return PyUserSkeletonsClassMembersProvider.getClassMembers((PyClass)pythonStub, classType.isDefinition());
|
||||
return getClassMembers((PyClass)pythonStub, classType.isDefinition());
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
@@ -35,8 +39,57 @@ public final class PyiClassMembersProvider extends PyClassMembersProviderBase im
|
||||
final PyClass cls = type.getPyClass();
|
||||
final PsiElement pythonStub = PyiUtil.getPythonStub(cls);
|
||||
if (pythonStub instanceof PyClass) {
|
||||
return PyUserSkeletonsClassMembersProvider.findClassMember((PyClass)pythonStub, name, type.isDefinition());
|
||||
return findClassMember((PyClass)pythonStub, name, type.isDefinition());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static PsiElement findClassMember(@NotNull PyClass cls, @NotNull String name, boolean isDefinition) {
|
||||
final PyFunction function = cls.findMethodByName(name, false, null);
|
||||
if (function != null) {
|
||||
final PyUtil.MethodFlags methodFlags = PyUtil.MethodFlags.of(function);
|
||||
final boolean instanceMethod = methodFlags == null || methodFlags.isInstanceMethod();
|
||||
if (isDefinition ^ instanceMethod) {
|
||||
return function;
|
||||
}
|
||||
}
|
||||
if (!isDefinition) {
|
||||
final PyTargetExpression instanceAttribute = cls.findInstanceAttribute(name, false);
|
||||
if (instanceAttribute != null) {
|
||||
return instanceAttribute;
|
||||
}
|
||||
}
|
||||
final PyTargetExpression classAttribute = cls.findClassAttribute(name, false, null);
|
||||
if (classAttribute != null) {
|
||||
return classAttribute;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Collection<PyCustomMember> getClassMembers(@NotNull PyClass cls, boolean isDefinition) {
|
||||
final List<PyCustomMember> result = new ArrayList<>();
|
||||
for (PyFunction function : cls.getMethods()) {
|
||||
final String name = function.getName();
|
||||
final PyUtil.MethodFlags methodFlags = PyUtil.MethodFlags.of(function);
|
||||
final boolean instanceMethod = methodFlags == null || methodFlags.isInstanceMethod();
|
||||
if (name != null && (isDefinition ^ instanceMethod)) {
|
||||
result.add(new PyCustomMember(name, function));
|
||||
}
|
||||
}
|
||||
if (!isDefinition) {
|
||||
for (PyTargetExpression attribute : cls.getInstanceAttributes()) {
|
||||
final String name = attribute.getName();
|
||||
if (name != null) {
|
||||
result.add(new PyCustomMember(name, attribute));
|
||||
}
|
||||
}
|
||||
}
|
||||
for (PyTargetExpression attribute : cls.getClassAttributes()) {
|
||||
final String name = attribute.getName();
|
||||
if (name != null) {
|
||||
result.add(new PyCustomMember(name, attribute));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,12 +30,14 @@ import com.intellij.util.containers.ContainerUtil;
|
||||
import com.jetbrains.python.PyNames;
|
||||
import com.jetbrains.python.PythonRuntimeService;
|
||||
import com.jetbrains.python.codeInsight.typing.PyTypeShed;
|
||||
import com.jetbrains.python.codeInsight.userSkeletons.PyUserSkeletonsUtil;
|
||||
import com.jetbrains.python.module.PyModuleService;
|
||||
import com.jetbrains.python.psi.search.PySearchUtilBase;
|
||||
import com.jetbrains.python.sdk.skeleton.PySkeletonHeader;
|
||||
import com.jetbrains.python.venvReader.VirtualEnvReader;
|
||||
import org.jetbrains.annotations.*;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
@@ -144,9 +146,6 @@ public final class PythonSdkUtil {
|
||||
if (venvLibDir != null && isUnderLibDirButNotSitePackages(originFile, originPath, venvLibDir, pythonSdk, checkOnRemoteFS)) {
|
||||
return true;
|
||||
}
|
||||
if (PyUserSkeletonsUtil.isStandardLibrarySkeleton(vFile)) {
|
||||
return true;
|
||||
}
|
||||
if (PyTypeShed.INSTANCE.isInStandardLibrary(vFile) && PyTypeShed.INSTANCE.isInside(vFile)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ import com.intellij.util.indexing.DumbModeAccessType;
|
||||
import com.intellij.util.indexing.FileBasedIndex;
|
||||
import com.intellij.util.indexing.FindSymbolParameters;
|
||||
import com.intellij.util.indexing.IdFilter;
|
||||
import com.jetbrains.python.codeInsight.userSkeletons.PyUserSkeletonsUtil;
|
||||
import com.jetbrains.python.psi.PyClass;
|
||||
import com.jetbrains.python.psi.PyFile;
|
||||
import com.jetbrains.python.psi.PyQualifiedNameOwner;
|
||||
@@ -49,7 +48,6 @@ public class PyGotoClassContributor implements GotoClassContributor, ChooseByNam
|
||||
DumbModeAccessType.RELIABLE_DATA_ONLY.ignoreDumbMode(() -> {
|
||||
if (!StubIndex.getInstance().processElements(PyClassNameIndex.KEY, name, project, scope, filter, PyClass.class, processor)) return;
|
||||
FileBasedIndex.getInstance().getFilesWithKey(PyModuleNameIndex.NAME, Collections.singleton(name), file -> {
|
||||
if (PyUserSkeletonsUtil.isUnderUserSkeletonsDirectory(file)) return true;
|
||||
PsiFile psiFile = psiManager.findFile(file);
|
||||
return !(psiFile instanceof PyFile) || processor.process(psiFile);
|
||||
}, scope);
|
||||
|
||||
@@ -15,7 +15,6 @@ import com.intellij.util.indexing.DumbModeAccessType;
|
||||
import com.intellij.util.indexing.FileBasedIndex;
|
||||
import com.intellij.util.indexing.FindSymbolParameters;
|
||||
import com.intellij.util.indexing.IdFilter;
|
||||
import com.jetbrains.python.codeInsight.userSkeletons.PyUserSkeletonsUtil;
|
||||
import com.jetbrains.python.psi.*;
|
||||
import com.jetbrains.python.psi.search.PySearchUtilBase;
|
||||
import com.jetbrains.python.psi.stubs.*;
|
||||
@@ -52,7 +51,6 @@ public class PyGotoSymbolContributor implements GotoClassContributor, ChooseByNa
|
||||
PsiManager psiManager = PsiManager.getInstance(project);
|
||||
DumbModeAccessType.RELIABLE_DATA_ONLY.ignoreDumbMode(() -> {
|
||||
if (!fileIndex.getFilesWithKey(PyModuleNameIndex.NAME, Collections.singleton(name), file -> {
|
||||
if (PyUserSkeletonsUtil.isUnderUserSkeletonsDirectory(file)) return true;
|
||||
PsiFile psiFile = psiManager.findFile(file);
|
||||
return !(psiFile instanceof PyFile) || processor.process(psiFile);
|
||||
}, scope)) return;
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.jetbrains.python.codeInsight.userSkeletons;
|
||||
|
||||
import com.intellij.codeInsight.daemon.LineMarkerInfo;
|
||||
import com.intellij.codeInsight.daemon.LineMarkerProvider;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.editor.markup.GutterIconRenderer;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiNameIdentifierOwner;
|
||||
import com.intellij.util.PsiNavigateUtil;
|
||||
import com.jetbrains.python.psi.PyElement;
|
||||
import com.jetbrains.python.psi.PyFunction;
|
||||
import com.jetbrains.python.psi.PyTargetExpression;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public final class PyUserSkeletonsLineMarkerProvider implements LineMarkerProvider {
|
||||
// TODO: Create an icon for a related user skeleton
|
||||
public static final Icon ICON = AllIcons.Gutter.Unique;
|
||||
|
||||
@Override
|
||||
public LineMarkerInfo<?> getLineMarkerInfo(@NotNull PsiElement element) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collectSlowLineMarkers(@NotNull List<? extends PsiElement> elements, @NotNull Collection<? super LineMarkerInfo<?>> result) {
|
||||
for (PsiElement element : elements) {
|
||||
final PyElement skeleton = getUserSkeleton(element);
|
||||
if (skeleton != null) {
|
||||
PsiElement identifier = ((PsiNameIdentifierOwner)element).getNameIdentifier();
|
||||
if (identifier != null) {
|
||||
result.add(new LineMarkerInfo<>(identifier, identifier.getTextRange(), ICON, __ -> "Has user skeleton", (__, elt) -> {
|
||||
final PyElement s = getUserSkeleton(elt.getParent());
|
||||
if (s != null) {
|
||||
PsiNavigateUtil.navigate(s);
|
||||
}
|
||||
}, GutterIconRenderer.Alignment.RIGHT));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static @Nullable PyElement getUserSkeleton(@NotNull PsiElement element) {
|
||||
if (element instanceof PyFunction || element instanceof PyTargetExpression) {
|
||||
return PyUserSkeletonsUtil.getUserSkeleton((PyElement)element);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,6 @@ import com.intellij.util.ArrayUtil;
|
||||
import com.jetbrains.python.PyBundle;
|
||||
import com.jetbrains.python.codeInsight.typing.PyBundledStubs;
|
||||
import com.jetbrains.python.codeInsight.typing.PyTypeShed;
|
||||
import com.jetbrains.python.codeInsight.userSkeletons.PyUserSkeletonsUtil;
|
||||
import com.jetbrains.python.sdk.PythonSdkAdditionalData;
|
||||
import com.jetbrains.python.sdk.PythonSdkUtil;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
@@ -37,8 +36,8 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
public class PythonPathEditor extends SdkPathEditor {
|
||||
private final @NotNull PathListModel myPathListModel;
|
||||
@@ -290,9 +289,6 @@ public class PythonPathEditor extends SdkPathEditor {
|
||||
if (skeletonRoot != null && file.getPath().startsWith(skeletonRoot.getPath())) {
|
||||
return true;
|
||||
}
|
||||
else if (file.equals(PyUserSkeletonsUtil.getUserSkeletonsDirectory())) {
|
||||
return true;
|
||||
}
|
||||
else if (PyTypeShed.INSTANCE.isInside(file)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,6 @@ import com.jetbrains.python.PyNames;
|
||||
import com.jetbrains.python.PyPsiPackageUtil;
|
||||
import com.jetbrains.python.codeInsight.controlflow.ScopeOwner;
|
||||
import com.jetbrains.python.codeInsight.typing.PyTypeShed;
|
||||
import com.jetbrains.python.codeInsight.userSkeletons.PyUserSkeletonsUtil;
|
||||
import com.jetbrains.python.psi.*;
|
||||
import com.jetbrains.python.psi.impl.PyPsiUtils;
|
||||
import com.jetbrains.python.psi.resolve.PyResolveContext;
|
||||
@@ -575,9 +574,7 @@ public final class PyPackageUtil {
|
||||
}
|
||||
final String skeletonsPath = PythonSdkUtil.getSkeletonsPath(PathManager.getSystemPath(), sdk.getHomePath());
|
||||
final VirtualFile skeletonsRoot = LocalFileSystem.getInstance().findFileByPath(skeletonsPath);
|
||||
result.removeIf(vf -> vf.equals(skeletonsRoot) ||
|
||||
vf.equals(PyUserSkeletonsUtil.getUserSkeletonsDirectory()) ||
|
||||
PyTypeShed.INSTANCE.isInside(vf));
|
||||
result.removeIf(vf -> vf.equals(skeletonsRoot) || PyTypeShed.INSTANCE.isInside(vf));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.jetbrains.python.codeInsight.typing.PyBundledStubs;
|
||||
import com.jetbrains.python.codeInsight.typing.PyTypeShed;
|
||||
import com.jetbrains.python.codeInsight.userSkeletons.PyUserSkeletonsUtil;
|
||||
import com.jetbrains.python.psi.PyDocStringOwner;
|
||||
import com.jetbrains.python.psi.PyFile;
|
||||
import com.jetbrains.python.psi.PyFunction;
|
||||
@@ -52,10 +51,6 @@ public final class PyTreeStructureProvider implements SelectableTreeStructurePro
|
||||
if (skeletonsNode != null) {
|
||||
newChildren.add(skeletonsNode);
|
||||
}
|
||||
final PyUserSkeletonsNode userSkeletonsNode = PyUserSkeletonsNode.create(project, settings);
|
||||
if (userSkeletonsNode != null) {
|
||||
newChildren.add(userSkeletonsNode);
|
||||
}
|
||||
final PyRemoteLibrariesNode remoteLibrariesNode = PyRemoteLibrariesNode.create(project, sdk, settings);
|
||||
if (remoteLibrariesNode != null) {
|
||||
newChildren.add(remoteLibrariesNode);
|
||||
@@ -112,9 +107,6 @@ public final class PyTreeStructureProvider implements SelectableTreeStructurePro
|
||||
continue;
|
||||
}
|
||||
VirtualFile dir = directory.getVirtualFile();
|
||||
if (dir.equals(PyUserSkeletonsUtil.getUserSkeletonsDirectory())) {
|
||||
continue;
|
||||
}
|
||||
if (dir.getFileSystem() instanceof JarFileSystem) {
|
||||
dir = ((JarFileSystem)dir.getFileSystem()).getLocalByEntry(dir);
|
||||
}
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.jetbrains.python.projectView;
|
||||
|
||||
import com.intellij.ide.projectView.PresentationData;
|
||||
import com.intellij.ide.projectView.ViewSettings;
|
||||
import com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiDirectory;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.util.PlatformIcons;
|
||||
import com.jetbrains.python.PyBundle;
|
||||
import com.jetbrains.python.codeInsight.userSkeletons.PyUserSkeletonsUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public final class PyUserSkeletonsNode extends PsiDirectoryNode {
|
||||
private PyUserSkeletonsNode(Project project, @NotNull PsiDirectory value, ViewSettings viewSettings) {
|
||||
super(project, value, viewSettings);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateImpl(@NotNull PresentationData data) {
|
||||
data.setPresentableText(PyBundle.message("python.project.view.user.skeletons.node"));
|
||||
data.setIcon(PlatformIcons.LIBRARY_ICON);
|
||||
}
|
||||
|
||||
public static @Nullable PyUserSkeletonsNode create(@NotNull Project project, ViewSettings viewSettings) {
|
||||
final VirtualFile userSkeletonsVirtualFile = PyUserSkeletonsUtil.getUserSkeletonsDirectory();
|
||||
if (userSkeletonsVirtualFile != null) {
|
||||
final PsiDirectory userSkeletonsDirectory = PsiManager.getInstance(project).findDirectory(userSkeletonsVirtualFile);
|
||||
if (userSkeletonsDirectory != null) {
|
||||
return new PyUserSkeletonsNode(project, userSkeletonsDirectory, viewSettings);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -44,7 +44,6 @@ import com.jetbrains.python.PyPsiPackageUtil;
|
||||
import com.jetbrains.python.PythonPluginDisposable;
|
||||
import com.jetbrains.python.codeInsight.typing.PyBundledStubs;
|
||||
import com.jetbrains.python.codeInsight.typing.PyTypeShed;
|
||||
import com.jetbrains.python.codeInsight.userSkeletons.PyUserSkeletonsUtil;
|
||||
import com.jetbrains.python.packaging.PyPackageManager;
|
||||
import com.jetbrains.python.packaging.PyPackageManagerBridge;
|
||||
import com.jetbrains.python.packaging.common.PythonPackage;
|
||||
@@ -665,11 +664,6 @@ public final class PythonSdkUpdater {
|
||||
LOG.info("Binary skeletons directory for SDK " + getSdkPresentableName(sdk) + "): " + skeletonsDir.getPath());
|
||||
}
|
||||
}
|
||||
final VirtualFile userSkeletonsDir = PyUserSkeletonsUtil.getUserSkeletonsDirectory();
|
||||
if (userSkeletonsDir != null) {
|
||||
results.add(userSkeletonsDir);
|
||||
LOG.info("User skeletons directory for SDK " + getSdkPresentableName(sdk) + "): " + userSkeletonsDir.getPath());
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ import com.jetbrains.python.PyBundle;
|
||||
import com.jetbrains.python.PyNames;
|
||||
import com.jetbrains.python.PythonHelpersLocator;
|
||||
import com.jetbrains.python.codeInsight.typing.PyTypeShed;
|
||||
import com.jetbrains.python.codeInsight.userSkeletons.PyUserSkeletonsUtil;
|
||||
import com.jetbrains.python.remote.PyRemoteSdkAdditionalDataBase;
|
||||
import com.jetbrains.python.remote.PyRemoteSkeletonGeneratorFactory;
|
||||
import com.jetbrains.python.sdk.InvalidSdkException;
|
||||
@@ -195,9 +194,6 @@ public class PySkeletonRefresher {
|
||||
private static List<String> calculateExtraSysPath(final @NotNull Sdk sdk, final @Nullable String skeletonsPath) {
|
||||
final File skeletons = skeletonsPath != null ? new File(skeletonsPath) : null;
|
||||
|
||||
final VirtualFile userSkeletonsDir = PyUserSkeletonsUtil.getUserSkeletonsDirectory();
|
||||
final File userSkeletons = userSkeletonsDir != null ? new File(userSkeletonsDir.getPath()) : null;
|
||||
|
||||
final VirtualFile remoteSourcesDir = PythonSdkUtil.findAnyRemoteLibrary(sdk);
|
||||
final File remoteSources = remoteSourcesDir != null ? new File(remoteSourcesDir.getPath()) : null;
|
||||
|
||||
@@ -207,7 +203,6 @@ public class PySkeletonRefresher {
|
||||
final File canonicalFile = new File(file.getPath());
|
||||
if (canonicalFile.exists() &&
|
||||
!FileUtil.filesEqual(canonicalFile, skeletons) &&
|
||||
!FileUtil.filesEqual(canonicalFile, userSkeletons) &&
|
||||
!PyTypeShed.INSTANCE.isInside(file) &&
|
||||
!FileUtil.filesEqual(canonicalFile, remoteSources)) {
|
||||
return file.getPath();
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
nd<caret>
|
||||
@@ -1,5 +1,5 @@
|
||||
from struct import Struct
|
||||
|
||||
s = Struct('c')
|
||||
s.unpack(<warning descr="Expected type 'bytes', got 'str' instead">'\x00'</warning>)
|
||||
s.unpack(<warning descr="Expected type 'Buffer', got 'str' instead">'\x00'</warning>)
|
||||
s.unpack(b'\x00')
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
class Struct(object):
|
||||
def __init__(self, format):
|
||||
pass
|
||||
|
||||
def unpack(self, string):
|
||||
return ()
|
||||
@@ -1,2 +0,0 @@
|
||||
def copy(x):
|
||||
pass
|
||||
@@ -1,2 +0,0 @@
|
||||
def deepcopy(x):
|
||||
pass
|
||||
@@ -1,5 +0,0 @@
|
||||
from . import core
|
||||
from .core import *
|
||||
|
||||
__all__ = []
|
||||
__all__.extend(core.__all__)
|
||||
@@ -1,6 +0,0 @@
|
||||
from . import multiarray
|
||||
from . import numeric
|
||||
from .numeric import *
|
||||
|
||||
__all__ = []
|
||||
__all__ += numeric.__all__
|
||||
@@ -1,129 +0,0 @@
|
||||
class ndarray(object):
|
||||
"""
|
||||
ndarray(shape, dtype=float, buffer=None, offset=0,
|
||||
strides=None, order=None)
|
||||
|
||||
An array object represents a multidimensional, homogeneous array
|
||||
of fixed-size items. An associated data-type object describes the
|
||||
format of each element in the array (its byte-order, how many bytes it
|
||||
occupies in memory, whether it is an integer, a floating point number,
|
||||
or something else, etc.)
|
||||
|
||||
Arrays should be constructed using `array`, `zeros` or `empty` (refer
|
||||
to the See Also section below). The parameters given here refer to
|
||||
a low-level method (`ndarray(...)`) for instantiating an array.
|
||||
|
||||
For more information, refer to the `numpy` module and examine the
|
||||
the methods and attributes of an array.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
(for the __new__ method; see Notes below)
|
||||
|
||||
shape : tuple of ints
|
||||
Shape of created array.
|
||||
dtype : data-type, optional
|
||||
Any object that can be interpreted as a numpy data type.
|
||||
buffer : object exposing buffer interface, optional
|
||||
Used to fill the array with data.
|
||||
offset : int, optional
|
||||
Offset of array data in buffer.
|
||||
strides : tuple of ints, optional
|
||||
Strides of data in memory.
|
||||
order : {'C', 'F'}, optional
|
||||
Row-major or column-major order.
|
||||
|
||||
Attributes
|
||||
----------
|
||||
T : ndarray
|
||||
Transpose of the array.
|
||||
data : buffer
|
||||
The array's elements, in memory.
|
||||
dtype : dtype object
|
||||
Describes the format of the elements in the array.
|
||||
flags : dict
|
||||
Dictionary containing information related to memory use, e.g.,
|
||||
'C_CONTIGUOUS', 'OWNDATA', 'WRITEABLE', etc.
|
||||
flat : numpy.flatiter object
|
||||
Flattened version of the array as an iterator. The iterator
|
||||
allows assignments, e.g., ``x.flat = 3`` (See `ndarray.flat` for
|
||||
assignment examples; TODO).
|
||||
imag : ndarray
|
||||
Imaginary part of the array.
|
||||
real : ndarray
|
||||
Real part of the array.
|
||||
size : int
|
||||
Number of elements in the array.
|
||||
itemsize : int
|
||||
The memory use of each array element in bytes.
|
||||
nbytes : int
|
||||
The total number of bytes required to store the array data,
|
||||
i.e., ``itemsize * size``.
|
||||
ndim : int
|
||||
The array's number of dimensions.
|
||||
shape : tuple of ints
|
||||
Shape of the array.
|
||||
strides : tuple of ints
|
||||
The step-size required to move from one element to the next in
|
||||
memory. For example, a contiguous ``(3, 4)`` array of type
|
||||
``int16`` in C-order has strides ``(8, 2)``. This implies that
|
||||
to move from element to element in memory requires jumps of 2 bytes.
|
||||
To move from row-to-row, one needs to jump 8 bytes at a time
|
||||
(``2 * 4``).
|
||||
ctypes : ctypes object
|
||||
Class containing properties of the array needed for interaction
|
||||
with ctypes.
|
||||
base : ndarray
|
||||
If the array is a view into another array, that array is its `base`
|
||||
(unless that array is also a view). The `base` array is where the
|
||||
array data is actually stored.
|
||||
|
||||
See Also
|
||||
--------
|
||||
array : Construct an array.
|
||||
zeros : Create an array, each element of which is zero.
|
||||
empty : Create an array, but leave its allocated memory unchanged (i.e.,
|
||||
it contains "garbage").
|
||||
dtype : Create a data-type.
|
||||
|
||||
Notes
|
||||
-----
|
||||
There are two modes of creating an array using ``__new__``:
|
||||
|
||||
1. If `buffer` is None, then only `shape`, `dtype`, and `order`
|
||||
are used.
|
||||
2. If `buffer` is an object exposing the buffer interface, then
|
||||
all keywords are interpreted.
|
||||
|
||||
No ``__init__`` method is needed because the array is fully initialized
|
||||
after the ``__new__`` method.
|
||||
|
||||
Examples
|
||||
--------
|
||||
These examples illustrate the low-level `ndarray` constructor. Refer
|
||||
to the `See Also` section above for easier ways of constructing an
|
||||
ndarray.
|
||||
|
||||
First mode, `buffer` is None:
|
||||
|
||||
>>> np.ndarray(shape=(2,2), dtype=float, order='F')
|
||||
array([[ -1.13698227e+002, 4.25087011e-303],
|
||||
[ 2.88528414e-306, 3.27025015e-309]]) #random
|
||||
|
||||
Second mode:
|
||||
|
||||
>>> np.ndarray((2,), buffer=np.array([1,2,3]),
|
||||
... offset=np.int_().itemsize,
|
||||
... dtype=int) # offset = 1*itemsize, i.e. skip first element
|
||||
array([2, 3])
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
def __mul__(self, y):
|
||||
""" x.__mul__(y) <==> x*y """
|
||||
pass
|
||||
|
||||
def __rmul__(self, y):
|
||||
""" x.__rmul__(y) <==> x*y """
|
||||
pass
|
||||
@@ -1,51 +0,0 @@
|
||||
from . import multiarray
|
||||
|
||||
__all__ = ['ndarray', 'ones']
|
||||
|
||||
|
||||
ndarray = multiarray.ndarray
|
||||
|
||||
def ones(shape, dtype=None, order='C'):
|
||||
"""
|
||||
**Test docstring**
|
||||
Return a new array of given shape and type, filled with ones.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
shape : int or sequence of ints
|
||||
Shape of the new array, e.g., ``(2, 3)`` or ``2``.
|
||||
dtype : data-type, optional
|
||||
The desired data-type for the array, e.g., `numpy.int8`. Default is
|
||||
`numpy.float64`.
|
||||
order : {'C', 'F'}, optional
|
||||
Whether to store multidimensional data in C- or Fortran-contiguous
|
||||
(row- or column-wise) order in memory.
|
||||
|
||||
Returns
|
||||
-------
|
||||
out : ndarray
|
||||
Array of ones with the given shape, dtype, and order.
|
||||
|
||||
See Also
|
||||
--------
|
||||
zeros, ones_like
|
||||
|
||||
Examples
|
||||
--------
|
||||
>>> np.ones(5)
|
||||
array([ 1., 1., 1., 1., 1.])
|
||||
|
||||
>>> np.ones((5,), dtype=np.int)
|
||||
array([1, 1, 1, 1, 1])
|
||||
|
||||
>>> np.ones((2, 1))
|
||||
array([[ 1.],
|
||||
[ 1.]])
|
||||
|
||||
>>> s = (2,2)
|
||||
>>> np.ones(s)
|
||||
array([[ 1., 1.],
|
||||
[ 1., 1.]])
|
||||
|
||||
"""
|
||||
pass
|
||||
@@ -4,22 +4,17 @@ package com.jetbrains.python;
|
||||
import com.intellij.codeInsight.completion.CompletionType;
|
||||
import com.intellij.codeInsight.lookup.Lookup;
|
||||
import com.intellij.codeInsight.lookup.LookupElement;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiDirectory;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFileSystemItem;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.testFramework.fixtures.TestLookupElementPresentation;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.jetbrains.python.codeInsight.PyCodeInsightSettings;
|
||||
import com.jetbrains.python.codeInsight.userSkeletons.PyUserSkeletonsUtil;
|
||||
import com.jetbrains.python.fixtures.PyTestCase;
|
||||
import com.jetbrains.python.formatter.PyCodeStyleSettings;
|
||||
import com.jetbrains.python.psi.PyClass;
|
||||
import com.jetbrains.python.psi.PyQualifiedNameOwner;
|
||||
import com.jetbrains.python.psi.resolve.QualifiedNameFinder;
|
||||
import com.jetbrains.python.psi.stubs.PyClassNameIndex;
|
||||
import one.util.streamex.StreamEx;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -178,21 +173,6 @@ public class PyClassNameCompletionTest extends PyTestCase {
|
||||
assertEquals("pkg.mod", varPresentation.getTypeText());
|
||||
}
|
||||
|
||||
// PY-45566
|
||||
public void testPythonSkeletonsVariantsNotSuggested() {
|
||||
LookupElement[] lookupElements = doExtendedCompletion();
|
||||
|
||||
LookupElement ndarray = ContainerUtil.find(lookupElements, variant -> variant.getLookupString().equals("ndarray"));
|
||||
assertNull(ndarray);
|
||||
|
||||
Project project = myFixture.getProject();
|
||||
PyClass ndarrayUserSkeleton = ContainerUtil.getFirstItem(PyClassNameIndex.findByQualifiedName("numpy.core.multiarray.ndarray",
|
||||
project,
|
||||
GlobalSearchScope.allScope(project)));
|
||||
assertNotNull(ndarrayUserSkeleton);
|
||||
assertTrue(PyUserSkeletonsUtil.isUnderUserSkeletonsDirectory(ndarrayUserSkeleton.getContainingFile()));
|
||||
}
|
||||
|
||||
// PY-46381
|
||||
public void testThirdPartyPackageTestsNotSuggested() {
|
||||
runWithAdditionalClassEntryInSdkRoots(getTestName(true) + "/site-packages", () -> {
|
||||
|
||||
@@ -1225,15 +1225,6 @@ public class PyTypeTest extends PyTestCase {
|
||||
expr = f3(42)""");
|
||||
}
|
||||
|
||||
// PY-8836
|
||||
public void testNumpyArrayIntMultiplicationType() {
|
||||
doMultiFileTest("ndarray",
|
||||
"""
|
||||
import numpy as np
|
||||
expr = np.ones(10) * 2
|
||||
""");
|
||||
}
|
||||
|
||||
// PY-9439
|
||||
public void testNumpyArrayType() {
|
||||
doMultiFileTest("ndarray",
|
||||
@@ -1721,24 +1712,24 @@ public class PyTypeTest extends PyTestCase {
|
||||
|
||||
// PY-8473
|
||||
public void testCopyDotCopy() {
|
||||
doMultiFileTest("A",
|
||||
"""
|
||||
import copy
|
||||
class A(object):
|
||||
pass
|
||||
expr = copy.copy(A())
|
||||
""");
|
||||
doTest("A",
|
||||
"""
|
||||
import copy
|
||||
class A(object):
|
||||
pass
|
||||
expr = copy.copy(A())
|
||||
""");
|
||||
}
|
||||
|
||||
// PY-8473
|
||||
public void testCopyDotDeepCopy() {
|
||||
doMultiFileTest("A",
|
||||
"""
|
||||
import copy
|
||||
class A(object):
|
||||
pass
|
||||
expr = copy.deepcopy(A())
|
||||
""");
|
||||
doTest("A",
|
||||
"""
|
||||
import copy
|
||||
class A(object):
|
||||
pass
|
||||
expr = copy.deepcopy(A())
|
||||
""");
|
||||
}
|
||||
|
||||
// PY-21083
|
||||
|
||||
@@ -9,7 +9,6 @@ import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.jetbrains.python.codeInsight.typing.PyTypeShed;
|
||||
import com.jetbrains.python.codeInsight.userSkeletons.PyUserSkeletonsUtil;
|
||||
import com.jetbrains.python.psi.LanguageLevel;
|
||||
import com.jetbrains.python.sdk.PythonSdkAdditionalData;
|
||||
import com.jetbrains.python.sdk.PythonSdkUtil;
|
||||
@@ -91,8 +90,6 @@ public final class PythonMockSdk {
|
||||
ContainerUtil.addIfNotNull(result, localFS.refreshAndFindFileByIoFile(new File(mockSdkPath, "Lib")));
|
||||
ContainerUtil.addIfNotNull(result, localFS.refreshAndFindFileByIoFile(new File(mockSdkPath, PythonSdkUtil.SKELETON_DIR_NAME)));
|
||||
|
||||
ContainerUtil.addIfNotNull(result, PyUserSkeletonsUtil.getUserSkeletonsDirectory());
|
||||
|
||||
result.addAll(PyTypeShed.INSTANCE.findStdlibRootsForLanguageLevel(level));
|
||||
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user