Removed properties-based stdlib types database

This commit is contained in:
Andrey Vlasovskikh
2013-10-29 19:53:14 +04:00
parent 9f92b82dbe
commit 8ca343f354
4 changed files with 1 additions and 1046 deletions
-921
View File
@@ -1,921 +0,0 @@
# Python stdlib
## 9.4. decimal
decimal.Decimal.as_tuple = \
:rtype: decimal.DecimalTuple \n\
decimal.Decimal.__new__ = \
:rtype: decimal.Decimal \n\
decimal.Decimal.__add__ = \
:type other: decimal.Decimal or int or long or float or complex \n\
:rtype: decimal.Decimal \n\
decimal.Decimal.__sub__ = \
:type other: decimal.Decimal or int or long or float or complex \n\
:rtype: decimal.Decimal \n\
decimal.Decimal.__mul__ = \
:type other: decimal.Decimal or int or long or float or complex \n\
:rtype: decimal.Decimal \n\
decimal.Decimal.__floordiv__ = \
:type other: decimal.Decimal or int or long or float or complex \n\
:rtype: decimal.Decimal \n\
decimal.Decimal.__mod__ = \
:type other: decimal.Decimal or int or long or float or complex \n\
:rtype: decimal.Decimal \n\
decimal.Decimal.__pow__ = \
:type other: decimal.Decimal or int or long or float or complex \n\
:rtype: decimal.Decimal \n\
decimal.Decimal.__div__ = \
:type other: decimal.Decimal or int or long or float or complex \n\
:rtype: decimal.Decimal \n\
decimal.Decimal.__truediv__ = \
:type other: decimal.Decimal or int or long or float or complex \n\
:rtype: decimal.Decimal \n\
decimal.Decimal.__radd__ = \
:type other: decimal.Decimal or int or long or float or complex \n\
:rtype: decimal.Decimal \n\
decimal.Decimal.__rsub__ = \
:type other: decimal.Decimal or int or long or float or complex \n\
:rtype: decimal.Decimal \n\
decimal.Decimal.__rmul__ = \
:type other: decimal.Decimal or int or long or float or complex \n\
:rtype: decimal.Decimal \n\
decimal.Decimal.__rfloordiv__ = \
:type other: decimal.Decimal or int or long or float or complex \n\
:rtype: decimal.Decimal \n\
decimal.Decimal.__rmod__ = \
:type other: decimal.Decimal or int or long or float or complex \n\
:rtype: decimal.Decimal \n\
decimal.Decimal.__rpow__ = \
:type other: decimal.Decimal or int or long or float or complex \n\
:rtype: decimal.Decimal \n\
decimal.Decimal.__rdiv__ = \
:type other: decimal.Decimal or int or long or float or complex \n\
:rtype: decimal.Decimal \n\
decimal.Decimal.__rtruediv__ = \
:type other: decimal.Decimal or int or long or float or complex \n\
:rtype: decimal.Decimal \n\
decimal.Decimal.__pos__ = \
:rtype: decimal.Decimal \n\
decimal.Decimal.__neg__ = \
:rtype: decimal.Decimal \n\
# 10.1. os.path
os.path.abspath = \
:type path: T <= bytes or unicode \n\
:rtype: T \n\
os.path.basename = \
:type p: T <= bytes or unicode \n\
:rtype: T \n\
os.path.commonprefix = \
:type m: collections.Iterable of T <= bytes or unicode \n\
:rtype: T \n\
os.path.dirname = \
:type p: T <= bytes or unicode \n\
:rtype: T \n\
os.path.exists = \
:type path: bytes or unicode \n\
:rtype: bool \n\
os.path.lexists = \
:type path: bytes or unicode \n\
:rtype: bool \n\
os.path.expanduser = \
:type path: T <= bytes or unicode \n\
:rtype: T \n\
os.path.expandvars = \
:type path: T <= bytes or unicode \n\
:rtype: T \n\
os.path.getatime = \
:type filename: bytes or unicode \n\
:rtype: int or float \n\
os.path.getmtime = \
:type filename: bytes or unicode \n\
:rtype: int or float \n\
os.path.getctime = \
:type filename: bytes or unicode \n\
:rtype: int or float \n\
os.path.getsize = \
:type filename: bytes or unicode \n\
:rtype: int or long \n\
os.path.isabs = \
:type s: bytes or unicode \n\
:rtype: bool \n\
os.path.isfile = \
:type path: bytes or unicode \n\
:rtype: bool \n\
os.path.isdir = \
:type s: bytes or unicode \n\
:rtype: bool \n\
os.path.islink = \
:type path: bytes or unicode \n\
:rtype: bool \n\
os.path.ismount = \
:type path: bytes or unicode \n\
:rtype: bool \n\
os.path.join = \
:type a: T <= bytes or unicode \n\
:rtype: T \n\
os.path.normcase = \
:type s: T <= bytes or unicode \n\
:rtype: T \n\
os.path.normpath = \
:type path: T <= bytes or unicode \n\
:rtype: T \n\
os.path.realpath = \
:type filename: T <= bytes or unicode \n\
:rtype: bytes or unicode \n\
os.path.relpath = \
:type path: T <= bytes or unicode \n\
:type start: bytes or unicode \n\
:rtype: T \n\
os.path.samefile = \
:type f1: bytes or unicode \n\
:type f2: bytes or unicode \n\
:rtype: bool \n\
os.path.sameopenfile = \
:type fp1: int \n\
:type fp2: int \n\
:rtype: bool \n\
os.path.samestat = \
:type s1: os.stat_result or tuple \n\
:type s2: os.stat_result or tuple \n\
:rtype: bool \n\
os.path.split = \
:type p: T <= bytes or unicode \n\
:rtype: (T, T) \n\
os.path.splitdrive = \
:type p: T <= bytes or unicode \n\
:rtype: (T, T) \n\
os.path.splitext = \
:type p: T <= bytes or unicode \n\
:rtype: (T, T) \n\
os.path.splitunc = \
:type p: T <= bytes or unicode \n\
:rtype: (T, T) \n\
os.path.walk = \
:type top: bytes or unicode \n\
:rtype: None \n\
## 10.10. shutil
shutil.copyfile = \
:type src: bytes or unicode \n\
:type dst: bytes or unicode \n\
:rtype None \n\
shutil.copymode = \
:type src: bytes or unicode \n\
:type dst: bytes or unicode \n\
:rtype None \n\
shutil.copystat = \
:type src: bytes or unicode \n\
:type dst: bytes or unicode \n\
:rtype None \n\
shutil.copy = \
:type src: bytes or unicode \n\
:type dst: bytes or unicode \n\
:rtype None \n\
shutil.copy2 = \
:type src: bytes or unicode \n\
:type dst: bytes or unicode \n\
:rtype None \n\
shutil.copytree = \
:type src: bytes or unicode \n\
:type dst: bytes or unicode \n\
:type symlinks: bool \n\
:type ignore: collections.Callable or None \n\
:rtype None \n\
shutil.rmtree = \
:type path: bytes or unicode \n\
:type ignore_errors: bool\n\
:type onerror: collections.Callable or None \n\
:rtype None \n\
shutil.move = \
:type src: bytes or unicode \n\
:type dst: bytes or unicode \n\
:rtype None \n\
shutil.make_archive = \
:type base_name: bytes or unicode \n\
:type format: bytes or unicode \n\
:type root_dir: bytes or unicode or None \n\
:type base_dir: bytes or unicode or None \n\
:type verbose: bool or int \n\
:type dry_run: bool or int \n\
:type owner: bytes or unicode or int or None \n\
:type group: bytes or unicode or int or None \n\
:rtype: bytes or unicode \n\
shutil.get_archive_formats = \
:rtype: list of (string, string) \n\
shutil.register_archive_format = \
:type name: bytes or unicode \n\
:type function: collections.Callable \n\
:type extra_args: None or collections.Sequence of (string, object) \n\
:type description: bytes or unicode \n\
:rtype: None
shutil.unregister_archive_format = \
:type name: bytes or unicode \n\
:rtype: None \n\
## 11.13 sqlite3
_sqlite3.connect = \
:type database: bytes or unicode \n\
:rtype: _sqlite3.Connection
_sqlite3.Connection.cursor = \
:rtype: _sqlite3.Cursor
## 15.1. os
os.ctermid = \
:rtype: unicode \n\
os.getegid = \
:rtype: int \n\
os.geteuid = \
:rtype: int \n\
os.getgid = \
:rtype: int \n\
os.getgroups = \
:rtype: list of int \n\
os.initgroups = \
:type username: string \n\
:type gid: int \n\
:rtype: None \n\
os.getlogin = \
:rtype: unicode \n\
os.getpgid = \
:type pid: int \n\
:rtype: int \n\
os.getpgrp = \
:rtype: int \n\
os.getpid = \
:rtype: int \n\
os.getresuid = \
:rtype: (int, int, int) \n\
os.getuid = \
:rtype: int \n\
os.getenv = \
:type key: string \n\
:type default: object \n\
:rtype: string \n\
os.putenv = \
:type key: bytes or unicode \n\
:type value: bytes or unicode \n\
:rtype: None \n\
os.setegid = \
:type gid: int \n\
:rtype: None \n\
os.seteuid = \
:type uid: int \n\
:rtype: None \n\
os.setgid = \
:type gid: int \n\
:rtype: None \n\
os.setgroups = \
:type p_list: list of int \n\
:rtype: None \n\
os.setpgrp = \
:rtype: None \n\
os.setpgid = \
:type pid: int \n\
:type pgrp: int \n\
:rtype: None \n\
os.setregid = \
:type rgid: int \n\
:type egid: int \n\
:rtype: None \n\
os.setresgid = \
:type rgid: int \n\
:type egid: int \n\
:type sgid: int \n\
:rtype: None \n\
os.setresuid = \
:type ruid: int \n\
:type euid: int \n\
:type suid: int \n\
:rtype: None \n\
os.setreuid = \
:type ruid: int \n\
:type euid: int \n\
:rtype: None \n\
os.getsid = \
:type pid: int \n\
:rtype: int \n\
os.setsid = \
:rtype: None \n\
os.setuid = \
:type uid: int \n\
:rtype: None \n\
os.strerror = \
:type code: int \n\
:rtype: unicode \n\
os.umask = \
:type new_mask: int \n\
:rtype: int \n\
os.uname = \
:rtype: (unicode, unicode, unicode, unicode, unicode) \n\
os.unsetenv = \
:type key: string \n\
:rtype: None \n\
os.fdopen = \
:type fd: int \n\
:type mode: string \n\
:type bufsize: int \n\
:rtype: file \n\
os.popen = \
:type command: string \n\
:type mode: string \n\
:type bufsize: int \n\
:rtype: io.FileIO \n\
os.tmpfile = \
:rtype: io.FileIO \n\
os.popen2 = \
:type cmd: string \n\
:type mode: string \n\
:type bufsize: int \n\
:rtype: (io.FileIO, io.FileIO) \n\
os.popen3 = \
:type cmd: string \n\
:type mode: string \n\
:type bufsize: int \n\
:rtype: (io.FileIO, io.FileIO, io.FileIO) \n\
os.popen4 = \
:type cmd: string \n\
:type mode: string \n\
:type bufsize: int \n\
:rtype: (io.FileIO, io.FileIO) \n\
os.close = \
:type fd: int \n\
:rtype: None \n\
os.closerange = \
:type fd_low: int \n\
:type fd_high: int \n\
:rtype: None \n\
os.dup = \
:type fd: int \n\
:rtype: int \n\
os.dup2 = \
:type old_fd: int \n\
:type new_fd: int \n\
:rtype: None \n\
os.fchmod = \
:type fd: int \n\
:type mode: int \n\
:rtype: None \n\
os.fchown = \
:type fd: int \n\
:type uid: int \n\
:type gid: int \n\
:rtype: None \n\
os.fdatasync = \
:type fildes: int \n\
:rtype: None \n\
os.fpathconf = \
:type fd: int \n\
:type name: int or string \n\
os.fstat = \
:type fd: int \n\
:rtype: os.stat_result \n\
os.fstatvfs = \
:type fd: int \n\
:rtype: os.statvfs_result \n\
os.fsync = \
:type filedes: int \n\
:rtype: None \n\
os.ftruncate = \
:type fd: int \n\
:type length: int or long \n\
:rtype: None \n\
os.isatty = \
:type fd: int \n\
:rtype: bool \n\
os.lseek = \
:type fd: int \n\
:type pos: int or long \n\
:type how: int \n\
:rtype: None \n\
os.open = \
:type filename: string \n\
:type mode: string \n\
:type bufsize: int \n\
:rtype: int \n\
os.openpty = \
:rtype: (int, int) \n\
os.pipe = \
:rtype: (int, int) \n\
os.read = \
:type fd: int \b\
:type buffersize: int or long \n\
:rtype: bytes \n\
os.tcgetpgrp = \
:type fd: int \n\
:rtype: int \n\
os.tcsetpgrp = \
:type fd: int \n\
:type pgid: int \n\
:rtype: None \n\
os.ttyname = \
:type fd: int \n\
:rtype: unicode \n\
os.write = \
:type fd: int \n\
:type string: bytes \n\
:rtype: int \n\
os.access = \
:type path: bytes or unicode \n\
:type mode: int \n\
:rtype: bool \n\
os.chdir = \
:type path: bytes or unicode \n\
:rtype: None \n\
os.fchdir = \
:type filedes: int \n\
:rtype: None \n\
os.getcwd = \
:rtype: str \n\
os.getcwdu = \
:rtype: unicode \n\
os.chroot = \
:type path: bytes or unicode \n\
:rtype: None \n\
os.chmod = \
:type path: bytes or unicode \n\
:type mode: int \n\
:rtype: None \n\
os.chown = \
:type path: bytes or unicode \n\
:type uid: int \n\
:type gid: int \n\
:rtype: None \n\
os.lchown = \
:type path: bytes or unicode \n\
:type uid: int \n\
:type gid: int \n\
:rtype: None \n\
os.link = \
:type src: bytes or unicode \n\
:type dst: bytes or unicode \n\
:rtype: None \n\
os.listdir = \
:type path: T <= bytes or unicode \n\
:rtype: list of T \n\
os.lstat = \
:type path: bytes or unicode \n\
:rtype: os.stat_result \n\
os.mkfifo = \
:type filename: bytes or unicode \n\
:type mode: int \n\
:rtype: None \n\
os.mknod = \
:type filename: bytes or unicode \n\
:type mode: int \n\
:type device: int \n\
:rtype: None \n\
os.major = \
:type device: int \n\
:rtype: int \n\
os.minor = \
:type device: int \n\
:rtype: int \n\
os.makedev = \
:type major: int \n\
:type minor: int \n\
:rtype: int \n\
os.mkdir = \
:type path: bytes or unicode \n\
:type mode: int \n\
:rtype: None \n\
os.makedirs = \
:type name: bytes or unicode \n\
:type mode: int \n\
:rtype: None \n\
os.pathconf = \
:type path: bytes or unicode \n\
:type name: int or string \n\
os.readlink = \
:type path: T <= bytes or unicode \n\
:rtype: T \n\
os.remove = \
:type path: bytes or unicode \n\
:rtype: None \n\
os.removedirs = \
:type name: bytes or unicode \n\
:rtype: None \n\
os.rename = \
:type old: bytes or unicode \n\
:type new: bytes or unicode \n\
:rtype: None \n\
os.renames = \
:type old: bytes or unicode \n\
:type new: bytes or unicode \n\
:rtype: None \n\
os.rmdir = \
:type path: bytes or unicode \n\
:rtype: None \n\
os.stat = \
:type path: bytes or unicode \n\
:rtype: os.stat_result \n\
os.stat_float_times = \
:type newval: bool or None \n\
:rtype: bool \n\
os.statvfs = \
:type path: bytes or unicode \n\
:rtype: os.statvfs_result \n\
os.symlink = \
:type src: bytes or unicode \n\
:type dst: bytes or unicode \n\
:rtype: None \n\
os.tempnam = \
:type dir: bytes or unicode \n\
:type prefix: bytes or unicode \n\
:rtype: string \n\
os.tmpnam = \
:rtype: string \n\
os.unlink = \
:type path: bytes or unicode \n\
:rtype: None \n\
os.utime = \
:type path: bytes or unicode \n\
:type atime: int or float \n\
:type mtime: int or float \n\
:rtype: None \n\
os.walk = \
:type top: T <= bytes or unicode \n\
:type topdown: bool \n\
:type followlinks: bool \n\
:rtype: collections.Iterable of (T, list of T, list of T) \n\
os.execl = \
:type file: bytes or unicode \n\
:rtype: None \n\
os.execle = \
:type file: bytes or unicode \n\
:rtype: None \n\
os.execlp = \
:type file: bytes or unicode \n\
:rtype: None \n\
os.execlpe = \
:type file: bytes or unicode \n\
:rtype: None \n\
os.execv = \
:type path: bytes or unicode \n\
:type args: collections.Iterable of string \n\
:rtype: None \n\
os.execve = \
:type path: bytes or unicode \n\
:type args: collections.Iterable of string \n\
:type env: collections.Mapping of (string, string) \n\
:rtype: None \n\
os.execvp = \
:type file: bytes or unicode \n\
:type args: collections.Iterable of string \n\
:rtype: None \n\
os.execvpe = \
:type file: bytes or unicode \n\
:type args: collections.Iterable of string \n\
:type env: collections.Mapping of (string, string) \n\
:rtype: None \n\
os._exit = \
:type status: int \n\
:rtype: None \n\
os.fork = \
:rtype: int \n\
os.forkpty = \
:rtype: (int, int) \n\
os.kill = \
:type pid: int \n\
:type sig: int \n\
:rtype: None \n\
os.killpg = \
:type pgid: int \n\
:type sig: int \n\
:rtype: None \n\
os.nice = \
:type inc: int \n\
:rtype: int \n\
os.spawnl = \
:type mode: int \n\
:type file: bytes or unicode \n\
:rtype: int \n\
os.spawnle = \
:type mode: int \n\
:type file: bytes or unicode \n\
:rtype: int \n\
os.spawnlp = \
:type mode: int \n\
:type file: bytes or unicode \n\
:rtype: int \n\
os.spawnlpe = \
:type mode: int \n\
:type file: bytes or unicode \n\
:rtype: int \n\
os.spawnv = \
:type mode: int \n\
:type file: bytes or unicode \n\
:type args: collections.Iterable of string \n\
:rtype: int \n\
os.spawnve = \
:type mode: int \n\
:type file: bytes or unicode \n\
:type args: collections.Iterable of string \n\
:type env: collections.Mapping of (string, string) \n\
:rtype: int \n\
os.spawnvp = \
:type mode: int \n\
:type file: bytes or unicode \n\
:type args: collections.Iterable of string \n\
:rtype: int \n\
os.spawnvpe = \
:type mode: int \n\
:type file: bytes or unicode \n\
:type args: collections.Iterable of string \n\
:type env: collections.Mapping of (string, string) \n\
:rtype: int \n\
os.system = \
:type command: bytes or unicode \n\
:rtype: int \n\
os.times = \
:rtype: (float, float, float, float, float) \n\
os.wait = \
:rtype: (int, int) \n\
os.waitpid = \
:type pid: int \n\
:type options: int \n\
:rtype: (int, int) \n\
os.wait3 = \
:type options: int \n\
:rtype: (int, int, resource.struct_rusage) \n\
os.wait4 = \
:type pid: int \n\
:type options: int \n\
:rtype: (int, int, resource.struct_rusage) \n\
os.WCOREDUMP = \
:type status: int \n\
:rtype: bool \n\
os.WIFCONTINUED = \
:type status: int \n\
:rtype: bool \n\
os.WIFSTOPPED = \
:type status: int \n\
:rtype: bool \n\
os.WIFSIGNALED = \
:type status: int \n\
:rtype: bool \n\
os.WIFEXITED = \
:type status: int \n\
:rtype: bool \n\
os.WEXITSTATUS = \
:type status: int \n\
:rtype: bool \n\
os.WSTOPSIG = \
:type status: int \n\
:rtype: bool \n\
os.WTERMSIG = \
:type status: int \n\
:rtype: bool \n\
os.urandom = \
:type n: int \n\
:rtype: bytes \n\
## 17.1. subprocess
subprocess.Popen.__init__ = \
:type args: string or collections.Sequence of string \n\
:type executable: string or None \n\
:type preexec_fn: collections.Callable or None \n\
:type close_fds: bool or int \n\
:type shell: bool or int \n\
:type cwd: string or None \n\
:type env: collections.Mapping of (string, string) \n\
:type universal_newlines: bool or int \n\
subprocess.Popen.poll = \
:rtype: int \n\
subprocess.Popen.wait = \
:rtype: int \n\
subprocess.Popen.communicate = \
:type intput: string or None \n\
:rtype: (bytes, bytes) \n\
subprocess.Popen.send_signal = \
:type sig: int \n\
## 18.2. json
json.loads = \
:type s: string \n\
:type encoding: string \n\
:rtype: object or unknown \n\
## 18.12. base64
base64.b64encode = \
:type s: bytes \n\
:rtype: bytes \n\
base64.b64decode = \
:type s: bytes \n\
:rtype: bytes \n\
## 27.1. sys
sys.exit = \
:type status: int or object \n\
:rtype: None \n\
@@ -17,16 +17,12 @@ package com.jetbrains.python.codeInsight.stdlib;
import com.google.common.collect.ImmutableSet;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiElement;
import com.intellij.psi.util.QualifiedName;
import com.jetbrains.python.PyNames;
import com.jetbrains.python.PythonHelpersLocator;
import com.jetbrains.python.documentation.DocStringUtil;
import com.jetbrains.python.psi.StructuredDocString;
import com.jetbrains.python.psi.*;
import com.jetbrains.python.psi.impl.PyBuiltinCache;
import com.intellij.psi.util.QualifiedName;
import com.jetbrains.python.psi.impl.PyTypeProvider;
import com.jetbrains.python.psi.resolve.PyResolveContext;
import com.jetbrains.python.psi.resolve.QualifiedNameFinder;
@@ -34,19 +30,13 @@ import com.jetbrains.python.psi.types.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
/**
* @author yole
*/
public class PyStdlibTypeProvider extends PyTypeProviderBase {
@NotNull private Properties myStdlibTypes = new Properties();
private static final Set<String> OPEN_FUNCTIONS = ImmutableSet.of("__builtin__.open", "io.open", "os.fdopen");
private static final String BINARY_FILE_TYPE = "io.FileIO[bytes]";
private static final String TEXT_FILE_TYPE = "io.TextIOWrapper[unicode]";
@@ -104,54 +94,6 @@ public class PyStdlibTypeProvider extends PyTypeProviderBase {
}
}
}
return getReturnTypeByQName(qname, function, context);
}
return null;
}
@Nullable
public PyType getConstructorType(@NotNull PyClass cls, @NotNull TypeEvalContext context) {
final String classQName = cls.getQualifiedName();
if (classQName != null) {
final QualifiedName
canonicalQName = PyStdlibCanonicalPathProvider.restoreStdlibCanonicalPath(QualifiedName.fromDottedString(classQName));
if (canonicalQName != null) {
final QualifiedName qname = canonicalQName.append(PyNames.INIT);
return getReturnTypeByQName(qname.toString(), cls, context);
}
}
return null;
}
@Nullable
private PyType getReturnTypeByQName(@NotNull String qname, @NotNull PsiElement anchor, @NotNull TypeEvalContext context) {
final LanguageLevel level = LanguageLevel.forElement(anchor);
final String key = String.format("Python%d/%s.return", level.getVersion(), qname);
final PyBuiltinCache cache = PyBuiltinCache.getInstance(anchor);
final Ref<PyType> cached = cache.getStdlibType(key, context);
if (cached != null) {
return cached.get();
}
final StructuredDocString docString = getStructuredDocString(qname);
if (docString == null) {
return null;
}
final String s = docString.getReturnType();
if (s == null) {
return null;
}
final PyType result = PyTypeParser.getTypeByName(anchor, s);
cache.storeStdlibType(key, result);
return result;
}
@Nullable
@Override
public PyType getParameterType(@NotNull PyNamedParameter param, @NotNull PyFunction func, @NotNull TypeEvalContext context) {
final String name = param.getName();
final String qname = getQualifiedName(func, param);
if (qname != null && name != null) {
return getParameterTypeByQName(qname, name, func, context);
}
return null;
}
@@ -215,38 +157,6 @@ public class PyStdlibTypeProvider extends PyTypeProviderBase {
}
}
@Nullable
private PyType getParameterTypeByQName(@NotNull String functionQName,
@NotNull String name,
@NotNull PsiElement anchor,
@NotNull TypeEvalContext context) {
final LanguageLevel level = LanguageLevel.forElement(anchor);
final String key = String.format("Python%d/%s.%s", level.getVersion(), functionQName, name);
final PyBuiltinCache cache = PyBuiltinCache.getInstance(anchor);
final Ref<PyType> cached = cache.getStdlibType(key, context);
if (cached != null) {
return cached.get();
}
final StructuredDocString docString = getStructuredDocString(functionQName);
if (docString == null) {
return null;
}
final String s = docString.getParamType(name);
if (s == null) {
return null;
}
final PyType result = PyTypeParser.getTypeByName(anchor, s);
cache.storeStdlibType(key, result);
return result;
}
@Nullable
private StructuredDocString getStructuredDocString(@NotNull String qualifiedName) {
final Properties db = getStdlibTypes();
final String docString = db.getProperty(qualifiedName);
return DocStringUtil.parse(docString);
}
@Nullable
private static String getQualifiedName(@NotNull PyFunction f, @Nullable PsiElement callSite) {
if (!f.isValid()) {
@@ -271,21 +181,4 @@ public class PyStdlibTypeProvider extends PyTypeProviderBase {
}
return result;
}
@NotNull
private Properties getStdlibTypes() {
if (myStdlibTypes.isEmpty()) {
try {
final InputStream s = new FileInputStream(PythonHelpersLocator.getHelperFile("StdlibTypes.properties"));
try {
myStdlibTypes.load(s);
}
finally {
s.close();
}
}
catch (IOException ignored) {}
}
return myStdlibTypes;
}
}
@@ -31,7 +31,6 @@ import com.jetbrains.python.PyElementTypes;
import com.jetbrains.python.PyNames;
import com.jetbrains.python.PyTokenTypes;
import com.jetbrains.python.PythonDialectsTokenSetProvider;
import com.jetbrains.python.codeInsight.stdlib.PyStdlibTypeProvider;
import com.jetbrains.python.psi.*;
import com.jetbrains.python.psi.resolve.PyResolveContext;
import com.jetbrains.python.psi.stubs.PyNamedParameterStub;
@@ -215,12 +214,6 @@ public class PyNamedParameterImpl extends PyPresentableElementImpl<PyNamedParame
}
}
}
else {
final PyStdlibTypeProvider stdlib = PyStdlibTypeProvider.getInstance();
if (stdlib != null) {
initType = stdlib.getConstructorType(containingClass, context);
}
}
if (initType != null && !(initType instanceof PyNoneType)) {
return initType;
}
@@ -357,16 +357,6 @@ public class PyTypeChecker {
match(initType, qualifierType, context, substitutions);
}
}
else {
// Unify generics in stdlib pseudo-constructor
final PyStdlibTypeProvider stdlib = PyStdlibTypeProvider.getInstance();
if (stdlib != null) {
final PyType initType = stdlib.getConstructorType(cls, context);
if (initType != null) {
match(initType, qualifierType, context, substitutions);
}
}
}
}
return substitutions;
}