121 Commits

Author SHA1 Message Date
Andrey Vokin
3f295d3e6c PY-73263 Python 3.13 Support - Code Insight - Typeshed
Support hashable and other implicit protocols

GitOrigin-RevId: 96abbd57142f4b105f54e728fac746402440e3bd
2024-09-09 13:54:00 +00:00
Andrey Vokin
1041f5e6a0 PY-73263 Python 3.13 Support - Code Insight - Typeshed
GitOrigin-RevId: 94973415b96b2a0f859d29b0201d1ccee0d06462
2024-09-09 13:54:00 +00:00
Andrey Vokin
9293cc2ad7 PY-73263 Python 3.13 Support - Code Insight - Typeshed
update dataclass typeshed

GitOrigin-RevId: bda7fda7ef235351f9ec6b21aa9021d6dcbd8b80
2024-09-09 13:54:00 +00:00
Andrey Vokin
80934bca38 PY-73263 Python 3.13 Support - Code Insight - Typeshed
update class enumerate

GitOrigin-RevId: 95fc30b01c3c99144fec4f36188dc28875b3dc42
2024-08-08 21:53:20 +00:00
Andrey Vokin
09ac564e51 PY-73263 Python 3.13 Support - Code Insight - Typeshed
PY-73099 Support PEP 705 – TypedDict: Read-only items

GitOrigin-RevId: f9596fdc5d0f6a9318abd4aa1366b0c94a5487fd
2024-08-07 10:13:26 +00:00
Petr
93b9066edf PY-34617 Support version check
GitOrigin-RevId: 3318ff79cdcc5ba0ce5e4feb65abad5ad0f4acfa
2024-07-28 00:24:15 +00:00
Andrey Vokin
673383c3da PY-61651 Deprecation highlighting with PEP 702 @deprecated decorator
GitOrigin-RevId: 426e7001d20849d7029fea55431d3e2cfae3eb11
2024-06-10 15:58:53 +00:00
Mikhail Golubev
d99a86efeb PY-35190 Fix resolving the register method of ABCMeta
The root cause was introduced in PY-23540 (see cb598c94c5).
Namely, abs.ABCMeta was explicitly filtered out from the list of metaclasses in
`PyClassImpl.getMostDerivedClassType` because for some reason in Typeshed stubs for
Python 2 `basestring`, and hence `str`, uses `ABCMeta` as its metaclass,
which is not true at runtime. It caused a metaclass conflict when inheriting `str`
with another user-defined metaclass (`ABCMeta` and a user metaclass didn't extend
each other), so we didn't detect any metaclass in a class as a result.

I've updated Typeshed stubs for Python 2 manually to process ABCMeta normally.
We don't update these stubs anyway, so these changes won't be lost on a future
Typeshed sync.

GitOrigin-RevId: 680e9fa890d00ea63987f3cf73e636e430685f34
2024-05-28 08:41:05 +00:00
Mikhail Golubev
93ac5fe566 PY-70528 Add support for typing_extensions.TypeVarTuple and Unpack
I've add-hoc updated typing_extensions.pyi in the bundled Typeshed to
recognize Unpack there.

GitOrigin-RevId: 953402e42984712a630c1772cf2f2cd4cbacdccf
2024-05-28 01:10:05 +00:00
Andrey.Matveev
c8942900df PY-63273 Restore SQLAlchemy and Flask-SQLAlchemy
GitOrigin-RevId: 0a3731899cc9d108839dd89128a2d3e583e8c56b
2023-11-10 17:48:23 +00:00
Andrey.Matveev
9aec9be967 PY-63273 Restore @python2
GitOrigin-RevId: f0bcf7431f279abab4332048fbdbadb0b221f44e
2023-11-10 17:48:23 +00:00
Andrey.Matveev
93919e49b3 PY-63273 Remove DataclassInstance related things
Issue: PY-63688

GitOrigin-RevId: 1c27f8d7d709bca75cb2b91abeacc5365d5ebab0
2023-11-10 17:48:23 +00:00
Andrey.Matveev
7d9e2720df PY-63273 Remove overloads of write and writelines
Issue: PY-63689

