Commit Graph

1821 Commits

Author SHA1 Message Date
Andrey Vokin
6521d75e87 PY-77891 "Unused import" inspection is inconsistent in nightly
The logic for disabling the unused warning on unresolved imports was dependent on the visit order. Moving sustracting unresolved imports to the end of computation fixes the problem.

GitOrigin-RevId: adeb85e59c17261a5bf9f64dfb4a7836a2403f43
2025-01-16 21:34:27 +00:00
Mikhail Golubev
291c34e589 [python] Simplify PyTypeHintsInspection.checkGenericTypeParameters
Previously, we relied on TypeEvalContext.getType() to interpret typing.Generic
parameters as type hints. Now we use PyTypingTypeProvider.getType() for that.

As a side effect, we no longer allow confusing aliasing of type parameters
similarly to other type checkers.

GitOrigin-RevId: 6994d417e16f179e0ebb51c43bf61e6be32f479c
2025-01-15 23:10:43 +00:00
Mikhail Golubev
e15c519747 [python] Make PyTypingTypeProvider.getType() handle top-level list literals as PyCallableParameterListType
Namely, the syntax `[type1, type2, ..., typeN]` used for Callable and
generic classes parameterized with ParamSpec.

GitOrigin-RevId: 928afadd862a5af587ef94776e3f166d028770d9
2025-01-15 23:10:43 +00:00
Gleb Marin
83e721a261 PY-77964, JBAI-10754 Unify ML API versions in ultimate
Also fixes 'Unable to load ML model' exception on Windows

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

GitOrigin-RevId: 2d5421dbee4ed86c81b9eba1f6d65dfdf4557698
2025-01-15 22:44:35 +00:00
Alex Grönholm
c9970c7c8c PY-57155: False positive for Annotated subexpression containing parentheses
GitOrigin-RevId: 8f088337474dd34fc1a99d869a4df508f4cc3056
2025-01-15 16:00:40 +00:00
Petr
04cac6392b PY-76906 Support type narrowing for comparisons with literal types
GitOrigin-RevId: 8094877f9b02b57f005391dd1b95befba621b604
2025-01-14 20:04:53 +00:00
Petr
4a13f8ad86 [python] Unused parameter (InstructionTypeCallback)
GitOrigin-RevId: 289fe7db3f8102db6d5072e5ee19cbc56c224bc1
2025-01-14 20:04:52 +00:00
Mikhail Golubev
039097a666 [python] Re-generate and add missing toString() to Python custom PSI stub implementations
GitOrigin-RevId: f6dbfcfd7a658a2675a324f91455a2ec071310ba
2025-01-14 10:55:47 +00:00
Mikhail Golubev
be17b9a8bd [python] Re-generate toString() for Python PSI stub implementations
GitOrigin-RevId: 59d730070ed3ed3bcb11251a2aadb5af615aaaef
2025-01-14 10:55:47 +00:00
Andrey Vokin
b175654a63 PY-74602 False positive warnings for parenthesised type annotations on TypedDicts
GitOrigin-RevId: 857551d19d25856924a406087e897e8ef5e083b8
2025-01-13 12:27:24 +00:00
Vladimir Krivosheev
bc115671b8 cleanup - reference static member via sub-class
GitOrigin-RevId: 4e081677a72ac1bc284532b61c225be6ceb6a5d7
2025-01-12 21:29:05 +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
Petr
2c70e635c4 PY-76906 Do not expand enum classes that derive from enum.Flag
GitOrigin-RevId: ea763c79c1aec73d0b41746d49218f91bfc191f6
2025-01-10 20:05:18 +00:00
Petr
4c8d8cd034 [python] Unused imports (PyStdlibTypeProvider)
GitOrigin-RevId: 0b16b8e134d0b914c4a6b45ad1156c9b5a2bc3ba
2025-01-10 20:05:18 +00:00
Petr
c1b66e6988 PY-76906 Exhaustiveness checks when dealing with enum values
GitOrigin-RevId: 3e434ee0a324934aae8d23931cc9a043b149a10b
2025-01-10 19:09:40 +00:00
Daniil Kalinin
29a7a64935 PY-78044 Do not substitute Self type with Any if no qualifier type is presented
Thus, we can later substitute it with the correct receiver type

