Commit Graph

312 Commits

Author SHA1 Message Date
Andrey Vokin
a906361c54 PY-81269 Extremely High RAM Usage
(cherry picked from commit bb534d62931c176d2395e2cceb0afabc57464669)

GitOrigin-RevId: a5abecbe752fee6f11880376ab587f10a02c3674
2025-06-22 19:42:43 +00:00
Aleksandr.Govenko
d8f57b77c6 PY-80524 Explicit return statement expected false positive for an if inside try / except
(cherry picked from commit 6877fc7b34622d7ae884233af96e06ea92c918c1)

IJ-MR-161824

GitOrigin-RevId: 8c3219ea8bb8f547f7c314af8cb0d432c042cd7c
2025-05-11 22:28:24 +00:00
Mikhail Golubev
1cc8316591 PY-80844 Add a new intention for converting between f-strings and t-strings
(cherry picked from commit be3ab4d72de05a92c986af31ac8e40309d9754b1)

GitOrigin-RevId: fba9757978f5f669aa63e2657a3fcbd2923bec74
2025-05-09 11:12:01 +00:00
Petr
e1b380f8b9 PY-12132 Support ABC classes (pep-3119)
Report error for abstract method in non-abstract class.

(cherry picked from commit 824d45a310b95ada628d6e607ae1ced6e351d849)

GitOrigin-RevId: 446cfea2ab76611d13648c17d6f7419fdefa0954
2025-04-23 23:27:31 +00:00
Petr
42dd3f39bf PY-12132 Support ABC classes (pep-3119)
A class containing at least one method declared with `abstractmethod` decorator that hasn’t been overridden yet cannot be instantiated.

Also report instantiation of classes that directly inherit ABC or have metaclass set to ABCMeta.

(cherry picked from commit 55cb4dc90c55ddc63991a4c3f6b50b4e34a3b4bd)

GitOrigin-RevId: b37ea24490dc5ce7dcce87adf21aa6fe31e0e9dc
2025-04-23 23:27:31 +00:00
evgeny.bovykin
5cdec66645 PY-78250 Call PyDataclassTypeProvider before PyTypingTypeProvider so that it has a chance to infer the dataclass type first
(cherry picked from commit 18230af949275e3f585ce806fec25144731e347b)

IJ-MR-158112

GitOrigin-RevId: 50ed312ca85b506cd1a8e8411b80548f81b56487
2025-04-23 12:07:33 +00:00
Mikhail Golubev
ea3859577e PY-53599 Return the registry value "enable.tensorflow.pyi.stubs"
(cherry picked from commit 576c04fe79fadb7d92df79e5648c62c914852051)

IJ-MR-157295

GitOrigin-RevId: fd2f549710e42e5c94d01e3a49d7e2b1a00e3402
2025-03-31 11:09:01 +00:00
evgeny.bovykin
8d4198bd81 PY-53599 Manually update tensorflow Typeshed. Enable enable.tensorflow.pyi.stubs by default
New Tensorflow Typeshed has updated stubs for the keras module, as well as for other Tensorflow modules. So PY-65966 should not be reproducible anymore


(cherry picked from commit 929e1da40c82bf6dd26efd227c0421087df3b75c)

IJ-MR-157295

GitOrigin-RevId: 4bf2396c3cd62aea0339db51fbec058f1d765a05
2025-03-31 11:09:01 +00:00
evgeny.bovykin
8a9854b80e PY-46623 Refactor PyKnownDecorator and related classes to be extendable
PyKnownDecorator is now a class instead of an enum, allowing extension to create new instances

(cherry picked from commit 846617f68e559f7f77af15a999f837391ac3090e)

GitOrigin-RevId: f3a8d9ac39955c888647e7186ad4315305a380bb
2025-03-19 18:57:08 +00:00
Aleksandr.Govenko
4360534147 PY-76876 PY-76856 PY-76836 Conformance test failure: qualifiers_final_decorator.py qualifiers_final_annotation.py dataclasses_final.py
Merge-request: IJ-MR-156322
Merged-by: Aleksandr Govenko <aleksandr.govenko@jetbrains.com>

(cherry picked from commit 1a049f52b4dfbdc86bd640a0cd547ead73a6af43)

IJ-MR-156322