GitOrigin-RevId: 683e93628761b0f4ea7b6f9a048a25a6630eec48
2023-11-10 17:48:23 +00:00
Andrey.Matveev
5f61744b47 PY-63273 Revert __new__ to __init__
Issue: PY-62301

GitOrigin-RevId: 3f3738447b7cff0ff27953492189eb99527bd948
2023-11-10 17:48:23 +00:00
Andrey.Matveev
9a26cf0c14 PY-63273 Revert NewType function remove class
Issue: PY-34617

GitOrigin-RevId: 72fe29747517bfe58fd0b1c75376b52799dad4a9
2023-11-10 17:48:23 +00:00
Andrey.Matveev
4b088c972e PY-63273 Change order of if sys.version_info in collections
Issue: PY-34617

GitOrigin-RevId: 7e688d37a0fb518736d7df16d214121d2082259d
2023-11-10 17:48:23 +00:00
Andrey.Matveev
5a1bf3501e PY-63273 Update typeshed: run script
typeshed commit hash: 21fcd8960f1dae5ec4563dd99860d0918efe5cff

GitOrigin-RevId: 0fd8f2c47be13006dbfd556d1ae57f0bbb23d1bd
2023-11-10 17:48:22 +00:00
Andrey.Matveev
c24752ceb1 PY-58752 Impl inspection for check matching override signature
GitOrigin-RevId: 4520138ac657a514b53f2f939521f0336701be46
2023-10-22 10:27:24 +00:00
Mikhail Golubev
a14c9ef92c PY-53105 Support PEP 646 and TypeVarTuples. Take 2.
The introduction of TypeVarTuples and the concept of unpacked tuple types made us
revise all the places where we match sequences of types in type inference.
For instance, when matching type parameters and type arguments for generic
specialization in:

* type hints, i.e. xs: MyGeneric[int, str] = MyGeneric()
* constructor invocations, i.e. xs = MyGeneric[int, str]()
* class declarations, i.e. class MyGeneric(Base[T1, T2, str]): ...
* type alias declarations, i.e. MyAlias: TypeAlias = MyGeneric[T, int]

as well as during type matching of all generic types, both normal non-variadic and
existing "built-in" generic variadics in the type system, namely tuples and
Callables.

Previously, this logic was spread across numerous places in PyTypeChecker and
PyTypingTypeProvider, all with their own subtle differences. The first attempt
of PEP 646 support put all the code for uniform matching of type parameters directly
in PyTypeChecker, significantly complicating its already arcane internals.
I've introduced a unified API for that called PyTypeParameterMapping.
It still retains some of the former quirks in form of its Option flags, controlling
in particular how we handle having some of the expected types unmatched
(imagine expecting MyGeneric[T1, T2, *Ts] and receiving MyGeneric[int]),
but I'm planning to gradually eliminate this conditional logic.

The same class is now also responsible for matching parameter types of callables
that already allowed to fix some of the known problems, such as ignoring their
arity (PY-16994), but I'm going to extract a separate API entity for that, since
matching of callable signatures is a much more complicated task involving
compatibility of different types of parameters (positional-only, keyword-only,
defaults, varargs, etc.).

Another positive side effect of these changes is that substitution of type
parameters during type inference became more consistent, and we no longer lose
useful type information by replacing all unbound type parameters with Any. It's
particularly visible in type checker errors where we stopped dropping unbound type
parameters from messages about mismatched parameter-argument types.

Among other improvements in this changeset are proper scoping for
TypeVarTuples, consistent with other type parameters, and recognizing TypeVarTuples
and unpacked tuples in types of *args parameters in function bodies, e.g.
`*args: *Ts` translates to "args" parameter having the type `tuple[*Ts]`.

Confusing PyNoMatchedType used only for reporting of missing arguments for *args
parameters annotated with unpacked tuples in the type checker inspection, e.g.

def f(*args: *tuple[int, str]): ...
f(42)  # a type checker error about a missing argument for str

