Commit Graph

1466 Commits

Author SHA1 Message Date
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
8322bb476d PY-55086 Do not report raising a BaseException instance directly
See https://docs.python.org/3/reference/simple_stmts.html#the-raise-statement.
I decided not to update the inspection description, because BaseException is not
intended to be inherited by user classes.
The check for Exception was removed because Exception itself extends BaseException.

GitOrigin-RevId: 5782c9351aebb524c4d0fc0c9f3307d8db682efb
2024-05-28 01:10:12 +00:00
Mikhail Golubev
46d7223d9f PY-70528 Refactor handling of the *Ts and Unpack[Ts] syntax in type hints
to have better code re-use between PEP 692 and PEP 646 implementations.

GitOrigin-RevId: 39d714fcb14ba1014099fd57325c5185df34ce45
2024-05-28 01:10:09 +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
Petr
c8509ccc80 [python] Support TypeVarTuple from typing_extensions
GitOrigin-RevId: 02ed108a55d3feed54d95bfb5552f31cdf3e4880
2024-05-24 22:15:34 +00:00
lada.gagina
625373b47a [python] requirements.txt: check entries regardless of dash/underscore in the package name (PY-65403, PY-70173)
Since pip [normalizes](https://github.com/pypa/packaging-problems/issues/230) underscores to dashes, PyCharm should treat them equally for requirements.txt entries

GitOrigin-RevId: 62149b9c64c67936f1405c7bf282a288e8d52764
2024-05-20 15:56:16 +00:00
Nikita.Ashihmin
c35feaee3e PY-72719 Jupyter(fix): no quickfix to install package
GitOrigin-RevId: b29330a381f7c103688a5a5874a182e4a72caaf9
2024-05-17 22:28:00 +00:00
Petr
01d14fab4e PY-40480 Lift literal type completion results higher in a lookup
GitOrigin-RevId: 51fcf9b611250104fdeff04284e908cce1164560
2024-05-16 20:36:19 +00:00
Vladimir Krivosheev
c783d08867 IJPL-149476 fix IAE due to PyFilterLexer protected ctor
GitOrigin-RevId: b65f7f5fc399476f04e036df94190b30bdf4f783
2024-05-15 21:10:39 +00:00
Petr
abfb927619 [python] PyAssignmentStatementImpl.getTargetsToValuesMapping() Unpack nested tuples as specified in javadoc
GitOrigin-RevId: e0d4c13cadfa11d85ba3ddeba17e3c4cdda0a46d
2024-05-15 00:01:20 +00:00
Petr
b9d89b367a [python] PyAssignmentStatementImpl.getTargetsToValuesMapping() Handle nested parenthesis
GitOrigin-RevId: 6431171bee6624e0256d08fd5e1eddfb82132ccb
2024-05-15 00:01:20 +00:00
Petr
c015ff5cbf PY-55044 TypedDict **kwargs typing
GitOrigin-RevId: 5dff382b321ac166ed4b8cf90e431ea719995608
2024-05-14 23:49:38 +00:00
Petr
aefaeaa52a PY-54151 TypedDict completion at callee does not work for methods
GitOrigin-RevId: 5a037490d8c24ccdd354e8396540a21294148a7e
2024-05-14 22:52:52 +00:00
Petr
feb3bdc4c2 PY-52502 Duplicate completion variants when local variable is used as map key
GitOrigin-RevId: 463225922b2f0201b5d1ed2749f4175a77fd543f
2024-05-14 01:09:52 +00:00
Petr
7965dde4a4 PY-56004 Completion for expected literal types in assignments
GitOrigin-RevId: 06cacc62e068d902b174e5208837959cbd92ed88
2024-05-13 14:59:57 +00:00
Tagir Valeev
7085a927d5 [mod-commands] ModCommandExecutor.executeInteractively convenience method
GitOrigin-RevId: ae163c5afe3391aa73e8b0898546de7e74ce2419
2024-05-12 17:34:00 +00:00
Daniil Kalinin
788390047b PY-64326 fixes for intentions affected by reparseable PyStatementList implementation
GitOrigin-RevId: 9a5954767e062dd95d6eab02283c63b1c39fba49
2024-05-07 17:30:41 +00:00
Daniil Kalinin
ba6015d27f PY-64326 implement incremental parsing for PyStatementList PSI elements
These changes make PyStatementList elements (which are function and class bodies, cycle bodies, if-else branches, etc.) lazy-parseable which means they can now be reparsed without reparsing the whole file if changes are happened inside them accepted as safe

The main reason behind these changes is to improve performance

GitOrigin-RevId: 892acbe0c95fde6aec74b7595b0a58f902c426f5
2024-05-07 17:30:41 +00:00
Petr
2bbe723750 PY-42307 PyPackageAliasesProvider.commonImportAliases should be immutable
GitOrigin-RevId: 49d4ca22becf1fc341fbb60febd72bc2583cb8bb
2024-05-07 14:27:33 +00:00
Petr
41730be0d8 PY-42307 Unused field (PyPackageAliasesProvider)
GitOrigin-RevId: ca0873bf22d5d02f13b7bac55f985932be8ccc43
2024-05-07 14:27:33 +00:00
Vladimir Koshelev
8754f98cbe PY-72443 fix module => package mapping for some of the popular ml libs
GitOrigin-RevId: 962d57b87333c8c196dbd52bcfd4b5a41ba7317b
2024-05-06 15:20:45 +00:00
Ilya.Kazakevich
9f06f1a251 PY-71747: Do not fail if remote interpreter has a path with ssh:// prefix.
Some remote interpreters have `sdk#homePath` starting with `ssh://`.

Code all over the monorepo assumes that `homePath` is a local file path and tries to convert it to `Path` throwing the exception effectively.

There is a `isCustomPythonSdkHomePath` which must be used to check string before trying to convert it into `Path`

The current situation (along with "solution") is a legacy from dark ages and will be rewritten to the workspace model soon

GitOrigin-RevId: 9adc02f312667571a65ff63d4e802aa7d6dbb518
2024-05-02 14:20:44 +00:00
Andrey Vokin
60aa7ae2d3 PY-71972 "Go to declaration or Usages" doesn't work for instance fields from the constructor.
TextOffset is used to retrieve target element here: TargetElementUtilBase#getNamedElement.

GitOrigin-RevId: 5c9d721e6870079e4bf86ab7e5c8efb0be5810b0
2024-04-30 16:17:53 +00:00
Petr
11549ca709 PY-42664 fixed dictionary type inference
GitOrigin-RevId: 3fd967d00a6212769001166975167f022288f787
2024-04-26 20:12:18 +00:00
Petr
c58f577ee8 PY-42664 Code deduplication (PyCollectionTypeUtil)
GitOrigin-RevId: cde6db9b023b33fc5955ed16ae465e00bb6a5160
2024-04-26 20:12:18 +00:00
Petr
68c421f3d9 PY-42738 Incomplete handling of single and double quotes for dictionary keys in auto completion
GitOrigin-RevId: ed480e40c4de292d38efbe59656cf3c8eb234435
2024-04-25 23:00:28 +00:00
Mikhail Golubev
fcf665e761 PY-64304 EA-247016 Report illegal usages of "await" expressions even if there is no operand
In other words, in a statement like "await = 42" there are now both a warning about
the missing operand and a warning that an await expression cannot be used as
an assignment target. This behavior is consistent with other expressions where
additional parsing errors are not special-cased.

GitOrigin-RevId: 37a68eacc7ec042435c185f9ddd8bc2eea42b40f
2024-04-24 09:03:57 +00:00
Mikhail Golubev
b9d7fee816 PY-64304 EA-247016 Don't report illegal "await" expressions used as assignment targets during parsing
Instead, parse them as usual and later report in the dedicated AssignTargetAnnotator
and TypeAnnotationTargetAnnotator. This way, a PsiError element appearing in the PSI
tree of a type declaration statement doesn't cause PyAstTypeDeclarationStatement.getTarget
nullability contract violation.

GitOrigin-RevId: a3e90088cfac7938c398d4d293a72dbd127a2cd0
2024-04-24 09:03:53 +00:00
Mikhail Golubev
5f6848fccb PY-65966 Disable partial tensorflow stubs in Typeshed with a registry flag
Otherwise, incomplete stubs break our custom logic for resolving tensorflow
modules re-exported from its _api.v2 subpackage, such as tensorflow.audio,
tensorflow.image, tensorflow.random, etc.

We did the same for Numpy stubs in the past, enabling them back once they
became mature enough.

GitOrigin-RevId: b1e46067406a592761f56b7d296a287e5282b079
2024-04-23 11:03:04 +00:00
Mikhail Golubev
319738dea5 PY-59791 Simplify extracting a wrapped type from sqlalchemy.orm.Mapped
Use PyTypingTypeProvider.getAnnotationValue for that, similarly to already
re-used in other places PyTypingTypeProvider.getReturnTypeAnnotation.

Also, I've better separated handling of attributes explicitly annotated with Mapped
and just initialized with a mapped_column call. It will help to remove special
casing for Mapped once generic descriptors are fully supported in type inference
(PY-26184).

GitOrigin-RevId: eaeb66abd26b851507970b112360631704b41db3
2024-04-18 22:59:27 +00:00
Petr
e01b0b6beb PY-40480 Completion for argument passed to parameter hinted as Literal
GitOrigin-RevId: 462b03dc35eef70bc873b568cae239d40f1d4974
2024-04-18 20:55:14 +00:00
Mikhail Pyltsin
2152c276dc [python] Pattern variable can be used mass cleanup
GitOrigin-RevId: 04229dfd0912fbc846d4b1d5e3726ef6c9c005c6
2024-04-18 14:03:55 +00:00
Piotr Tomiak
3a14f22bc7 WEB-64707 Flaky test com.intellij.tests.BootstrapTests: org.angular2.codeInsight.Angular2HighlightingTest.testTrUnderTemplate
GitOrigin-RevId: a46fed4f6d7e64a89e44cca76bd09c6c117b0abe
2024-04-17 16:21:14 +00:00
Mikhail Golubev
ec49cd6c0c PY-29489 Rename and simplify PyTargetExpressionImpl.getTargetTypeFromTupleAssignment
GitOrigin-RevId: 7913cfdc8a4b9664b56b71ecbfde12c49d701e72
2024-04-17 11:41:27 +00:00
Mikhail Golubev
5bf2f99b65 PY-29489 Support unpacking non-generic iterable types, e.g. str or range
Use getIterationType for that, already implemented for inferring types
of for loop targets.

GitOrigin-RevId: daac45b4118629676eb37897cd08d5f8e193bf76
2024-04-17 11:41:23 +00:00
Mikhail Golubev
b70b23ca27 PY-29489 Support unpacking to targets in square brackets
GitOrigin-RevId: 470b0bd74bf3dc2ed5c8b6902df264624b50628d
2024-04-17 11:41:20 +00:00
Mikhail Golubev
8c0b817248 PY-29489 Infer types for generic iterable unpacking in assignments
GitOrigin-RevId: ac4454eae1eba2ec4c3eb71377253b1f97685561
2024-04-17 11:41:16 +00:00
Ilia Zakoulov
9377d67718 PY-64143: resolveQualifiedName might be called during indexing
Use withAlternativeResolveEnabled to prevent causing IndexNotReady exception.
Calling resolveQualifiedName as smartReadAction might be a bad idea
since it will postpone resolving for undefined period of time.

This method calls `foreignResults` which might access index as it does for Ultimate in `PyJavaImportResolver`

GitOrigin-RevId: 3bdbf103c3db4a9d55b5a72c3dfb3d5be9390cc4
2024-04-16 19:09:26 +00:00
Ilia Zakoulov
1e724ceee2 PY-64143: Make getFullAppName suspend
GitOrigin-RevId: 5b498851ce19c6657410c86134f31d8fb8f6d7c3
2024-04-16 19:09:26 +00:00
Alexander Koshevoy
1dba282b9b PY-71284 Prevent Python plugin in CLion from logging lots of assertion errors when dealing with Python interpreters
Being a paid IDE, CLion users get the community version of Python plugin. In such configuration, successfully passing the condition `PlatformUtils.isCommercialEdition()` the further call of `PythonHelpersLocator.getHelpersProRoot()` method resulted in the assertions logged and a non-existent path of the Python Pro helpers returned.

GitOrigin-RevId: bca751f5524ad137f721af76c475905c54638177
2024-04-04 16:00:40 +00:00
Petr
4e2f6f2685 PY-28076 Type of assignment target in parentheses is not inferred
GitOrigin-RevId: 457adb65fea311a169ae8fd4ca78a6915518b378
2024-04-02 19:04:20 +00:00
Mikhail Golubev
f24e4f0fff [python] Cleanup in ImportToImportFromIntention: replace two mutable fields by one final
GitOrigin-RevId: ea3f453568709059eb2b14d35940d95596b49733
2024-04-02 18:57:35 +00:00
Mikhail Golubev
126b58d099 [python] Cleanup in ImportToImportFromIntention: remove redundant casts
GitOrigin-RevId: 28ba26e6c199d57052bab81f32a9b20e1a990ff2
2024-04-02 18:57:35 +00:00
Mikhail Golubev
79d991a338 [python] Cleanup in ImportToImportFromIntention: remove a meaningless loop
GitOrigin-RevId: e28fdc30bbf378784bb3f2753490e83125e624f4
2024-04-02 18:57:35 +00:00
Mikhail Golubev
0a7cb22aa2 [python] Cleanup in ImportToImportFromIntention: use simpler API for replacing a PSI element
GitOrigin-RevId: 815e6d1d879d3d8ee85cccf43b73ea2797687d61
2024-04-02 18:57:35 +00:00
Mikhail Golubev
9cfd020b2a [python] Cleanup in ImportToImportFromIntention: remove pointless validity checks and sure() usages.
GitOrigin-RevId: 16b43f86c27c82abe2a170a3852d91cba5e0a619
2024-04-02 18:57:35 +00:00
Mikhail Golubev
c9613fd97b [python] Cleanup in ImportToImportFromIntention: use ModCommand API for locating a target element
GitOrigin-RevId: 8aa1e79216362b48074868eefa6b4bfa2496faed
2024-04-02 18:57:35 +00:00
Mikhail Golubev
bfdf267830 [python] Cleanup in ImportToImportFromIntention: add nullability annotations, use simpler API
GitOrigin-RevId: 2d2d044475270f5bce6a7cc1bfed9c50fa1e8fb3
2024-04-02 18:57:35 +00:00
Petr
cdfef53944 PY-52760 Type checker fails at tuple unpacking into a dictionary
GitOrigin-RevId: dbf1181099501764ac9b0d42813b37b48882379c
2024-04-02 15:05:56 +00:00
Mikhail Golubev
cef42660a3 PY-17627 PY-17733 Resolve class attributes defined in @classmethods
The logic is similar to that for instance attributes. Top-level class
attributes and methods defined in the class body get the precedence,
followed by class attributes defined with assignments in @classmethods
unless the latter would resolve to the same assignments as in

cls.attr = cls.attr + 1

finally, we scan through all other class methods resolving the name
to the first definition inside one of them.

So far, I intentionally didn't expose such attributes in findClassAttribute()
or getClassAttributes() because users of these methods assume that
this API considers only attributes defined immediately in the class body.
Adding extra definitions from class methods might break these usages.

I had to update the inspection about typing.Final, because it relied
on the fact that resolve() on assignment targets on class objects can
lead only to those top-level class attributes, where type hints are normally
located, but now it can lead to assignments to a qualified attribute inside
a containing class method.

GitOrigin-RevId: 0ca5bdaa4efca127ac187e822a49df6795e1028a
2024-03-28 12:17:37 +00:00