GitOrigin-RevId: 0cff70d5f4c48b1af3807f38a8d1e18de8049acd
2025-03-07 02:03:04 +00:00
Alex Grönholm
c63994201b PY-32478: Suggest adding "async" to a function with the error "'await' outside async function"
Merge-request: IJ-MR-156125
Merged-by: Andrey Vokin <andrey.vokin@jetbrains.com>

(cherry picked from commit f3a2bc86331013879716b6991da26307c63b10fc)

IJ-MR-156125

GitOrigin-RevId: 10f0b3a8f60469af64bfd97613f258a282c9d0e2
2025-03-05 15:38:39 +00:00
Aleksandr.Govenko
e8f5b1c631 PY-52477 PY-78913 Add inspection for inconsistent returns
Merge-request: IJ-MR-154297
Merged-by: Aleksandr Govenko <aleksandr.govenko@jetbrains.com>

GitOrigin-RevId: e89225212cc981a5b256fca4ee23d77659b3ce5e
2025-02-14 17:21:51 +00:00
Petr
bb55a1b4f0 PY-79129 Report tuple index out of range
GitOrigin-RevId: 42c382dfaa5fc75244151d24324b479a62aee85f
2025-02-13 20:03:24 +00:00
Petr
f89bcdcabc PY-78878 Missing error: class type parameter parameterizes an outer scope
GitOrigin-RevId: b819ff172605a949156e5bd96d920044b70e1679
2025-02-09 00:26:30 +00:00
Petr
35c82af80e PY-78798 Report unbound type parameters
GitOrigin-RevId: a901450c4186561e534cfebaafaeaac7d1319e12
2025-02-09 00:26:30 +00:00
Petr
1d07b59290 PY-78767 Missing error "Generic metaclasses are not supported"
GitOrigin-RevId: 0eac15f3da77bcfff20254d35e9614a814d14373
2025-01-28 15:07:20 +00:00
Mikhail Golubev
3e7f5516bd PY-78662 PY-78663 Enable the "Unused local" inspection for type aliases and other scope owners
besides already supported classes, functions and lambdas.

GitOrigin-RevId: e70774af6b97e68ca82c47ac58b7b1421307b2d3
2025-01-24 22:48:25 +00:00
Mikhail Golubev
4d14b2bdc3 PY-78299 Force processing of reads in nested scopes in "Unused local" inspection
Use a cache of reads to avoid processing all code paths in a nested function
twice when visitPyFunction is called separately for outer and inner function
definitions.

GitOrigin-RevId: b5e2640756893d7b87c8e4b2443927d012f645ad
2025-01-24 22:48:25 +00:00
Mikhail Golubev
42bf350057 PY-78299 Fix flaky "Unused local" inspection with runForWholeFile="true"
The problem occurs when there are nested functions referring to variables
in the outer scope. The inspection implementation requires all nested scopes
to be visited to correctly detect unused local definitions, but the platform
may skip inner function when their enclosing function changes.

Unlike in PY-77891, the problem here is not the order of `visitPy*Element` calls
in the inspection visitor, but the fact that for some elements it's not invoked
at all.

Using runForWholeFile="true" forces full tree traversal and remedies the problem.

GitOrigin-RevId: 59ecba5ca204d51bba3e3b1b73c03f70bcbe231c
2025-01-24 22:48:25 +00:00
Alex Grönholm
02f5e3f522 PY-75291: Implemented auto-import for PEP 695 type aliases
GitOrigin-RevId: c15a6387785813688358e9695186a72dbdf35744
2025-01-23 15:46:39 +00:00
Petr
6e09d1fe40 PY-78401 "NewType cannot be used with protocol classes" warning is reported twice
GitOrigin-RevId: 31361b64758202ec85a96a78a4cb2149e76f1f25
2025-01-10 21:40:52 +00:00
Daniil Kalinin
1266b45fc2 Fix a typo
GitOrigin-RevId: f5174e94b55412df4b9a48033d1d7622dc3250c9
2025-01-08 14:05:27 +00:00
Daniil Kalinin
c3d4d41155 IJ-MR-150918 Refactor PyTypeHintsInspection
* Iterate over the type arguments to check their validity and infer the type at the same time, add a test for it
* Do not expose `PyTypingTypeProvider.getIndexTypes`