GitOrigin-RevId: f4207b557e47de293d780556423c66b820023d98
2025-01-09 14:17:45 +00:00
Petr
9318043cdf [python] Use proper name for generic typed dict
GitOrigin-RevId: 23bdb23b427febedec09eee15f48b1b21b179314
2025-01-08 23:59:24 +00:00
Petr
ed734fe124 PY-78326 Nested typed dict initialization
GitOrigin-RevId: b5d6dd290e0f2acb5020b26a2df235295cc8e5e7
2025-01-08 20:59:21 +00:00
Petr
680c30d286 PY-78174 Typed dict type inference for nested sequence literals
GitOrigin-RevId: 746a7f0e334626b2d63aae2c3e70c1fdf295c55c
2025-01-08 20:59:20 +00:00
Petr
009b1d1180 PY-78174 Simplified code
GitOrigin-RevId: 83038b0f91ea43faef6cc39448896610afcf2ad3
2025-01-08 20:59:20 +00:00
Petr
bb4a9bfc30 PY-78174 Get rid of PyTypedDictType.createFromKeysToValueTypes() method
GitOrigin-RevId: 086a3f6ce7328d0ae195f2bd0d0b537f2854e46a
2025-01-08 20:59:20 +00:00
Petr
f38f4ff6bd PY-78174 Get rid of PyTypedDictType.getKeysToValuesWithTypes() method
GitOrigin-RevId: 690704d43d1d3814702e459657757980e01e7d1c
2025-01-08 20:59:20 +00:00
Petr
dea16a32ad PY-78174 Remove PyTypedDictType.inferred field
GitOrigin-RevId: b08113ce4d713fe507df72bc0e09c9e6cd87b5c0
2025-01-08 20:59:20 +00:00
Petr
dcc38d3c9c PY-78174 Do not infer typed dict type for a dict literal
GitOrigin-RevId: 913de6e62a8e477bb3eb76d31c28569ab61ed5b0
2025-01-08 20:59:20 +00:00
Daniil Kalinin
2c85a4232a IJ-MR-150918 Simplify mapping of ParamSpecs in PyTypeParameterMapping when ParamSpec is the only type parameter
GitOrigin-RevId: 794fef2c884d7ecd183f42dde9796e921269f8ac
2025-01-08 14:05:27 +00:00
Daniil Kalinin
e48833d512 IJ-MR-150918 Changes in PyNewStyleGenericSyntaxInspection
GitOrigin-RevId: e3b3eaaee1263a85347c840d7b48c2211a04ae00
2025-01-08 14:05:27 +00:00
Daniil Kalinin
1266b45fc2 Fix a typo
GitOrigin-RevId: f5174e94b55412df4b9a48033d1d7622dc3250c9
2025-01-08 14:05:27 +00:00
Daniil Kalinin
919e6d5e51 PY-77601 Fix wrong mapping to ParamSpec, fix test in PyTypeParameterMappingTest, add a couple more
GitOrigin-RevId: d4d65f900c43159c9c026254833c37d7eeb5e8ba
2025-01-08 14:05:27 +00:00
Daniil Kalinin
076049fbe4 IJ-MR-151374 Remove unused method
GitOrigin-RevId: cf67dd52378b0474eec6934f97d2318b0f4db120
2025-01-08 14:05:27 +00:00
Daniil Kalinin
a58a325c18 IJ-MR-151374 Remove repeated search for generic definition
GitOrigin-RevId: b53f354e46858b2204de1147dc27f4024cc8ece2
2025-01-08 14:05:27 +00:00
Daniil Kalinin
d4aae65514 PY-77601 Do not promote the list of type arguments to PyCallableParameterListType in getIndexTypes()
Handle it directly in PyTypeParameterMapping instead
Remove useless test