was also removed from the type system in favor of a simpler approach with handling
such errors directly in the inspection. We might need such a general type in
the future, but it has to be well thought-through.

GitOrigin-RevId: 63db6202254205863657f014632d141d340fe147
2023-10-20 13:38:06 +00:00
andrey.matveev
a75c569022 PY-53105 Support TypeVarTuple
GitOrigin-RevId: f8160e9d802b09991daa710ed9a20f3e30d455da
2023-10-20 13:38:04 +00:00
Pavel Karateev
904c6d68ea [python] PY-63580 Sync sys with the latest typeshed to include sys.monitoring
Introduced by 838dd3a5ba

GitOrigin-RevId: 1ba68c25956ede8c6a8afe3cd8560720d8ed7b95
2023-10-17 23:24:36 +00:00
lada.gagina
015a641eb9 Undo the rollback in builtins
Since PY-53896 got implemented, I'm making builtins up-to-date. They were reverted to workaround PY-52648 & PY-52656

GitOrigin-RevId: f7bacdc06c0bc0669ec8cb65ec64eec02834d2a1
2023-04-14 12:44:47 +00:00
lada.gagina
18590c0781 Sync with typeshed @ f611d18f70fd9f20797c832f10bba3bfb9d99e47
[PY-59793](https://youtrack.jetbrains.com/issue/PY-59793/Sync-bundled-typeshed-f611d18f70fd9f20797c832f10bba3bfb9d99e47-sep-22)

GitOrigin-RevId: 9dcaafbd9bf1bc6f077e130042883a7a0436961f
2023-04-14 12:44:45 +00:00
Mikhail Golubev
2135871356 PY-57541 PY-53896 Add missing AnyStr_co to partially updated Typeshed
Its absence made Py3TypeCheckerInspectionTest.testPathlibPathMatchingOsPathLike
fail as os.PathLike protocol wasn't considered generic. Once the changes
for generics are in the upstream, we will be able to update the Typeshed
fully at long last.

GitOrigin-RevId: 1333cc19bff15e328996c57362124a7fdb5ab057
2023-01-24 08:56:54 +00:00
lada.gagina
f5db62e099 Sync with typeshed @ df905102da05e99e7e7cd6cd0a1e3ddea2eddba2 (excluding the python2 removal)
[PY-57541](https://youtrack.jetbrains.com/issue/PY-57541/Sync-bundled-typeshed-df905102da05e99e7e7cd6cd0a1e3ddea2eddba2)

GitOrigin-RevId: 50eb01e74255002005343caa51bf8eb21c6028a6
2023-01-13 18:45:18 +00:00
lada.gagina
293bb95998 Sync with typeshed @ 460537c7f69ea36aa9ad12ca1bfb48ea56239462
Fixes PY-53839, PY-56090, PY-55053, PY-57120, PY-53965, PY-56368, PY-54532

GitOrigin-RevId: 1b80465a7c72f89f48b22d35b69e4da4ea1efd46
2022-11-21 14:46:32 +00:00
andrey.matveev
44cc11bb75 PY-44557 Update flask_sqlalchemy stubs in typeshed to inference Query type for Model.query
Type annotation Model for SQLAlchemy.Model will appear in 6a9c06edb95c9ecae7a76789e906fbbd420e5a25

GitOrigin-RevId: a4c601d534630253489fef55d08ce5afaa41d3c4
2022-09-20 11:03:27 +00:00
andrey.matveev
254902f1b5 PY-31296 Add annotation for __iter__ in stubs and comment special case in SQLAlchemyTypeProvider
The changes in typeshed will be in 0e4ea44080cff090ead62943de15487963ef0b2a and 234250384dad99367c181f2c8e2370ae2a2e3e83 revisions

GitOrigin-RevId: 9ee9953b0efa7f98cac2ee23756a30cf25e0fdb2
2022-08-03 13:14:49 +00:00
Mikhail Golubev
bb7e382697 PY-52648 PY-52656 Revert problematic Typeshed changes and add regression tests
This is a workaround until PY-53896 is implemented.

It effectively brings the stubs for builtins in Typeshed to their state at
37ee52ec2d883d8bbf244e4d1a871cde7f678d17, with the exception that I kept new
definitions for __build_class__ and ExceptionGroup (for 3.11).

GitOrigin-RevId: 92fdf169d228c52bcefa7edc3f185cb931ff4d79
2022-07-20 17:19:46 +00:00
Lada Gagina
b8c68586bc Sync with typeshed @ 4e87b9058f0908fa895076c0d9643e18be785be6 (PY-41510)
GitOrigin-RevId: 31a3e761d5a4e2508e2eceb33170e8283bedcb36
2022-03-15 14:03:04 +00:00
Semyon Proshev
38dd9d9e84 Sync with typeshed @ 7682ae957a32686becaf884de26cf79c9de5b221 (PY-41510)
GitOrigin-RevId: b199b44b7611b70ddc52848dfc4f71684f49e711
2022-02-14 16:49:39 +00:00
Semyon Proshev
d09cfa814b Sync with typeshed @ 48f13e451a3ef21002cca3f3b325ff3635f32d66 (PY-41510)
GitOrigin-RevId: b758ee90685ea9ad1e70cd8df2ea92afcb3f0f35
2021-12-24 13:26:30 +00:00
Semyon Proshev
2260f4b7d8 Enable more stubs from typeshed (PY-41509)
GitOrigin-RevId: 0ec9af526f5e90502b9411c806cd1d8170d71482
2021-10-18 16:33:51 +00:00
Semyon Proshev
59a6eeaae4 Sync with typeshed @ 53087be4eb935e5db24e9dddad3567ecaf1909a7 (PY-41510)
GitOrigin-RevId: 37ee52ec2d883d8bbf244e4d1a871cde7f678d17
2021-10-18 16:02:12 +00:00
Semyon Proshev
644ab20a24 Enable more stubs from typeshed (PY-41509)
GitOrigin-RevId: 70e4e01cef508a36c2cdf780c13f07d5d1ee3ddc
2021-08-19 17:20:27 +00:00
Semyon Proshev
7f77fb1c37 Sync with typeshed @ 837b57fdd1a814237ef4b15f6ce19c701303aebb (PY-41510)
Temporarily exclude https://github.com/python/typeshed/pull/4987
Temporarily exclude https://github.com/python/typeshed/pull/5206 from `collections/__init__.pyi`

GitOrigin-RevId: 6146af923d749b0cff56e823101b8f2b8525383d
2021-08-18 15:24:40 +00:00
Semyon Proshev
40e13e1069 Sync with typeshed @ 55a2a180c6f095d7a897ac5da3f7e0e7f8dd908b (PY-41510, PY-44548, PY-46355, PY-48948, PY-48958)
Temporarily exclude https://github.com/python/typeshed/pull/4987
Temporarily exclude https://github.com/python/typeshed/pull/5206 from `collections/__init__.pyi`

GitOrigin-RevId: 1bf4e6120ecd5927a113716878e503239ba33873
2021-05-27 10:14:40 +00:00
Semyon Proshev
fbadbbc40d Sync with typeshed @ 2c8cb605961bf76a88f9c21624893e4368ac3638
Temporarily exclude https://github.com/python/typeshed/pull/4987
Temporarily exclude https://github.com/python/typeshed/pull/5206 from `collections/__init__.pyi`

GitOrigin-RevId: 78775cc6c09fd8d867d8f46bf9908bd5cdbb05f6
2021-04-28 00:06:58 +00:00
Semyon Proshev
2465b8a67d Enable pyi stubs for several modules (PY-41509, PY-46229)
_ast, _dummy_thread, datetimerange, dummy_thread, dummy_threading, formatter, jwt, platform, string, thread

GitOrigin-RevId: a8010a0bd2381712599be0f96b35ce74e3e0c7d2
2021-03-03 22:46:06 +00:00
Semyon Proshev
39700adb5e Sync with typeshed @ 771e872cf605dbe6b489aa228c0a09a1a8ca69f2 (PY-41510)
Support new typeshed structure

GitOrigin-RevId: 4ada15febc11dc9acb8243c791aef722e16dd958
2021-03-03 22:46:04 +00:00
Semyon Proshev
1264585bb6 Sync with typeshed @ 869238e587ce2bb2e1b990026d5a038f6eb0f1a3 (PY-25553, PY-41510)
GitOrigin-RevId: b47a3913595abe4f3c5c59b5451be3a844aa34a7
2021-01-27 10:38:00 +00:00
Semyon Proshev
fbbb78bc4e Change receiver for initialization calls and don't resolve callee to constructors
Callee is now a receiver for these cases, previously it was `null`.
Callee is not replaced with constructors to have an ability to map it onto self/cls parameters and process `(cls: Type[T], ...) -> T` annotations.
Stay with the previous behaviour for navigation and looking for target element.

GitOrigin-RevId: c0f9894cf50fd5d7fd325f095976d096fb948e89
2020-11-11 19:30:34 +00:00
Semyon Proshev
55b934691b Sync with typeshed @ c3e04054cfe24866ff2c80955a8d8718ece20ed4
Builtins are split again, no need to split them on our side.

GitOrigin-RevId: 886e3d424f9f698271ee6c610358a3de9a28dca5
2020-11-11 18:09:08 +00:00
Anna Kozlova
ebf97ab3ba java records: forbid to extract superclass
GitOrigin-RevId: b7f4b4b503e96b32373fa0b371a8454884219cdd
2020-11-03 19:14:10 +00:00
Semyon Proshev
feed56de02 Sync with typeshed @ 10d3c6c325090172d5dc1cb99c5ce8a9319d88b2 (PY-41509, PY-41510, PY-44819)
Enable stubs for contextlib, cprofile, fractions, keyword, pipes, pkgutil, typed_ast, zoneinfo.
Skipped several `__init__` to `__new__` changes in builtin classes.

GitOrigin-RevId: dad913f67c69396d0db2d5e550254535713ea2f3
2020-10-19 21:15:33 +00:00
Semyon Proshev
dde82a759a Reduce ignored typeshed changes after the fix for PY-37876
GitOrigin-RevId: 99a9240b49fbf3896684fef6a66080e12338162b
2020-09-16 19:20:38 +00:00
Semyon Proshev
69ae32f06b Sync with typeshed @ d4191de79f5d65d5b8b6fecd68773f6d43a3c731 (PY-43297)
GitOrigin-RevId: 6510912ed00a94af5dc499bee2158ac17518baab
2020-09-16 14:58:32 +00:00
Semyon Proshev
9cdccc20ba Sync with typeshed @ 51cf2f51b8a0e33a8f20c2d020b2a86cfb9b8243
GitOrigin-RevId: 01706426dd8620b847f5f448500baa243744aa7f
2020-06-15 20:28:07 +03:00
Semyon Proshev
425b711c8a Enable pyi-stubs for several modules and packages
_bisect, _bootlocale, _compat_pickle, _msi, _py_abc, _sitebuiltins,
_tracemalloc, _winapi, _winreg, aifc, atomicwrites, base64, bz2,
chardet, compileall, ftplib, hmac, lzma, mmap, msilib, pkg_resources,
random, sunau, tracemalloc, tzlocal, urlparse, waitress, wave,
winreg, wsgiref, xmlrpc

GitOrigin-RevId: f0cdd560c24199b2f16dce094b0be2240950fb13
2020-06-02 22:37:57 +03:00
Semyon Proshev
f95d4aef98 Sync with typeshed @ 43cf0ec87058b247188fd1c7d906265eef07214c (PY-42534, PY-41791)
Possibly PY-32905 and PY-32788 are fixed.
No more need to provide callable type for `typing.TypeVar` because of https://github.com/python/typeshed/pull/4150

GitOrigin-RevId: f45928ad3b6ab18866b543bd2f375faa92d79b41
2020-06-02 19:59:09 +03:00