GitOrigin-RevId: f22e34aa65425c147b43052ec592c6351c0c6ff0
2025-01-08 14:05:26 +00:00
Daniil Kalinin
bc911c01b3 IJ-MR-150918 Simplify the report of not matched type arguments
Instead of reporting not enough / too many type arguments passed to a class, simply report the fact of type arguments mismatch.
It will help to avoid false positives and will extend the checks to both incorrect number and incorrect types of passed type arguments
Update the tests

GitOrigin-RevId: 6f0ae3fc1c46f74162da7cc3fccc370f4646ffdc
2025-01-08 14:05:26 +00:00
Daniil Kalinin
89351c84fa PY-75759 Move the check for scope of defaults for new-style generic syntax from PyTypeHintsInspection to PyNewStyleGenericSyntaxInspection
* Update the corresponding tests
* Change wording

GitOrigin-RevId: e5d666c1ae30d553346ed6bfa9363493e3b192ed
2025-01-08 14:05:26 +00:00
Daniil Kalinin
f21312cf3a PY-75759 Check that ParamSpecs and TypeVarTuples cannot be used in default types of TypeVar
GitOrigin-RevId: d94e8b8ff64e180b71ed280e6ebbc13b67a57b2b
2025-01-08 14:05:26 +00:00
Daniil Kalinin
8bba17afae PY-75759 Implement inspections for the number of type parameters passed to class during the parameterization
GitOrigin-RevId: 718e366366402944e0f43963e6dfb4e1a9b7fe37
2025-01-08 14:05:26 +00:00
Daniil Kalinin
a7d5a2deea PY-75759 Implement inspections for allowed type variable default values, scoping and type vars following TypeVarTuple
GitOrigin-RevId: 455cdff457a24523fde47947c1ee5d3bd830d07d
2025-01-08 14:05:26 +00:00
Gleb Marin
d80ad96aee [ml imports ranking] Update ML API version & add an actual ML model
Fix build issues

Fix build issues

Remove redundant extension point

Fix build issues

Fix rebase issues

import rank

# Conflicts:
#	.idea/libraries/jetbrains_ml_models_python_imports_ranking_model.xml
#	.idea/libraries/jetbrains_mlapi_ml_feature_api.xml
#	build/expected/ultimate-content-platform.yaml
#	community/.idea/libraries/jetbrains_mlapi_ml_building_blocks.xml
#	community/.idea/libraries/jetbrains_mlapi_ml_feature_api.xml
#	community/platform/ml-api/intellij.platform.ml.iml
#	community/platform/ml-impl/intellij.platform.ml.impl.iml
#	community/platform/ml-impl/src/com/intellij/platform/ml/impl/logs/fus/IntelliJFusEventRegister.kt
#	community/platform/ml-impl/src/com/intellij/platform/ml/impl/logs/fus/eventFields.kt
#	community/platform/ml-impl/src/com/intellij/platform/ml/impl/tools/logs/IntelliJFusEventRegister.kt
#	community/platform/ml-impl/src/com/intellij/platform/ml/impl/tools/logs/eventFields.kt
#	community/platform/ml-tools/src/com/intellij/platform/ml/tools/logs/fus/IntelliJFusEventRegister.kt
#	community/platform/ml-tools/src/com/intellij/platform/ml/tools/logs/fus/eventFields.kt
#	community/platform/platform-impl/codeinsight-inline/src/com/intellij/codeInsight/inline/completion/ml/TypingSpeedFeatureProvider.kt
#	community/python/intellij.python.ml.features/src/com/intellij/python/ml/features/imports/README.md
#	community/python/intellij.python.ml.features/src/com/intellij/python/ml/features/imports/mlModel.kt
#	community/python/pluginCore/plugin-content.yaml
#	community/python/src/com/jetbrains/python/codeInsight/imports/mlapi/mlAnalysis.kt
#	community/python/src/com/jetbrains/python/codeInsight/imports/mlapi/mlImplementation.kt
#	community/python/src/com/jetbrains/python/codeInsight/imports/mlapi/mlLogs.kt
#	community/python/src/com/jetbrains/python/codeInsight/imports/mlapi/mlTask.kt

Fix some tests

Refactor RelevanceEvaluationFeatures.kt to fix null handling

Improved the handling of `null` cases for `MODULE_SOURCE_TYPE` in `RelevanceEvaluationFeatures.kt`. This ensures more robust feature addition by checking conditions and setting the value accordingly when it's `null`. Minor formatting adjustments were also made.