GitOrigin-RevId: dfd0d8cdf2b2b663f677ea1467578e1ce8e21b52
2025-01-08 14:05:26 +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
134ff15ec3 PY-77601 Correctly map type arguments when ParamSpec is the only generic parameter
In such cases, no additional wrapping in square brackets is needed
```
class Clazz(Generic[P]): ...
# Both are valid and equal
c1 = Clazz[int, str, bool]()
c2 = Clazz[[int, str, bool]]()
```

GitOrigin-RevId: 1134f4e9f47f5d29f447ee73febb44c4a07a7ae1
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
25c1d1a5d8 IJ-MR-150918 Change the check for allowed defaults of TypeVar to a simple check for the type of assigned type parameter
Do not analyze the references inside the default expression, wrong ones will be reported later

GitOrigin-RevId: 99065e43fd75bd9d6592e017a1c141feefbc9dd4
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
2780f5147e PY-75759 Report defaults that refer to another type parameters out of scope for new-style generic syntax
Small refactoring in `PyNewStyleGenericSyntaxInspection`, updated test in `PyNewStyleGenericSyntaxInspectionTest`

GitOrigin-RevId: 7cd842f5b3cac4f6a57c334c54eb1685255a7253
2025-01-08 14:05:26 +00:00
Daniil Kalinin
c0e2658f0c IJ-MR-150918 Get rid of the unnecessary MAP_WITH_DEFAULTS_STRICT flag in PyTypeHintsInspection
GitOrigin-RevId: 396b61fcbe3033787c8bf805901135e915324870
2025-01-08 14:05:26 +00:00
Daniil Kalinin
97d93cc944 IJ-MR-150918 Rename methods in PyTypeHintsInspection and PyTypingTypeProvider
GitOrigin-RevId: 6643f2396fabcedd7a6b189e95146ea28d2a2e96
2025-01-08 14:05:26 +00:00
Daniil Kalinin
76e64a99dd PY-75759 Turn off the check for the number of type arguments for everything but operands which are explicitly resolved to class declaration
Temporary. It will be changed along with the support for the checks for TypeAlias-es
Better naming

GitOrigin-RevId: 1a56e31e4fba26072fdc1cd104203cf888c89df9
2025-01-08 14:05:26 +00:00
Daniil Kalinin
1dbd0cdebd PY-75759 Refactor the check for type parameter default scoping
Briefly:
* Get the clarified type parameter type from `PyTypingTypeProvider` for further checks to be able to check the defaults of ParamSpec and TypeVarTuple as well.
* Use a set of declaration elements as the set of processed generics
* Better naming

Add missing tests

GitOrigin-RevId: 0a78b350a997508d325228335490712214e03773
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
304dea9a94 PY-75759 Correctly infer a default type of ParamSpec if it is a forward ref to another ParamSpec via string literal
Consider this change in PyTypeHintsInspection

GitOrigin-RevId: a97011f421a8804c2abe126daf1ac1d1c41cc4ad
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
Daniil Kalinin
f05119cead [python] Store default types of Type Parameters as Ref to avoid problems with an explicit Any
GitOrigin-RevId: 880e883d196dc48d9cf6400580e9b4981448c507
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
90897b73b7 PY-78248 typed dict can be compatible with protocol types
GitOrigin-RevId: c19c0c68610718878b76ce5e149f0e1e1e642465
2025-01-07 21:44:59 +00:00
Mikhail Golubev
98a4ae8a8c PY-74114 Split PyTypeshed.findRoots* into findStdlibRoots* and findAllRoots*
So as not to cause confusion about which roots are added to SDK paths.

GitOrigin-RevId: 7045c7e3b48d216342d9eb77f2ad06026155f13b
2025-01-06 17:58:30 +00:00
Mikhail Golubev
8fcefcb14c PY-77456 Add a dedicated project tree node for bundled .pyi stubs
GitOrigin-RevId: e0504ba6a77ad29dfe900c721201333388910306
2025-01-06 17:58:30 +00:00