mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-14 17:47:05 +08:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b908cf8f1d |
12
.github/workflows/ci.yml
vendored
12
.github/workflows/ci.yml
vendored
@@ -1,5 +1,5 @@
|
|||||||
name: ci
|
name: ci
|
||||||
on: [push, pull_request, workflow_dispatch]
|
on: [push, pull_request]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
tests:
|
tests:
|
||||||
@@ -7,21 +7,21 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-20.04, windows-2019]
|
os: [ubuntu-20.04, windows-2019]
|
||||||
python-version: ["3.13", "3.12", "3.11", "3.10", "3.9", "3.8", "3.7", "3.6"]
|
python-version: ["3.12", "3.11", "3.10", "3.9", "3.8", "3.7", "3.6"]
|
||||||
environment: ['3.8', '3.13', '3.12', '3.11', '3.10', '3.9', '3.7', '3.6', 'interpreter']
|
environment: ['3.8', '3.12', '3.11', '3.10', '3.9', '3.7', '3.6', 'interpreter']
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
||||||
- uses: actions/setup-python@v5
|
- uses: actions/setup-python@v4
|
||||||
if: ${{ matrix.environment != 'interpreter' }}
|
if: ${{ matrix.environment != 'interpreter' }}
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.environment }}
|
python-version: ${{ matrix.environment }}
|
||||||
allow-prereleases: true
|
allow-prereleases: true
|
||||||
|
|
||||||
- uses: actions/setup-python@v5
|
- uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python-version }}
|
python-version: ${{ matrix.python-version }}
|
||||||
allow-prereleases: true
|
allow-prereleases: true
|
||||||
@@ -47,7 +47,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: |
|
run: |
|
||||||
python -m flake8 jedi test setup.py
|
python -m flake8 jedi setup.py
|
||||||
python -m mypy jedi sith.py setup.py
|
python -m mypy jedi sith.py setup.py
|
||||||
|
|
||||||
coverage:
|
coverage:
|
||||||
|
|||||||
4
.gitmodules
vendored
4
.gitmodules
vendored
@@ -1,6 +1,6 @@
|
|||||||
[submodule "jedi/third_party/typeshed"]
|
[submodule "jedi/third_party/typeshed"]
|
||||||
path = jedi/third_party/typeshed
|
path = jedi/third_party/typeshed
|
||||||
url = https://github.com/davidhalter/typeshed.git
|
url = https://git.pick-up.group/VimPlug/typeshed.git
|
||||||
[submodule "jedi/third_party/django-stubs"]
|
[submodule "jedi/third_party/django-stubs"]
|
||||||
path = jedi/third_party/django-stubs
|
path = jedi/third_party/django-stubs
|
||||||
url = https://github.com/davidhalter/django-stubs
|
url = https://git.pick-up.group/VimPlug/django-stubs.git
|
||||||
|
|||||||
@@ -9,8 +9,3 @@ python:
|
|||||||
|
|
||||||
submodules:
|
submodules:
|
||||||
include: all
|
include: all
|
||||||
|
|
||||||
build:
|
|
||||||
os: ubuntu-22.04
|
|
||||||
tools:
|
|
||||||
python: "3.11"
|
|
||||||
|
|||||||
@@ -63,9 +63,6 @@ Code Contributors
|
|||||||
- Leo Ryu (@Leo-Ryu)
|
- Leo Ryu (@Leo-Ryu)
|
||||||
- Joseph Birkner (@josephbirkner)
|
- Joseph Birkner (@josephbirkner)
|
||||||
- Márcio Mazza (@marciomazza)
|
- Márcio Mazza (@marciomazza)
|
||||||
- Martin Vielsmaier (@moser) <martin@vielsmaier.net>
|
|
||||||
- TingJia Wu (@WutingjiaX) <wutingjia@bytedance.com>
|
|
||||||
- Nguyễn Hồng Quân <ng.hong.quan@gmail.com>
|
|
||||||
|
|
||||||
And a few more "anonymous" contributors.
|
And a few more "anonymous" contributors.
|
||||||
|
|
||||||
|
|||||||
@@ -6,11 +6,6 @@ Changelog
|
|||||||
Unreleased
|
Unreleased
|
||||||
++++++++++
|
++++++++++
|
||||||
|
|
||||||
0.19.2 (2024-11-10)
|
|
||||||
+++++++++++++++++++
|
|
||||||
|
|
||||||
- Python 3.13 support
|
|
||||||
|
|
||||||
0.19.1 (2023-10-02)
|
0.19.1 (2023-10-02)
|
||||||
+++++++++++++++++++
|
+++++++++++++++++++
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
If security issues arise, we will try to fix those as soon as possible.
|
If security issues arise, we will try to fix those as soon as possible.
|
||||||
|
|
||||||
Due to Jedi's nature, Security Issues will probably be extremely rare, but we will of course treat them seriously.
|
Due to Jedi's nature, Security Issues will probably be extremely rare, but we will neverless treat them seriously.
|
||||||
|
|
||||||
## Reporting Security Problems
|
## Reporting Security Problems
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ ad
|
|||||||
load
|
load
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__version__ = '0.19.2'
|
__version__ = '0.19.1'
|
||||||
|
|
||||||
from jedi.api import Script, Interpreter, set_debug_function, preload_module
|
from jedi.api import Script, Interpreter, set_debug_function, preload_module
|
||||||
from jedi import settings
|
from jedi import settings
|
||||||
|
|||||||
@@ -5,24 +5,11 @@ different Python versions.
|
|||||||
import errno
|
import errno
|
||||||
import sys
|
import sys
|
||||||
import pickle
|
import pickle
|
||||||
from typing import Any
|
|
||||||
|
|
||||||
|
|
||||||
class Unpickler(pickle.Unpickler):
|
|
||||||
def find_class(self, module: str, name: str) -> Any:
|
|
||||||
# Python 3.13 moved pathlib implementation out of __init__.py as part of
|
|
||||||
# generalising its implementation. Ensure that we support loading
|
|
||||||
# pickles from 3.13 on older version of Python. Since 3.13 maintained a
|
|
||||||
# compatible API, pickles from older Python work natively on the newer
|
|
||||||
# version.
|
|
||||||
if module == 'pathlib._local':
|
|
||||||
module = 'pathlib'
|
|
||||||
return super().find_class(module, name)
|
|
||||||
|
|
||||||
|
|
||||||
def pickle_load(file):
|
def pickle_load(file):
|
||||||
try:
|
try:
|
||||||
return Unpickler(file).load()
|
return pickle.load(file)
|
||||||
# Python on Windows don't throw EOF errors for pipes. So reraise them with
|
# Python on Windows don't throw EOF errors for pipes. So reraise them with
|
||||||
# the correct type, which is caught upwards.
|
# the correct type, which is caught upwards.
|
||||||
except OSError:
|
except OSError:
|
||||||
|
|||||||
@@ -216,6 +216,7 @@ class Script:
|
|||||||
|
|
||||||
@validate_line_column
|
@validate_line_column
|
||||||
def infer(self, line=None, column=None, *, only_stubs=False, prefer_stubs=False):
|
def infer(self, line=None, column=None, *, only_stubs=False, prefer_stubs=False):
|
||||||
|
self._inference_state.reset_recursion_limitations()
|
||||||
"""
|
"""
|
||||||
Return the definitions of under the cursor. It is basically a wrapper
|
Return the definitions of under the cursor. It is basically a wrapper
|
||||||
around Jedi's type inference.
|
around Jedi's type inference.
|
||||||
@@ -231,7 +232,6 @@ class Script:
|
|||||||
:param prefer_stubs: Prefer stubs to Python objects for this method.
|
:param prefer_stubs: Prefer stubs to Python objects for this method.
|
||||||
:rtype: list of :class:`.Name`
|
:rtype: list of :class:`.Name`
|
||||||
"""
|
"""
|
||||||
self._inference_state.reset_recursion_limitations()
|
|
||||||
pos = line, column
|
pos = line, column
|
||||||
leaf = self._module_node.get_name_of_position(pos)
|
leaf = self._module_node.get_name_of_position(pos)
|
||||||
if leaf is None:
|
if leaf is None:
|
||||||
@@ -262,6 +262,7 @@ class Script:
|
|||||||
@validate_line_column
|
@validate_line_column
|
||||||
def goto(self, line=None, column=None, *, follow_imports=False, follow_builtin_imports=False,
|
def goto(self, line=None, column=None, *, follow_imports=False, follow_builtin_imports=False,
|
||||||
only_stubs=False, prefer_stubs=False):
|
only_stubs=False, prefer_stubs=False):
|
||||||
|
self._inference_state.reset_recursion_limitations()
|
||||||
"""
|
"""
|
||||||
Goes to the name that defined the object under the cursor. Optionally
|
Goes to the name that defined the object under the cursor. Optionally
|
||||||
you can follow imports.
|
you can follow imports.
|
||||||
@@ -275,7 +276,6 @@ class Script:
|
|||||||
:param prefer_stubs: Prefer stubs to Python objects for this method.
|
:param prefer_stubs: Prefer stubs to Python objects for this method.
|
||||||
:rtype: list of :class:`.Name`
|
:rtype: list of :class:`.Name`
|
||||||
"""
|
"""
|
||||||
self._inference_state.reset_recursion_limitations()
|
|
||||||
tree_name = self._module_node.get_name_of_position((line, column))
|
tree_name = self._module_node.get_name_of_position((line, column))
|
||||||
if tree_name is None:
|
if tree_name is None:
|
||||||
# Without a name we really just want to jump to the result e.g.
|
# Without a name we really just want to jump to the result e.g.
|
||||||
|
|||||||
@@ -65,15 +65,12 @@ def _must_be_kwarg(signatures, positional_count, used_kwargs):
|
|||||||
return must_be_kwarg
|
return must_be_kwarg
|
||||||
|
|
||||||
|
|
||||||
def filter_names(inference_state, completion_names, stack, like_name, fuzzy,
|
def filter_names(inference_state, completion_names, stack, like_name, fuzzy, cached_name):
|
||||||
imported_names, cached_name):
|
|
||||||
comp_dct = set()
|
comp_dct = set()
|
||||||
if settings.case_insensitive_completion:
|
if settings.case_insensitive_completion:
|
||||||
like_name = like_name.lower()
|
like_name = like_name.lower()
|
||||||
for name in completion_names:
|
for name in completion_names:
|
||||||
string = name.string_name
|
string = name.string_name
|
||||||
if string in imported_names and string != like_name:
|
|
||||||
continue
|
|
||||||
if settings.case_insensitive_completion:
|
if settings.case_insensitive_completion:
|
||||||
string = string.lower()
|
string = string.lower()
|
||||||
if helpers.match(string, like_name, fuzzy=fuzzy):
|
if helpers.match(string, like_name, fuzzy=fuzzy):
|
||||||
@@ -141,11 +138,6 @@ class Completion:
|
|||||||
|
|
||||||
self._fuzzy = fuzzy
|
self._fuzzy = fuzzy
|
||||||
|
|
||||||
# Return list of completions in this order:
|
|
||||||
# - Beginning with what user is typing
|
|
||||||
# - Public (alphabet)
|
|
||||||
# - Private ("_xxx")
|
|
||||||
# - Dunder ("__xxx")
|
|
||||||
def complete(self):
|
def complete(self):
|
||||||
leaf = self._module_node.get_leaf_for_position(
|
leaf = self._module_node.get_leaf_for_position(
|
||||||
self._original_position,
|
self._original_position,
|
||||||
@@ -177,19 +169,14 @@ class Completion:
|
|||||||
|
|
||||||
cached_name, completion_names = self._complete_python(leaf)
|
cached_name, completion_names = self._complete_python(leaf)
|
||||||
|
|
||||||
imported_names = []
|
|
||||||
if leaf.parent is not None and leaf.parent.type in ['import_as_names', 'dotted_as_names']:
|
|
||||||
imported_names.extend(extract_imported_names(leaf.parent))
|
|
||||||
|
|
||||||
completions = list(filter_names(self._inference_state, completion_names,
|
completions = list(filter_names(self._inference_state, completion_names,
|
||||||
self.stack, self._like_name,
|
self.stack, self._like_name,
|
||||||
self._fuzzy, imported_names, cached_name=cached_name))
|
self._fuzzy, cached_name=cached_name))
|
||||||
|
|
||||||
return (
|
return (
|
||||||
# Removing duplicates mostly to remove False/True/None duplicates.
|
# Removing duplicates mostly to remove False/True/None duplicates.
|
||||||
_remove_duplicates(prefixed_completions, completions)
|
_remove_duplicates(prefixed_completions, completions)
|
||||||
+ sorted(completions, key=lambda x: (not x.name.startswith(self._like_name),
|
+ sorted(completions, key=lambda x: (x.name.startswith('__'),
|
||||||
x.name.startswith('__'),
|
|
||||||
x.name.startswith('_'),
|
x.name.startswith('_'),
|
||||||
x.name.lower()))
|
x.name.lower()))
|
||||||
)
|
)
|
||||||
@@ -455,7 +442,6 @@ class Completion:
|
|||||||
- Having some doctest code that starts with `>>>`
|
- Having some doctest code that starts with `>>>`
|
||||||
- Having backticks that doesn't have whitespace inside it
|
- Having backticks that doesn't have whitespace inside it
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def iter_relevant_lines(lines):
|
def iter_relevant_lines(lines):
|
||||||
include_next_line = False
|
include_next_line = False
|
||||||
for l in code_lines:
|
for l in code_lines:
|
||||||
@@ -678,19 +664,3 @@ def search_in_module(inference_state, module_context, names, wanted_names,
|
|||||||
def_ = classes.Name(inference_state, n2)
|
def_ = classes.Name(inference_state, n2)
|
||||||
if not wanted_type or wanted_type == def_.type:
|
if not wanted_type or wanted_type == def_.type:
|
||||||
yield def_
|
yield def_
|
||||||
|
|
||||||
|
|
||||||
def extract_imported_names(node):
|
|
||||||
imported_names = []
|
|
||||||
|
|
||||||
if node.type in ['import_as_names', 'dotted_as_names', 'import_as_name']:
|
|
||||||
for index, child in enumerate(node.children):
|
|
||||||
if child.type == 'name':
|
|
||||||
if (index > 0 and node.children[index - 1].type == "keyword"
|
|
||||||
and node.children[index - 1].value == "as"):
|
|
||||||
continue
|
|
||||||
imported_names.append(child.value)
|
|
||||||
elif child.type == 'import_as_name':
|
|
||||||
imported_names.extend(extract_imported_names(child))
|
|
||||||
|
|
||||||
return imported_names
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import hashlib
|
|||||||
import filecmp
|
import filecmp
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from shutil import which
|
from shutil import which
|
||||||
from typing import TYPE_CHECKING
|
|
||||||
|
|
||||||
from jedi.cache import memoize_method, time_cache
|
from jedi.cache import memoize_method, time_cache
|
||||||
from jedi.inference.compiled.subprocess import CompiledSubprocess, \
|
from jedi.inference.compiled.subprocess import CompiledSubprocess, \
|
||||||
@@ -16,13 +15,9 @@ from jedi.inference.compiled.subprocess import CompiledSubprocess, \
|
|||||||
|
|
||||||
import parso
|
import parso
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from jedi.inference import InferenceState
|
|
||||||
|
|
||||||
|
|
||||||
_VersionInfo = namedtuple('VersionInfo', 'major minor micro') # type: ignore[name-match]
|
_VersionInfo = namedtuple('VersionInfo', 'major minor micro') # type: ignore[name-match]
|
||||||
|
|
||||||
_SUPPORTED_PYTHONS = ['3.13', '3.12', '3.11', '3.10', '3.9', '3.8', '3.7', '3.6']
|
_SUPPORTED_PYTHONS = ['3.12', '3.11', '3.10', '3.9', '3.8', '3.7', '3.6']
|
||||||
_SAFE_PATHS = ['/usr/bin', '/usr/local/bin']
|
_SAFE_PATHS = ['/usr/bin', '/usr/local/bin']
|
||||||
_CONDA_VAR = 'CONDA_PREFIX'
|
_CONDA_VAR = 'CONDA_PREFIX'
|
||||||
_CURRENT_VERSION = '%s.%s' % (sys.version_info.major, sys.version_info.minor)
|
_CURRENT_VERSION = '%s.%s' % (sys.version_info.major, sys.version_info.minor)
|
||||||
@@ -107,10 +102,7 @@ class Environment(_BaseEnvironment):
|
|||||||
version = '.'.join(str(i) for i in self.version_info)
|
version = '.'.join(str(i) for i in self.version_info)
|
||||||
return '<%s: %s in %s>' % (self.__class__.__name__, version, self.path)
|
return '<%s: %s in %s>' % (self.__class__.__name__, version, self.path)
|
||||||
|
|
||||||
def get_inference_state_subprocess(
|
def get_inference_state_subprocess(self, inference_state):
|
||||||
self,
|
|
||||||
inference_state: 'InferenceState',
|
|
||||||
) -> InferenceStateSubprocess:
|
|
||||||
return InferenceStateSubprocess(inference_state, self._get_subprocess())
|
return InferenceStateSubprocess(inference_state, self._get_subprocess())
|
||||||
|
|
||||||
@memoize_method
|
@memoize_method
|
||||||
@@ -142,10 +134,7 @@ class SameEnvironment(_SameEnvironmentMixin, Environment):
|
|||||||
|
|
||||||
|
|
||||||
class InterpreterEnvironment(_SameEnvironmentMixin, _BaseEnvironment):
|
class InterpreterEnvironment(_SameEnvironmentMixin, _BaseEnvironment):
|
||||||
def get_inference_state_subprocess(
|
def get_inference_state_subprocess(self, inference_state):
|
||||||
self,
|
|
||||||
inference_state: 'InferenceState',
|
|
||||||
) -> InferenceStateSameProcess:
|
|
||||||
return InferenceStateSameProcess(inference_state)
|
return InferenceStateSameProcess(inference_state)
|
||||||
|
|
||||||
def get_sys_path(self):
|
def get_sys_path(self):
|
||||||
@@ -384,13 +373,10 @@ def _get_executable_path(path, safe=True):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
pythons = [os.path.join(path, 'Scripts', 'python.exe'), os.path.join(path, 'python.exe')]
|
python = os.path.join(path, 'Scripts', 'python.exe')
|
||||||
else:
|
|
||||||
pythons = [os.path.join(path, 'bin', 'python')]
|
|
||||||
for python in pythons:
|
|
||||||
if os.path.exists(python):
|
|
||||||
break
|
|
||||||
else:
|
else:
|
||||||
|
python = os.path.join(path, 'bin', 'python')
|
||||||
|
if not os.path.exists(python):
|
||||||
raise InvalidPythonEnvironment("%s seems to be missing." % python)
|
raise InvalidPythonEnvironment("%s seems to be missing." % python)
|
||||||
|
|
||||||
_assert_safe(python, safe)
|
_assert_safe(python, safe)
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ class InferenceState:
|
|||||||
self.compiled_subprocess = environment.get_inference_state_subprocess(self)
|
self.compiled_subprocess = environment.get_inference_state_subprocess(self)
|
||||||
self.grammar = environment.get_grammar()
|
self.grammar = environment.get_grammar()
|
||||||
|
|
||||||
self.latest_grammar = parso.load_grammar(version='3.13')
|
self.latest_grammar = parso.load_grammar(version='3.12')
|
||||||
self.memoize_cache = {} # for memoize decorators
|
self.memoize_cache = {} # for memoize decorators
|
||||||
self.module_cache = imports.ModuleCache() # does the job of `sys.modules`.
|
self.module_cache = imports.ModuleCache() # does the job of `sys.modules`.
|
||||||
self.stub_module_cache = {} # Dict[Tuple[str, ...], Optional[ModuleValue]]
|
self.stub_module_cache = {} # Dict[Tuple[str, ...], Optional[ModuleValue]]
|
||||||
|
|||||||
@@ -5,23 +5,6 @@ goals:
|
|||||||
1. Making it safer - Segfaults and RuntimeErrors as well as stdout/stderr can
|
1. Making it safer - Segfaults and RuntimeErrors as well as stdout/stderr can
|
||||||
be ignored and dealt with.
|
be ignored and dealt with.
|
||||||
2. Make it possible to handle different Python versions as well as virtualenvs.
|
2. Make it possible to handle different Python versions as well as virtualenvs.
|
||||||
|
|
||||||
The architecture here is briefly:
|
|
||||||
- For each Jedi `Environment` there is a corresponding subprocess which
|
|
||||||
operates within the target environment. If the subprocess dies it is replaced
|
|
||||||
at this level.
|
|
||||||
- `CompiledSubprocess` manages exactly one subprocess and handles communication
|
|
||||||
from the parent side.
|
|
||||||
- `Listener` runs within the subprocess, processing each request and yielding
|
|
||||||
results.
|
|
||||||
- `InterpreterEnvironment` provides an API which matches that of `Environment`,
|
|
||||||
but runs functionality inline rather than within a subprocess. It is thus
|
|
||||||
used both directly in places where a subprocess is unnecessary and/or
|
|
||||||
undesirable and also within subprocesses themselves.
|
|
||||||
- `InferenceStateSubprocess` (or `InferenceStateSameProcess`) provide high
|
|
||||||
level access to functionality within the subprocess from within the parent.
|
|
||||||
Each `InterpreterState` has an instance of one of these, provided by its
|
|
||||||
environment.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import collections
|
import collections
|
||||||
@@ -33,7 +16,6 @@ import traceback
|
|||||||
import weakref
|
import weakref
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
from typing import Dict, TYPE_CHECKING
|
|
||||||
|
|
||||||
from jedi._compatibility import pickle_dump, pickle_load
|
from jedi._compatibility import pickle_dump, pickle_load
|
||||||
from jedi import debug
|
from jedi import debug
|
||||||
@@ -43,9 +25,6 @@ from jedi.inference.compiled.access import DirectObjectAccess, AccessPath, \
|
|||||||
SignatureParam
|
SignatureParam
|
||||||
from jedi.api.exceptions import InternalError
|
from jedi.api.exceptions import InternalError
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
|
||||||
from jedi.inference import InferenceState
|
|
||||||
|
|
||||||
|
|
||||||
_MAIN_PATH = os.path.join(os.path.dirname(__file__), '__main__.py')
|
_MAIN_PATH = os.path.join(os.path.dirname(__file__), '__main__.py')
|
||||||
PICKLE_PROTOCOL = 4
|
PICKLE_PROTOCOL = 4
|
||||||
@@ -104,9 +83,10 @@ def _cleanup_process(process, thread):
|
|||||||
|
|
||||||
|
|
||||||
class _InferenceStateProcess:
|
class _InferenceStateProcess:
|
||||||
def __init__(self, inference_state: 'InferenceState') -> None:
|
def __init__(self, inference_state):
|
||||||
self._inference_state_weakref = weakref.ref(inference_state)
|
self._inference_state_weakref = weakref.ref(inference_state)
|
||||||
self._handles: Dict[int, AccessHandle] = {}
|
self._inference_state_id = id(inference_state)
|
||||||
|
self._handles = {}
|
||||||
|
|
||||||
def get_or_create_access_handle(self, obj):
|
def get_or_create_access_handle(self, obj):
|
||||||
id_ = id(obj)
|
id_ = id(obj)
|
||||||
@@ -136,49 +116,11 @@ class InferenceStateSameProcess(_InferenceStateProcess):
|
|||||||
|
|
||||||
|
|
||||||
class InferenceStateSubprocess(_InferenceStateProcess):
|
class InferenceStateSubprocess(_InferenceStateProcess):
|
||||||
"""
|
def __init__(self, inference_state, compiled_subprocess):
|
||||||
API to functionality which will run in a subprocess.
|
|
||||||
|
|
||||||
This mediates the interaction between an `InferenceState` and the actual
|
|
||||||
execution of functionality running within a `CompiledSubprocess`. Available
|
|
||||||
functions are defined in `.functions`, though should be accessed via
|
|
||||||
attributes on this class of the same name.
|
|
||||||
|
|
||||||
This class is responsible for indicating that the `InferenceState` within
|
|
||||||
the subprocess can be removed once the corresponding instance in the parent
|
|
||||||
goes away.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(
|
|
||||||
self,
|
|
||||||
inference_state: 'InferenceState',
|
|
||||||
compiled_subprocess: 'CompiledSubprocess',
|
|
||||||
) -> None:
|
|
||||||
super().__init__(inference_state)
|
super().__init__(inference_state)
|
||||||
self._used = False
|
self._used = False
|
||||||
self._compiled_subprocess = compiled_subprocess
|
self._compiled_subprocess = compiled_subprocess
|
||||||
|
|
||||||
# Opaque id we'll pass to the subprocess to identify the context (an
|
|
||||||
# `InferenceState`) which should be used for the request. This allows us
|
|
||||||
# to make subsequent requests which operate on results from previous
|
|
||||||
# ones, while keeping a single subprocess which can work with several
|
|
||||||
# contexts in the parent process. Once it is no longer needed(i.e: when
|
|
||||||
# this class goes away), we also use this id to indicate that the
|
|
||||||
# subprocess can discard the context.
|
|
||||||
#
|
|
||||||
# Note: this id is deliberately coupled to this class (and not to
|
|
||||||
# `InferenceState`) as this class manages access handle mappings which
|
|
||||||
# must correspond to those in the subprocess. This approach also avoids
|
|
||||||
# race conditions from successive `InferenceState`s with the same object
|
|
||||||
# id (as observed while adding support for Python 3.13).
|
|
||||||
#
|
|
||||||
# This value does not need to be the `id()` of this instance, we merely
|
|
||||||
# need to ensure that it enables the (visible) lifetime of the context
|
|
||||||
# within the subprocess to match that of this class. We therefore also
|
|
||||||
# depend on the semantics of `CompiledSubprocess.delete_inference_state`
|
|
||||||
# for correctness.
|
|
||||||
self._inference_state_id = id(self)
|
|
||||||
|
|
||||||
def __getattr__(self, name):
|
def __getattr__(self, name):
|
||||||
func = _get_function(name)
|
func = _get_function(name)
|
||||||
|
|
||||||
@@ -186,7 +128,7 @@ class InferenceStateSubprocess(_InferenceStateProcess):
|
|||||||
self._used = True
|
self._used = True
|
||||||
|
|
||||||
result = self._compiled_subprocess.run(
|
result = self._compiled_subprocess.run(
|
||||||
self._inference_state_id,
|
self._inference_state_weakref(),
|
||||||
func,
|
func,
|
||||||
args=args,
|
args=args,
|
||||||
kwargs=kwargs,
|
kwargs=kwargs,
|
||||||
@@ -222,17 +164,6 @@ class InferenceStateSubprocess(_InferenceStateProcess):
|
|||||||
|
|
||||||
|
|
||||||
class CompiledSubprocess:
|
class CompiledSubprocess:
|
||||||
"""
|
|
||||||
A subprocess which runs inference within a target environment.
|
|
||||||
|
|
||||||
This class manages the interface to a single instance of such a process as
|
|
||||||
well as the lifecycle of the process itself. See `.__main__` and `Listener`
|
|
||||||
for the implementation of the subprocess and details of the protocol.
|
|
||||||
|
|
||||||
A single live instance of this is maintained by `jedi.api.environment.Environment`,
|
|
||||||
so that typically a single subprocess is used at a time.
|
|
||||||
"""
|
|
||||||
|
|
||||||
is_crashed = False
|
is_crashed = False
|
||||||
|
|
||||||
def __init__(self, executable, env_vars=None):
|
def __init__(self, executable, env_vars=None):
|
||||||
@@ -282,18 +213,18 @@ class CompiledSubprocess:
|
|||||||
t)
|
t)
|
||||||
return process
|
return process
|
||||||
|
|
||||||
def run(self, inference_state_id, function, args=(), kwargs={}):
|
def run(self, inference_state, function, args=(), kwargs={}):
|
||||||
# Delete old inference_states.
|
# Delete old inference_states.
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
delete_id = self._inference_state_deletion_queue.pop()
|
inference_state_id = self._inference_state_deletion_queue.pop()
|
||||||
except IndexError:
|
except IndexError:
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
self._send(delete_id, None)
|
self._send(inference_state_id, None)
|
||||||
|
|
||||||
assert callable(function)
|
assert callable(function)
|
||||||
return self._send(inference_state_id, function, args, kwargs)
|
return self._send(id(inference_state), function, args, kwargs)
|
||||||
|
|
||||||
def get_sys_path(self):
|
def get_sys_path(self):
|
||||||
return self._send(None, functions.get_sys_path, (), {})
|
return self._send(None, functions.get_sys_path, (), {})
|
||||||
@@ -341,65 +272,21 @@ class CompiledSubprocess:
|
|||||||
|
|
||||||
def delete_inference_state(self, inference_state_id):
|
def delete_inference_state(self, inference_state_id):
|
||||||
"""
|
"""
|
||||||
Indicate that an inference state (in the subprocess) is no longer
|
Currently we are not deleting inference_state instantly. They only get
|
||||||
needed.
|
deleted once the subprocess is used again. It would probably a better
|
||||||
|
solution to move all of this into a thread. However, the memory usage
|
||||||
The state corresponding to the given id will become inaccessible and the
|
of a single inference_state shouldn't be that high.
|
||||||
id may safely be re-used to refer to a different context.
|
|
||||||
|
|
||||||
Note: it is not guaranteed that the corresponding state will actually be
|
|
||||||
deleted immediately.
|
|
||||||
"""
|
"""
|
||||||
# Warning: if changing the semantics of context deletion see the comment
|
# With an argument - the inference_state gets deleted.
|
||||||
# in `InferenceStateSubprocess.__init__` regarding potential race
|
|
||||||
# conditions.
|
|
||||||
|
|
||||||
# Currently we are not deleting the related state instantly. They only
|
|
||||||
# get deleted once the subprocess is used again. It would probably a
|
|
||||||
# better solution to move all of this into a thread. However, the memory
|
|
||||||
# usage of a single inference_state shouldn't be that high.
|
|
||||||
self._inference_state_deletion_queue.append(inference_state_id)
|
self._inference_state_deletion_queue.append(inference_state_id)
|
||||||
|
|
||||||
|
|
||||||
class Listener:
|
class Listener:
|
||||||
"""
|
|
||||||
Main loop for the subprocess which actually does the inference.
|
|
||||||
|
|
||||||
This class runs within the target environment. It listens to instructions
|
|
||||||
from the parent process, runs inference and returns the results.
|
|
||||||
|
|
||||||
The subprocess has a long lifetime and is expected to process several
|
|
||||||
requests, including for different `InferenceState` instances in the parent.
|
|
||||||
See `CompiledSubprocess` for the parent half of the system.
|
|
||||||
|
|
||||||
Communication is via pickled data sent serially over stdin and stdout.
|
|
||||||
Stderr is read only if the child process crashes.
|
|
||||||
|
|
||||||
The request protocol is a 4-tuple of:
|
|
||||||
* inference_state_id | None: an opaque identifier of the parent's
|
|
||||||
`InferenceState`. An `InferenceState` operating over an
|
|
||||||
`InterpreterEnvironment` is created within this process for each of
|
|
||||||
these, ensuring that each parent context has a corresponding context
|
|
||||||
here. This allows context to be persisted between requests. Unless
|
|
||||||
`None`, the local `InferenceState` will be passed to the given function
|
|
||||||
as the first positional argument.
|
|
||||||
* function | None: the function to run. This is expected to be a member of
|
|
||||||
`.functions`. `None` indicates that the corresponding inference state is
|
|
||||||
no longer needed and should be dropped.
|
|
||||||
* args: positional arguments to the `function`. If any of these are
|
|
||||||
`AccessHandle` instances they will be adapted to the local
|
|
||||||
`InferenceState` before being passed.
|
|
||||||
* kwargs: keyword arguments to the `function`. If any of these are
|
|
||||||
`AccessHandle` instances they will be adapted to the local
|
|
||||||
`InferenceState` before being passed.
|
|
||||||
|
|
||||||
The result protocol is a 3-tuple of either:
|
|
||||||
* (False, None, function result): if the function returns without error, or
|
|
||||||
* (True, traceback, exception): if the function raises an exception
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._inference_states = {}
|
self._inference_states = {}
|
||||||
|
# TODO refactor so we don't need to process anymore just handle
|
||||||
|
# controlling.
|
||||||
|
self._process = _InferenceStateProcess(Listener)
|
||||||
|
|
||||||
def _get_inference_state(self, function, inference_state_id):
|
def _get_inference_state(self, function, inference_state_id):
|
||||||
from jedi.inference import InferenceState
|
from jedi.inference import InferenceState
|
||||||
@@ -421,9 +308,6 @@ class Listener:
|
|||||||
if inference_state_id is None:
|
if inference_state_id is None:
|
||||||
return function(*args, **kwargs)
|
return function(*args, **kwargs)
|
||||||
elif function is None:
|
elif function is None:
|
||||||
# Warning: if changing the semantics of context deletion see the comment
|
|
||||||
# in `InferenceStateSubprocess.__init__` regarding potential race
|
|
||||||
# conditions.
|
|
||||||
del self._inference_states[inference_state_id]
|
del self._inference_states[inference_state_id]
|
||||||
else:
|
else:
|
||||||
inference_state = self._get_inference_state(function, inference_state_id)
|
inference_state = self._get_inference_state(function, inference_state_id)
|
||||||
@@ -464,12 +348,7 @@ class Listener:
|
|||||||
|
|
||||||
|
|
||||||
class AccessHandle:
|
class AccessHandle:
|
||||||
def __init__(
|
def __init__(self, subprocess, access, id_):
|
||||||
self,
|
|
||||||
subprocess: _InferenceStateProcess,
|
|
||||||
access: DirectObjectAccess,
|
|
||||||
id_: int,
|
|
||||||
) -> None:
|
|
||||||
self.access = access
|
self.access = access
|
||||||
self._subprocess = subprocess
|
self._subprocess = subprocess
|
||||||
self.id = id_
|
self.id = id_
|
||||||
|
|||||||
@@ -493,9 +493,7 @@ def infer_factor(value_set, operator):
|
|||||||
elif operator == 'not':
|
elif operator == 'not':
|
||||||
b = value.py__bool__()
|
b = value.py__bool__()
|
||||||
if b is None: # Uncertainty.
|
if b is None: # Uncertainty.
|
||||||
yield list(value.inference_state.builtins_module.py__getattribute__('bool')
|
return
|
||||||
.execute_annotation()).pop()
|
|
||||||
else:
|
|
||||||
yield compiled.create_simple_object(value.inference_state, not b)
|
yield compiled.create_simple_object(value.inference_state, not b)
|
||||||
else:
|
else:
|
||||||
yield value
|
yield value
|
||||||
@@ -647,7 +645,7 @@ def _infer_comparison_part(inference_state, context, left, operator, right):
|
|||||||
_bool_to_value(inference_state, False)
|
_bool_to_value(inference_state, False)
|
||||||
])
|
])
|
||||||
elif str_operator in ('in', 'not in'):
|
elif str_operator in ('in', 'not in'):
|
||||||
return inference_state.builtins_module.py__getattribute__('bool').execute_annotation()
|
return NO_VALUES
|
||||||
|
|
||||||
def check(obj):
|
def check(obj):
|
||||||
"""Checks if a Jedi object is either a float or an int."""
|
"""Checks if a Jedi object is either a float or an int."""
|
||||||
@@ -697,15 +695,8 @@ def tree_name_to_values(inference_state, context, tree_name):
|
|||||||
|
|
||||||
if expr_stmt.type == "expr_stmt" and expr_stmt.children[1].type == "annassign":
|
if expr_stmt.type == "expr_stmt" and expr_stmt.children[1].type == "annassign":
|
||||||
correct_scope = parser_utils.get_parent_scope(name) == context.tree_node
|
correct_scope = parser_utils.get_parent_scope(name) == context.tree_node
|
||||||
ann_assign = expr_stmt.children[1]
|
|
||||||
if correct_scope:
|
if correct_scope:
|
||||||
found_annotation = True
|
found_annotation = True
|
||||||
if (
|
|
||||||
(ann_assign.children[1].type == 'name')
|
|
||||||
and (ann_assign.children[1].value == tree_name.value)
|
|
||||||
and context.parent_context
|
|
||||||
):
|
|
||||||
context = context.parent_context
|
|
||||||
value_set |= annotation.infer_annotation(
|
value_set |= annotation.infer_annotation(
|
||||||
context, expr_stmt.children[1].children[1]
|
context, expr_stmt.children[1].children[1]
|
||||||
).execute_annotation()
|
).execute_annotation()
|
||||||
|
|||||||
@@ -320,7 +320,7 @@ def expr_is_dotted(node):
|
|||||||
return node.type == 'name'
|
return node.type == 'name'
|
||||||
|
|
||||||
|
|
||||||
def _function_is_x_method(decorator_checker):
|
def _function_is_x_method(*method_names):
|
||||||
def wrapper(function_node):
|
def wrapper(function_node):
|
||||||
"""
|
"""
|
||||||
This is a heuristic. It will not hold ALL the times, but it will be
|
This is a heuristic. It will not hold ALL the times, but it will be
|
||||||
@@ -330,16 +330,12 @@ def _function_is_x_method(decorator_checker):
|
|||||||
"""
|
"""
|
||||||
for decorator in function_node.get_decorators():
|
for decorator in function_node.get_decorators():
|
||||||
dotted_name = decorator.children[1]
|
dotted_name = decorator.children[1]
|
||||||
if decorator_checker(dotted_name.get_code()):
|
if dotted_name.get_code() in method_names:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
|
|
||||||
function_is_staticmethod = _function_is_x_method(lambda m: m == "staticmethod")
|
function_is_staticmethod = _function_is_x_method('staticmethod')
|
||||||
function_is_classmethod = _function_is_x_method(lambda m: m == "classmethod")
|
function_is_classmethod = _function_is_x_method('classmethod')
|
||||||
function_is_property = _function_is_x_method(
|
function_is_property = _function_is_x_method('property', 'cached_property')
|
||||||
lambda m: m == "property"
|
|
||||||
or m == "cached_property"
|
|
||||||
or (m.endswith(".setter"))
|
|
||||||
)
|
|
||||||
|
|||||||
@@ -181,13 +181,7 @@ def _iter_pytest_modules(module_context, skip_own_module=False):
|
|||||||
if Path(file_io.path) != module_context.py__file__():
|
if Path(file_io.path) != module_context.py__file__():
|
||||||
try:
|
try:
|
||||||
m = load_module_from_path(module_context.inference_state, file_io)
|
m = load_module_from_path(module_context.inference_state, file_io)
|
||||||
conftest_module = m.as_context()
|
yield m.as_context()
|
||||||
yield conftest_module
|
|
||||||
|
|
||||||
plugins_list = m.tree_node.get_used_names().get("pytest_plugins")
|
|
||||||
if plugins_list:
|
|
||||||
name = conftest_module.create_name(plugins_list[0])
|
|
||||||
yield from _load_pytest_plugins(module_context, name)
|
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
pass
|
pass
|
||||||
folder = folder.get_parent_folder()
|
folder = folder.get_parent_folder()
|
||||||
@@ -202,19 +196,6 @@ def _iter_pytest_modules(module_context, skip_own_module=False):
|
|||||||
yield module_value.as_context()
|
yield module_value.as_context()
|
||||||
|
|
||||||
|
|
||||||
def _load_pytest_plugins(module_context, name):
|
|
||||||
from jedi.inference.helpers import get_str_or_none
|
|
||||||
|
|
||||||
for inferred in name.infer():
|
|
||||||
for seq_value in inferred.py__iter__():
|
|
||||||
for value in seq_value.infer():
|
|
||||||
fq_name = get_str_or_none(value)
|
|
||||||
if fq_name:
|
|
||||||
names = fq_name.split(".")
|
|
||||||
for module_value in module_context.inference_state.import_module(names):
|
|
||||||
yield module_value.as_context()
|
|
||||||
|
|
||||||
|
|
||||||
class FixtureFilter(ParserTreeFilter):
|
class FixtureFilter(ParserTreeFilter):
|
||||||
def _filter(self, names):
|
def _filter(self, names):
|
||||||
for name in super()._filter(names):
|
for name in super()._filter(names):
|
||||||
|
|||||||
@@ -21,13 +21,7 @@ per-file-ignores =
|
|||||||
jedi/__init__.py:F401
|
jedi/__init__.py:F401
|
||||||
jedi/inference/compiled/__init__.py:F401
|
jedi/inference/compiled/__init__.py:F401
|
||||||
jedi/inference/value/__init__.py:F401
|
jedi/inference/value/__init__.py:F401
|
||||||
exclude =
|
exclude = jedi/third_party/* .tox/*
|
||||||
.tox/*
|
|
||||||
jedi/third_party/*
|
|
||||||
test/completion/*
|
|
||||||
test/examples/*
|
|
||||||
test/refactor/*
|
|
||||||
test/static_analysis/*
|
|
||||||
|
|
||||||
[pycodestyle]
|
[pycodestyle]
|
||||||
max-line-length = 100
|
max-line-length = 100
|
||||||
|
|||||||
7
setup.py
7
setup.py
@@ -35,11 +35,11 @@ setup(name='jedi',
|
|||||||
long_description=readme,
|
long_description=readme,
|
||||||
packages=find_packages(exclude=['test', 'test.*']),
|
packages=find_packages(exclude=['test', 'test.*']),
|
||||||
python_requires='>=3.6',
|
python_requires='>=3.6',
|
||||||
# Python 3.13 grammars are added to parso in 0.8.4
|
# Python 3.11 & 3.12 grammars are added to parso in 0.8.3
|
||||||
install_requires=['parso>=0.8.4,<0.9.0'],
|
install_requires=['parso>=0.8.3,<0.9.0'],
|
||||||
extras_require={
|
extras_require={
|
||||||
'testing': [
|
'testing': [
|
||||||
'pytest<9.0.0',
|
'pytest<7.0.0',
|
||||||
# docopt for sith doctests
|
# docopt for sith doctests
|
||||||
'docopt',
|
'docopt',
|
||||||
# coloroma for colored debug output
|
# coloroma for colored debug output
|
||||||
@@ -101,7 +101,6 @@ setup(name='jedi',
|
|||||||
'Programming Language :: Python :: 3.10',
|
'Programming Language :: Python :: 3.10',
|
||||||
'Programming Language :: Python :: 3.11',
|
'Programming Language :: Python :: 3.11',
|
||||||
'Programming Language :: Python :: 3.12',
|
'Programming Language :: Python :: 3.12',
|
||||||
'Programming Language :: Python :: 3.13',
|
|
||||||
'Topic :: Software Development :: Libraries :: Python Modules',
|
'Topic :: Software Development :: Libraries :: Python Modules',
|
||||||
'Topic :: Text Editors :: Integrated Development Environments (IDE)',
|
'Topic :: Text Editors :: Integrated Development Environments (IDE)',
|
||||||
'Topic :: Utilities',
|
'Topic :: Utilities',
|
||||||
|
|||||||
@@ -424,13 +424,3 @@ with open("a"), open("b") as bfile:
|
|||||||
some_array = ['', '']
|
some_array = ['', '']
|
||||||
#! ['def upper']
|
#! ['def upper']
|
||||||
some_array[some_not_defined_index].upper
|
some_array[some_not_defined_index].upper
|
||||||
|
|
||||||
# -----------------
|
|
||||||
# operator
|
|
||||||
# -----------------
|
|
||||||
|
|
||||||
#? bool()
|
|
||||||
res = 'f' in 'foo'; res
|
|
||||||
|
|
||||||
#? bool()
|
|
||||||
res = not {}; res
|
|
||||||
|
|||||||
@@ -27,9 +27,3 @@ def capsysbinary(capsysbinary):
|
|||||||
#? ['close']
|
#? ['close']
|
||||||
capsysbinary.clos
|
capsysbinary.clos
|
||||||
return capsysbinary
|
return capsysbinary
|
||||||
|
|
||||||
|
|
||||||
# used when fixtures are defined in multiple files
|
|
||||||
pytest_plugins = [
|
|
||||||
"completion.fixture_module",
|
|
||||||
]
|
|
||||||
|
|||||||
@@ -21,9 +21,11 @@ class Y(X):
|
|||||||
#? []
|
#? []
|
||||||
def __doc__
|
def __doc__
|
||||||
|
|
||||||
#? []
|
# This might or might not be what we wanted, currently properties are also
|
||||||
def __class__
|
# used like this. IMO this is not wanted ~dave.
|
||||||
#? ['__class__']
|
#? ['__class__']
|
||||||
|
def __class__
|
||||||
|
#? []
|
||||||
__class__
|
__class__
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
# Exists only for completion/pytest.py
|
|
||||||
import pytest
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def my_module_fixture():
|
|
||||||
return 1.0
|
|
||||||
@@ -180,11 +180,6 @@ def argskwargs(*args: int, **kwargs: float):
|
|||||||
#? float()
|
#? float()
|
||||||
kwargs['']
|
kwargs['']
|
||||||
|
|
||||||
class Test:
|
|
||||||
str: str = 'abc'
|
|
||||||
|
|
||||||
#? ['upper']
|
|
||||||
Test.str.upp
|
|
||||||
|
|
||||||
class NotCalledClass:
|
class NotCalledClass:
|
||||||
def __init__(self, x):
|
def __init__(self, x):
|
||||||
|
|||||||
@@ -96,9 +96,6 @@ def test_x(my_con
|
|||||||
#? 18 ['my_conftest_fixture']
|
#? 18 ['my_conftest_fixture']
|
||||||
def test_x(my_conftest_fixture):
|
def test_x(my_conftest_fixture):
|
||||||
return
|
return
|
||||||
#? ['my_module_fixture']
|
|
||||||
def test_x(my_modu
|
|
||||||
return
|
|
||||||
|
|
||||||
#? []
|
#? []
|
||||||
def lala(my_con
|
def lala(my_con
|
||||||
|
|||||||
@@ -321,19 +321,10 @@ def test_docstrings_for_completions(Script):
|
|||||||
assert isinstance(c.docstring(), str)
|
assert isinstance(c.docstring(), str)
|
||||||
|
|
||||||
|
|
||||||
def test_completions_order_most_resemblance_on_top(Script):
|
|
||||||
"""Test that the completion which resembles the in-typing the most will come first."""
|
|
||||||
code = "from pathlib import Path\npath = Path('hello.txt')\n\npat"
|
|
||||||
script = Script(code)
|
|
||||||
# User is typing "pat" and "path" is closer to it than "Path".
|
|
||||||
assert ['path', 'Path'] == [comp.name for comp in script.complete()]
|
|
||||||
|
|
||||||
|
|
||||||
def test_fuzzy_completion(Script):
|
def test_fuzzy_completion(Script):
|
||||||
script = Script('string = "hello"\nstring.upper')
|
script = Script('string = "hello"\nstring.upper')
|
||||||
# 'isupper' is included because it is fuzzily matched.
|
assert ['isupper',
|
||||||
assert ['upper',
|
'upper'] == [comp.name for comp in script.complete(fuzzy=True)]
|
||||||
'isupper'] == [comp.name for comp in script.complete(fuzzy=True)]
|
|
||||||
|
|
||||||
|
|
||||||
def test_math_fuzzy_completion(Script, environment):
|
def test_math_fuzzy_completion(Script, environment):
|
||||||
|
|||||||
@@ -348,8 +348,8 @@ def test_parent_on_comprehension(Script):
|
|||||||
|
|
||||||
def test_type(Script):
|
def test_type(Script):
|
||||||
for c in Script('a = [str()]; a[0].').complete():
|
for c in Script('a = [str()]; a[0].').complete():
|
||||||
if c.name == '__class__':
|
if c.name == '__class__' and False: # TODO fix.
|
||||||
assert c.type == 'property'
|
assert c.type == 'class'
|
||||||
else:
|
else:
|
||||||
assert c.type in ('function', 'statement')
|
assert c.type in ('function', 'statement')
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ def get_completion(source, namespace):
|
|||||||
|
|
||||||
|
|
||||||
def test_builtin_details():
|
def test_builtin_details():
|
||||||
import keyword # noqa: F401
|
import keyword
|
||||||
|
|
||||||
class EmptyClass:
|
class EmptyClass:
|
||||||
pass
|
pass
|
||||||
@@ -53,9 +53,9 @@ def test_numpy_like_non_zero():
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
class NumpyNonZero:
|
class NumpyNonZero:
|
||||||
|
|
||||||
def __zero__(self):
|
def __zero__(self):
|
||||||
raise ValueError('Numpy arrays would raise and tell you to use .any() or all()')
|
raise ValueError('Numpy arrays would raise and tell you to use .any() or all()')
|
||||||
|
|
||||||
def __bool__(self):
|
def __bool__(self):
|
||||||
raise ValueError('Numpy arrays would raise and tell you to use .any() or all()')
|
raise ValueError('Numpy arrays would raise and tell you to use .any() or all()')
|
||||||
|
|
||||||
@@ -113,17 +113,17 @@ def _assert_interpreter_complete(source, namespace, completions, *, check_type=F
|
|||||||
|
|
||||||
|
|
||||||
def test_complete_raw_function():
|
def test_complete_raw_function():
|
||||||
from os.path import join # noqa: F401
|
from os.path import join
|
||||||
_assert_interpreter_complete('join("").up', locals(), ['upper'])
|
_assert_interpreter_complete('join("").up', locals(), ['upper'])
|
||||||
|
|
||||||
|
|
||||||
def test_complete_raw_function_different_name():
|
def test_complete_raw_function_different_name():
|
||||||
from os.path import join as pjoin # noqa: F401
|
from os.path import join as pjoin
|
||||||
_assert_interpreter_complete('pjoin("").up', locals(), ['upper'])
|
_assert_interpreter_complete('pjoin("").up', locals(), ['upper'])
|
||||||
|
|
||||||
|
|
||||||
def test_complete_raw_module():
|
def test_complete_raw_module():
|
||||||
import os # noqa: F401
|
import os
|
||||||
_assert_interpreter_complete('os.path.join("a").up', locals(), ['upper'])
|
_assert_interpreter_complete('os.path.join("a").up', locals(), ['upper'])
|
||||||
|
|
||||||
|
|
||||||
@@ -281,7 +281,7 @@ def test_param_completion():
|
|||||||
def foo(bar):
|
def foo(bar):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
lambd = lambda xyz: 3 # noqa: E731
|
lambd = lambda xyz: 3
|
||||||
|
|
||||||
_assert_interpreter_complete('foo(bar', locals(), ['bar='])
|
_assert_interpreter_complete('foo(bar', locals(), ['bar='])
|
||||||
_assert_interpreter_complete('lambd(xyz', locals(), ['xyz='])
|
_assert_interpreter_complete('lambd(xyz', locals(), ['xyz='])
|
||||||
@@ -295,7 +295,7 @@ def test_endless_yield():
|
|||||||
|
|
||||||
|
|
||||||
def test_completion_params():
|
def test_completion_params():
|
||||||
foo = lambda a, b=3: None # noqa: E731
|
foo = lambda a, b=3: None
|
||||||
|
|
||||||
script = jedi.Interpreter('foo', [locals()])
|
script = jedi.Interpreter('foo', [locals()])
|
||||||
c, = script.complete()
|
c, = script.complete()
|
||||||
@@ -310,9 +310,8 @@ def test_completion_param_annotations():
|
|||||||
# Need to define this function not directly in Python. Otherwise Jedi is too
|
# Need to define this function not directly in Python. Otherwise Jedi is too
|
||||||
# clever and uses the Python code instead of the signature object.
|
# clever and uses the Python code instead of the signature object.
|
||||||
code = 'def foo(a: 1, b: str, c: int = 1.0) -> bytes: pass'
|
code = 'def foo(a: 1, b: str, c: int = 1.0) -> bytes: pass'
|
||||||
exec_locals = {}
|
exec(code, locals())
|
||||||
exec(code, exec_locals)
|
script = jedi.Interpreter('foo', [locals()])
|
||||||
script = jedi.Interpreter('foo', [exec_locals])
|
|
||||||
c, = script.complete()
|
c, = script.complete()
|
||||||
sig, = c.get_signatures()
|
sig, = c.get_signatures()
|
||||||
a, b, c = sig.params
|
a, b, c = sig.params
|
||||||
@@ -324,7 +323,7 @@ def test_completion_param_annotations():
|
|||||||
assert b.description == 'param b: str'
|
assert b.description == 'param b: str'
|
||||||
assert c.description == 'param c: int=1.0'
|
assert c.description == 'param c: int=1.0'
|
||||||
|
|
||||||
d, = jedi.Interpreter('foo()', [exec_locals]).infer()
|
d, = jedi.Interpreter('foo()', [locals()]).infer()
|
||||||
assert d.name == 'bytes'
|
assert d.name == 'bytes'
|
||||||
|
|
||||||
|
|
||||||
@@ -410,7 +409,7 @@ def test_dir_magic_method(allow_unsafe_getattr):
|
|||||||
def test_name_not_findable():
|
def test_name_not_findable():
|
||||||
class X():
|
class X():
|
||||||
if 0:
|
if 0:
|
||||||
NOT_FINDABLE # noqa: F821
|
NOT_FINDABLE
|
||||||
|
|
||||||
def hidden(self):
|
def hidden(self):
|
||||||
return
|
return
|
||||||
@@ -423,7 +422,7 @@ def test_name_not_findable():
|
|||||||
|
|
||||||
|
|
||||||
def test_stubs_working():
|
def test_stubs_working():
|
||||||
from multiprocessing import cpu_count # noqa: F401
|
from multiprocessing import cpu_count
|
||||||
defs = jedi.Interpreter("cpu_count()", [locals()]).infer()
|
defs = jedi.Interpreter("cpu_count()", [locals()]).infer()
|
||||||
assert [d.name for d in defs] == ['int']
|
assert [d.name for d in defs] == ['int']
|
||||||
|
|
||||||
@@ -526,17 +525,14 @@ def test_partial_signatures(code, expected, index):
|
|||||||
c = functools.partial(func, 1, c=2)
|
c = functools.partial(func, 1, c=2)
|
||||||
|
|
||||||
sig, = jedi.Interpreter(code, [locals()]).get_signatures()
|
sig, = jedi.Interpreter(code, [locals()]).get_signatures()
|
||||||
|
assert sig.name == 'partial'
|
||||||
assert [p.name for p in sig.params] == expected
|
assert [p.name for p in sig.params] == expected
|
||||||
assert index == sig.index
|
assert index == sig.index
|
||||||
|
|
||||||
if sys.version_info < (3, 13):
|
|
||||||
# Python 3.13.0b3 makes functools.partial be a descriptor, which breaks
|
|
||||||
# Jedi's `py__name__` detection; see https://github.com/davidhalter/jedi/issues/2012
|
|
||||||
assert sig.name == 'partial'
|
|
||||||
|
|
||||||
|
|
||||||
def test_type_var():
|
def test_type_var():
|
||||||
"""This was an issue before, see Github #1369"""
|
"""This was an issue before, see Github #1369"""
|
||||||
|
import typing
|
||||||
x = typing.TypeVar('myvar')
|
x = typing.TypeVar('myvar')
|
||||||
def_, = jedi.Interpreter('x', [locals()]).infer()
|
def_, = jedi.Interpreter('x', [locals()]).infer()
|
||||||
assert def_.name == 'TypeVar'
|
assert def_.name == 'TypeVar'
|
||||||
@@ -614,7 +610,7 @@ def test_dict_getitem(code, types):
|
|||||||
('next(DunderCls())', 'float'),
|
('next(DunderCls())', 'float'),
|
||||||
('next(dunder)', 'float'),
|
('next(dunder)', 'float'),
|
||||||
('for x in DunderCls(): x', 'str'),
|
('for x in DunderCls(): x', 'str'),
|
||||||
# ('for x in dunder: x', 'str'),
|
#('for x in dunder: x', 'str'),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
def test_dunders(class_is_findable, code, expected, allow_unsafe_getattr):
|
def test_dunders(class_is_findable, code, expected, allow_unsafe_getattr):
|
||||||
@@ -691,7 +687,7 @@ def bar():
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
def test_string_annotation(annotations, result, code):
|
def test_string_annotation(annotations, result, code):
|
||||||
x = lambda foo: 1 # noqa: E731
|
x = lambda foo: 1
|
||||||
x.__annotations__ = annotations
|
x.__annotations__ = annotations
|
||||||
defs = jedi.Interpreter(code or 'x()', [locals()]).infer()
|
defs = jedi.Interpreter(code or 'x()', [locals()]).infer()
|
||||||
assert [d.name for d in defs] == result
|
assert [d.name for d in defs] == result
|
||||||
@@ -724,8 +720,8 @@ def test_negate():
|
|||||||
|
|
||||||
def test_complete_not_findable_class_source():
|
def test_complete_not_findable_class_source():
|
||||||
class TestClass():
|
class TestClass():
|
||||||
ta = 1
|
ta=1
|
||||||
ta1 = 2
|
ta1=2
|
||||||
|
|
||||||
# Simulate the environment where the class is defined in
|
# Simulate the environment where the class is defined in
|
||||||
# an interactive session and therefore inspect module
|
# an interactive session and therefore inspect module
|
||||||
@@ -760,7 +756,7 @@ def test_param_infer_default():
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_keyword_param_completion(code, expected):
|
def test_keyword_param_completion(code, expected):
|
||||||
import random # noqa: F401
|
import random
|
||||||
completions = jedi.Interpreter(code, [locals()]).complete()
|
completions = jedi.Interpreter(code, [locals()]).complete()
|
||||||
assert expected == [c.name for c in completions if c.name.endswith('=')]
|
assert expected == [c.name for c in completions if c.name.endswith('=')]
|
||||||
|
|
||||||
|
|||||||
@@ -144,17 +144,13 @@ def test_load_save_project(tmpdir):
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
def test_search(string, full_names, kwargs):
|
def test_search(string, full_names, kwargs):
|
||||||
some_search_test_var = 1.0 # noqa: F841
|
some_search_test_var = 1.0
|
||||||
project = Project(test_dir)
|
project = Project(test_dir)
|
||||||
if kwargs.pop('complete', False) is True:
|
if kwargs.pop('complete', False) is True:
|
||||||
defs = project.complete_search(string, **kwargs)
|
defs = project.complete_search(string, **kwargs)
|
||||||
else:
|
else:
|
||||||
defs = project.search(string, **kwargs)
|
defs = project.search(string, **kwargs)
|
||||||
actual = sorted([
|
assert sorted([('stub:' if d.is_stub() else '') + (d.full_name or d.name) for d in defs]) == full_names
|
||||||
('stub:' if d.is_stub() else '') + (d.full_name or d.name)
|
|
||||||
for d in defs
|
|
||||||
])
|
|
||||||
assert actual == full_names
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ def test_diff_without_ending_newline(Script):
|
|||||||
b
|
b
|
||||||
-a
|
-a
|
||||||
+c
|
+c
|
||||||
''') # noqa: W291
|
''')
|
||||||
|
|
||||||
|
|
||||||
def test_diff_path_outside_of_project(Script):
|
def test_diff_path_outside_of_project(Script):
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
import sys # noqa: F401
|
import sys
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import jedi
|
import jedi
|
||||||
from jedi import debug
|
from jedi import debug
|
||||||
|
|
||||||
|
|
||||||
def test_simple():
|
def test_simple():
|
||||||
jedi.set_debug_function()
|
jedi.set_debug_function()
|
||||||
debug.speed('foo')
|
debug.speed('foo')
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ from datetime import datetime
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
import jedi
|
|
||||||
from jedi.inference import compiled
|
from jedi.inference import compiled
|
||||||
from jedi.inference.compiled.access import DirectObjectAccess
|
from jedi.inference.compiled.access import DirectObjectAccess
|
||||||
from jedi.inference.gradual.conversion import _stub_to_python_value_set
|
from jedi.inference.gradual.conversion import _stub_to_python_value_set
|
||||||
@@ -82,9 +81,9 @@ def test_method_completion(Script, environment):
|
|||||||
assert [c.name for c in Script(code).complete()] == ['__func__']
|
assert [c.name for c in Script(code).complete()] == ['__func__']
|
||||||
|
|
||||||
|
|
||||||
def test_time_docstring():
|
def test_time_docstring(Script):
|
||||||
import time
|
import time
|
||||||
comp, = jedi.Script('import time\ntime.sleep').complete()
|
comp, = Script('import time\ntime.sleep').complete()
|
||||||
assert comp.docstring(raw=True) == time.sleep.__doc__
|
assert comp.docstring(raw=True) == time.sleep.__doc__
|
||||||
expected = 'sleep(secs: float) -> None\n\n' + time.sleep.__doc__
|
expected = 'sleep(secs: float) -> None\n\n' + time.sleep.__doc__
|
||||||
assert comp.docstring() == expected
|
assert comp.docstring() == expected
|
||||||
|
|||||||
@@ -206,7 +206,6 @@ def test_numpydoc_parameters_set_of_values():
|
|||||||
assert 'capitalize' in names
|
assert 'capitalize' in names
|
||||||
assert 'numerator' in names
|
assert 'numerator' in names
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skipif(numpydoc_unavailable,
|
@pytest.mark.skipif(numpydoc_unavailable,
|
||||||
reason='numpydoc module is unavailable')
|
reason='numpydoc module is unavailable')
|
||||||
def test_numpydoc_parameters_set_single_value():
|
def test_numpydoc_parameters_set_single_value():
|
||||||
@@ -391,8 +390,7 @@ def test_numpydoc_yields():
|
|||||||
@pytest.mark.skipif(numpydoc_unavailable or numpy_unavailable,
|
@pytest.mark.skipif(numpydoc_unavailable or numpy_unavailable,
|
||||||
reason='numpydoc or numpy module is unavailable')
|
reason='numpydoc or numpy module is unavailable')
|
||||||
def test_numpy_returns():
|
def test_numpy_returns():
|
||||||
s = dedent(
|
s = dedent('''
|
||||||
'''
|
|
||||||
import numpy
|
import numpy
|
||||||
x = numpy.asarray([])
|
x = numpy.asarray([])
|
||||||
x.d'''
|
x.d'''
|
||||||
@@ -404,8 +402,7 @@ def test_numpy_returns():
|
|||||||
@pytest.mark.skipif(numpydoc_unavailable or numpy_unavailable,
|
@pytest.mark.skipif(numpydoc_unavailable or numpy_unavailable,
|
||||||
reason='numpydoc or numpy module is unavailable')
|
reason='numpydoc or numpy module is unavailable')
|
||||||
def test_numpy_comp_returns():
|
def test_numpy_comp_returns():
|
||||||
s = dedent(
|
s = dedent('''
|
||||||
'''
|
|
||||||
import numpy
|
import numpy
|
||||||
x = numpy.array([])
|
x = numpy.array([])
|
||||||
x.d'''
|
x.d'''
|
||||||
|
|||||||
@@ -33,9 +33,7 @@ def test_get_signatures_stdlib(Script):
|
|||||||
|
|
||||||
# Check only on linux 64 bit platform and Python3.8.
|
# Check only on linux 64 bit platform and Python3.8.
|
||||||
@pytest.mark.parametrize('load_unsafe_extensions', [False, True])
|
@pytest.mark.parametrize('load_unsafe_extensions', [False, True])
|
||||||
@pytest.mark.skipif(
|
@pytest.mark.skipif('sys.platform != "linux" or sys.maxsize <= 2**32 or sys.version_info[:2] != (3, 8)')
|
||||||
'sys.platform != "linux" or sys.maxsize <= 2**32 or sys.version_info[:2] != (3, 8)',
|
|
||||||
)
|
|
||||||
def test_init_extension_module(Script, load_unsafe_extensions):
|
def test_init_extension_module(Script, load_unsafe_extensions):
|
||||||
"""
|
"""
|
||||||
``__init__`` extension modules are also packages and Jedi should understand
|
``__init__`` extension modules are also packages and Jedi should understand
|
||||||
|
|||||||
@@ -222,7 +222,7 @@ def test_goto_stubs_on_itself(Script, code, type_):
|
|||||||
|
|
||||||
def test_module_exists_only_as_stub(Script):
|
def test_module_exists_only_as_stub(Script):
|
||||||
try:
|
try:
|
||||||
import redis # noqa: F401
|
import redis
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
@@ -234,7 +234,7 @@ def test_module_exists_only_as_stub(Script):
|
|||||||
|
|
||||||
def test_django_exists_only_as_stub(Script):
|
def test_django_exists_only_as_stub(Script):
|
||||||
try:
|
try:
|
||||||
import django # noqa: F401
|
import django
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -307,28 +307,6 @@ def test_os_issues(Script):
|
|||||||
assert 'path' in import_names(s, column=len(s) - 3)
|
assert 'path' in import_names(s, column=len(s) - 3)
|
||||||
|
|
||||||
|
|
||||||
def test_duplicated_import(Script):
|
|
||||||
def import_names(*args, **kwargs):
|
|
||||||
return [d.name for d in Script(*args).complete(**kwargs)]
|
|
||||||
|
|
||||||
s = 'import os, o'
|
|
||||||
assert 'os' not in import_names(s)
|
|
||||||
assert 'os' in import_names(s, column=len(s) - 3)
|
|
||||||
|
|
||||||
s = 'from os import path, p'
|
|
||||||
assert 'path' not in import_names(s)
|
|
||||||
assert 'path' in import_names(s, column=len(s) - 3)
|
|
||||||
|
|
||||||
s = 'import path as pp, p'
|
|
||||||
assert 'path' not in import_names(s)
|
|
||||||
|
|
||||||
s = 'from os import path as pp, p'
|
|
||||||
assert 'path' not in import_names(s)
|
|
||||||
|
|
||||||
s = 'from os import chdir as path, p'
|
|
||||||
assert 'path' in import_names(s)
|
|
||||||
|
|
||||||
|
|
||||||
def test_path_issues(Script):
|
def test_path_issues(Script):
|
||||||
"""
|
"""
|
||||||
See pull request #684 for details.
|
See pull request #684 for details.
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import pytest
|
||||||
from jedi.inference.value import TreeInstance
|
from jedi.inference.value import TreeInstance
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
from textwrap import dedent
|
from textwrap import dedent
|
||||||
from operator import eq, ge, lt
|
from operator import ge, lt
|
||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
|
|
||||||
@@ -14,8 +14,7 @@ from ..helpers import get_example_dir
|
|||||||
('import math; math.cos', 'cos(x, /)', ['x'], ge, (3, 6)),
|
('import math; math.cos', 'cos(x, /)', ['x'], ge, (3, 6)),
|
||||||
|
|
||||||
('next', 'next(iterator, default=None, /)', ['iterator', 'default'], lt, (3, 12)),
|
('next', 'next(iterator, default=None, /)', ['iterator', 'default'], lt, (3, 12)),
|
||||||
('next', 'next()', [], eq, (3, 12)),
|
('next', 'next()', [], ge, (3, 12)),
|
||||||
('next', 'next(iterator, default=None, /)', ['iterator', 'default'], ge, (3, 13)),
|
|
||||||
|
|
||||||
('str', "str(object='', /) -> str", ['object'], ge, (3, 6)),
|
('str', "str(object='', /) -> str", ['object'], ge, (3, 6)),
|
||||||
|
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ def test_venv_and_pths(venv_path, environment):
|
|||||||
|
|
||||||
ETALON = [
|
ETALON = [
|
||||||
# For now disable egg-links. I have no idea how they work... ~ dave
|
# For now disable egg-links. I have no idea how they work... ~ dave
|
||||||
# pjoin('/path', 'from', 'egg-link'),
|
#pjoin('/path', 'from', 'egg-link'),
|
||||||
# pjoin(site_pkg_path, '.', 'relative', 'egg-link', 'path'),
|
#pjoin(site_pkg_path, '.', 'relative', 'egg-link', 'path'),
|
||||||
site_pkg_path,
|
site_pkg_path,
|
||||||
pjoin(site_pkg_path, 'dir-from-foo-pth'),
|
pjoin(site_pkg_path, 'dir-from-foo-pth'),
|
||||||
'/foo/smth.py:module',
|
'/foo/smth.py:module',
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
from textwrap import dedent
|
from textwrap import dedent
|
||||||
|
|
||||||
|
import pytest
|
||||||
from parso import parse
|
from parso import parse
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ class TestSetupReadline(unittest.TestCase):
|
|||||||
class NameSpace(object):
|
class NameSpace(object):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def setUp(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().setUp(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
self.namespace = self.NameSpace()
|
self.namespace = self.NameSpace()
|
||||||
utils.setup_readline(self.namespace)
|
utils.setup_readline(self.namespace)
|
||||||
@@ -73,21 +73,15 @@ class TestSetupReadline(unittest.TestCase):
|
|||||||
import os
|
import os
|
||||||
s = 'from os import '
|
s = 'from os import '
|
||||||
goal = {s + el for el in dir(os)}
|
goal = {s + el for el in dir(os)}
|
||||||
|
|
||||||
# There are minor differences, e.g. the dir doesn't include deleted
|
# There are minor differences, e.g. the dir doesn't include deleted
|
||||||
# items as well as items that are not only available on linux.
|
# items as well as items that are not only available on linux.
|
||||||
difference = set(self.complete(s)).symmetric_difference(goal)
|
difference = set(self.complete(s)).symmetric_difference(goal)
|
||||||
ACCEPTED_DIFFERENCE_PREFIXES = [
|
|
||||||
'_', 'O_', 'EX_', 'EFD_', 'MFD_', 'TFD_',
|
|
||||||
'SF_', 'ST_', 'CLD_', 'POSIX_SPAWN_', 'P_',
|
|
||||||
'RWF_', 'CLONE_', 'SCHED_', 'SPLICE_',
|
|
||||||
]
|
|
||||||
difference = {
|
difference = {
|
||||||
x for x in difference
|
x for x in difference
|
||||||
if not any(
|
if all(not x.startswith('from os import ' + s)
|
||||||
x.startswith('from os import ' + prefix)
|
for s in ['_', 'O_', 'EX_', 'MFD_', 'SF_', 'ST_',
|
||||||
for prefix in ACCEPTED_DIFFERENCE_PREFIXES
|
'CLD_', 'POSIX_SPAWN_', 'P_', 'RWF_',
|
||||||
)
|
'CLONE_', 'SCHED_'])
|
||||||
}
|
}
|
||||||
# There are quite a few differences, because both Windows and Linux
|
# There are quite a few differences, because both Windows and Linux
|
||||||
# (posix and nt) libraries are included.
|
# (posix and nt) libraries are included.
|
||||||
|
|||||||
Reference in New Issue
Block a user