Update ML model version in project configuration

Changed the Maven artifact ID from "lilac-coua" to "daffy-pony" for the python imports ranking ML model.

Fix some tests

Fix some tests

Fix some tests

Fix some tests

Fix some tests

Update Maven dependencies for JetBrains ML libraries

Update ML model version & fix missing read action

Update ML API version & update Imports Ranking implementation

Update mlapi version


Co-authored-by: Andrey Vokin <andrey.vokin@jetbrains.com>
Co-authored-by: Nikita Ermolenko <ermolenko.dev@gmail.com>

Merge-request: IJ-MR-147271
Merged-by: Gleb Marin <Gleb.Marin@jetbrains.com>

GitOrigin-RevId: 7aa520df915bb8a62263524868a17a984b619728
2025-01-08 12:52:17 +00:00
Petr
72dee29a9c PY-76812 Conformance test failure: typeddicts_alt_syntax.py
TypedDict() second argument has to be a dictionary literal

GitOrigin-RevId: 98dd2a2d8cf1d89bc9513e1562fc751d13812ca4
2024-12-19 18:50:44 +00:00
Petr
ce5eb63faa PY-77912 Sequence literals type inference
Drop type inference based on collection updates.

GitOrigin-RevId: c322c8232dc2be32ed4889333d7ba15d42d479fe
2024-12-16 16:54:09 +00:00
Mikhail Golubev
9792dc828b PY-76059 Special-case DataclassInstance protocol in the type checker
Alternatively, we can try to add a synthetic __dataclass_fields__
to all dataclasses with a PyClassMemberProvider.

GitOrigin-RevId: 98595a97138ba00ac95fff744b8f9cc1167c1ec4
2024-12-12 16:14:34 +00:00
Petr
98560f5f19 [codeServer] Move PyUnresolvedReferencesInspection.html to python.psi.impl
The description file is shared by
com.intellij.codeServer.python.unresolvedReference.PyUnresolvedReferencesInspection
and
com.jetbrains.python.inspections.unresolvedReference.PyUnresolvedReferencesInspection

GitOrigin-RevId: bfcefccac775c0955b2bfac62adfa8f187e350ec
2024-12-11 20:51:44 +00:00
Petr
5486d93839 PY-76841 Conformance test failure: dataclasses_postinit.py
__post_init__ parameters have to match InitVars type not name

GitOrigin-RevId: 0e1e4a9c3a50eee84cd724b5a3f8c5e894e90bdd
2024-12-11 20:51:44 +00:00
Andrey Vokin
44b9d24ae8 Revert "MLP-33 IJ Imports Ranking"
This reverts commit 47140fd0301283a10966e14c65df9a08d128ec39.

GitOrigin-RevId: 81fa4946bd76885bcc599dfae9bfb9feaa11fbb3
2024-12-09 21:19:47 +00:00
Andrey Vokin
d2b7ce6435 MLP-33 IJ Imports Ranking
Fix smoke tests

Update ML libraries

Remove kotlin std from classes of a library

Remove redundant extension point

import rank

PY-40997 Typing/Reformatting/Autocomplete lags when stubs for boto3 are installed

set test iteration count to 12


Co-authored-by: Gleb Marin <Gleb.Marin@jetbrains.com>

Merge-request: IJ-MR-150955
Merged-by: Gleb Marin <Gleb.Marin@jetbrains.com>

GitOrigin-RevId: 47140fd0301283a10966e14c65df9a08d128ec39
2024-12-07 16:07:16 +00:00
Petr
b93a58f196 PY-76842 Conformance test failure: aliases_newtype.py
NewType cannot be generic.

GitOrigin-RevId: 7e8fdc69f7200222f57f9de77c22b01e4e92d716
2024-12-06 18:16:42 +00:00
Petr
158dc1aeab PY-76842 Conformance test failure: aliases_newtype.py
NewType's type argument check.

GitOrigin-RevId: f4c2c6fc61b604458cb6182f1e4db7f8f53f2087
2024-12-06 18:16:42 +00:00
Petr
be10aee59a PY-76842 Conformance test failure: aliases_newtype.py
Variable name must be the same as NewType name.

GitOrigin-RevId: 704ce79bf7cc1d968acdceee40b9cda6936e848f
2024-12-06 18:16:42 +00:00
Petr
1125197401 PY-76842 Conformance test failure: aliases_newtype.py
NewType type cannot be subclassed.

GitOrigin-RevId: c1b27037aca9bb0fe2a34fc239d2cf8b693c0c99
2024-12-06 18:16:42 +00:00
Petr
3babbf844b PY-76842 Conformance test failure: aliases_newtype.py
isinstance and issubclass cannot be used with NewType type

GitOrigin-RevId: 4d5c2227b8a68684dd56c731d6f0d2139629708c
2024-12-06 18:16:41 +00:00
Aleksandr.Govenko
80ea4e852c PY-20710 Support 'Generator' typing class
Check YieldType of yield expressions in PyTypeCheckerInspection
Check that (Async)Generator is used in (async) function
Check that in 'yield from' sync Generator is used
Convert PyMakeFunctionReturnTypeQuickFix into PsiUpdateModCommandAction
Infer Generator type for lambdas
When getting function type from annotation, do not convert Generator to AsyncGenerator
Introduce GeneratorTypeDescriptor to simplify working with generator annotations


Merge-request: IJ-MR-146521
Merged-by: Aleksandr Govenko <aleksandr.govenko@jetbrains.com>

GitOrigin-RevId: b3b8182168c5224f0e03f54d443171ccf6ca7b89
2024-12-04 15:22:15 +00:00
Petr
433eb0d1cc PY-76891 Conformance test failure: directives_cast.py
GitOrigin-RevId: 9ada2b6756366bbc1091cb317a3e7d3a499fa53f
2024-12-03 16:10:46 +00:00
Petr
6a2fe3f2c6 PY-76897 PY-76869 Conformance test failure: narrowing_typeguard.py, narrowing_typeis.py
If a type narrowing function is implemented as an instance method or class method, the first positional argument maps to the second parameter.

GitOrigin-RevId: 55e4948a41022687d306711300bcd22bca60384e
2024-12-03 02:59:37 +00:00
Petr
2273799954 PY-76892 Conformance test failure: typeddicts_class_syntax.py
Check for unexpected __init_subclass__ parameter

GitOrigin-RevId: bb6dd8975c14bf6758f6deaf73b6aead02003233
2024-11-29 20:35:12 +00:00
Petr
4cc19d6cff PY-76907 Conformance test failure: typeddicts_usage.py
TypedDicts cannot be used with instance and class checks.
Typed dicts are not allowed as a bound for a TypeVar

GitOrigin-RevId: bfbc70c700ba2fb69e838a50db1439a7e904ec77
2024-11-29 20:35:11 +00:00
Petr
68ccfa30e4 PY-76853 Conformance test failure: typeddicts_required.py
Add a warning for repeated Required[]/NotRequired[] and ReadOnly[] TypedDict's field qualifiers.

GitOrigin-RevId: d380cfa9ab34acc257f99809867b6dbf05d37871
2024-11-29 20:35:11 +00:00
Aleksandr.Govenko
31dd92576e PY-20611 Missing warning about functions implicitly returning None when return type is not Optional
Updated PyFunction to account for implicit 'return None' statements when inferring return statement types.

It affected return type inference of PyFunction.

Fixed a failing test related to formatted strings.

Added a quick fix to make all return statements explicit.

Updated the CFG to include PyPassStatements, enabling detection of exit points in empty functions.

Simplified PyMakeFunctionReturnTypeQuickFix to independently infer function types and handle required imports. Currently, it does not support specifying custom suggested types.



Merge-request: IJ-MR-148719
Merged-by: Aleksandr Govenko <aleksandr.govenko@jetbrains.com>

GitOrigin-RevId: 9f58961f9eb70e4f9dbba7359f5aafdfd392b7e2
2024-11-26 17:02:37 +00:00
Irina Fediaeva
fe989c63f0 PY-52574: Rephrase docstring formatter error message
GitOrigin-RevId: 0160800e29a630657b068f71894fef984eb8e5c9
2024-11-14 15:43:32 +00:00
Petr
16d40e9c5d PY-76830 PY-76833 PY-76843 PY-76879 Enums support
GitOrigin-RevId: 9021c003cde70c39f8a5635b42761c08049490e2
2024-11-13 18:30:03 +00:00