Commit Graph

1365 Commits

Author SHA1 Message Date
Petr Golubev
b3c3216f79 PY-61639: Extracted python ast
GitOrigin-RevId: 4fc0ae909811302d8425f1e67d8c648c290afcb3
2024-01-17 17:23:01 +00:00
Ilya.Kazakevich
b533e29ce0 [python] get rid of classes registered in wrong modules
You must register class in the same v2 module class sits

GitOrigin-RevId: c7fcccd27c2fcaa3d9391d1173f61ad43fe2b076
2024-01-17 04:59:01 +00:00
Georgii Ustinov
f8b666c6cd Specify more precisely elements for some ModCommand based actions, remove file type check, hide startInWriteAction
PY-62597

GitOrigin-RevId: d2bd27cbc0f6197d4c9cfbb55fa23351f255aa18
2024-01-15 13:15:57 +00:00
Georgii Ustinov
369953fbd2 Specify more precisely elements for some ModCommand based actions and remove IntentionFamilyName annotation from key
PY-62597

GitOrigin-RevId: 486a50119c13e1d204bd13f63bf0786a84d54408
2024-01-15 13:15:48 +00:00
Georgii Ustinov
1ee87451b8 Migrate PyBaseConvertCollectionLiteralIntention to ModCommand
PY-65297

GitOrigin-RevId: 992f7104f83136b1bb2c47d29a83dc482bcf15b2
2024-01-12 16:07:38 +00:00
Georgii Ustinov
85810b8e83 Migrate PyConvertToFStringIntention to ModCommand
PY-65297

GitOrigin-RevId: b8323699fe45068a330662e78052decd6035b919
2024-01-12 12:53:18 +00:00
Georgii Ustinov
16c24031a3 Migrate PyConvertTripleQuotedStringIntention and PyDemorganIntention to ModCommand
PY-65297

GitOrigin-RevId: 900c8ac1568a0d97e7365cf63e7c554d57a76708
2024-01-12 12:53:11 +00:00
Georgii Ustinov
1ca8156c65 Migrate PyDictConstructorToLiteralFormIntention, PyDictLiteralFormToConstructorIntention, PyFlipComparisonIntention
PY-65297

GitOrigin-RevId: 535ec8dce4ecb5933f840fb6237ecec1b9ed07ad
2024-01-12 12:53:04 +00:00
Georgii Ustinov
83a345e0ba Migrate PyInvertIfConditionIntention, PyNegateComparisonIntention, PyQuotedStringIntention to ModCommand
PY-65297

GitOrigin-RevId: b6fcd76c1f21cbf7b17e11ca4690be6f9742faba
2024-01-12 12:52:58 +00:00
Georgii Ustinov
183c37f41e Migrate PyConvertImportIntentionActio and ReplaceListComprehensionWithForIntention to ModCommand
PY-65297

GitOrigin-RevId: e5aa826a816c3d302a7f70f005ba6688449bde10
2024-01-12 12:52:51 +00:00
Georgii Ustinov
fb31a3e184 Migrate PyStringConcatenationToFormatIntention to ModCommand
PY-65297

GitOrigin-RevId: c70ff45bfee111408b44aa903c353eba6df895c3
2024-01-12 12:52:44 +00:00
Georgii Ustinov
f8990a192d Migrate CompatibilityPrintCallQuickFix, PyTransformConditionalExpressionIntention and PyYieldFromIntention to ModCommand
PY-65297

GitOrigin-RevId: f77789cecd5d8d83e33242b7e800b63b00dafe1e
2024-01-12 12:52:37 +00:00
Mikhail Golubev
d6275fee56 [python] Rename PyVariableAnnotator to PyLocalVariableAnnotator
GitOrigin-RevId: 3915187122fc37bea44ca983b685dbfa0f65d725
2024-01-12 11:52:18 +00:00
Mikhail Golubev
f9bb539137 [python] Speed up and extend PyVariableAnnotator
Traversing through all children of a PyFunction looking for nested functions,
possibly declaring a nonlocal or global variable, and doing that for every
target expression or a reference to one, is both inefficient and seemingly
hardly needed. For a name being local means that it cannot be accessed
outside the scope of the corresponding function. Updating this variable from
some inner helper function doesn't violate this property. In Python, one
has to explicitly mark a name from an enclosing scope as nonlocal or global to
be able to assign to it within a function. It seems enough (and less surprising)
to rely on this information to distinguish between local variables and everything
else.

All in all, if some local variable is accessed as a nonlocal name in an inner
function, it's now still highlighted as local in the function that defines
it (previously it wasn't), but it is not in the function declaring it as
nonlocal (same as before).

Additionally, we now uniformly highlight as local variables "for" and "with"
statement targets, targets of assignment expressions, names bound in patterns,
and variables in assignments with unpacking (previously it was done only for
trivial assignments).

GitOrigin-RevId: 04c07ae6814a6b531911b3d87a3a26191c934962
2024-01-12 11:52:08 +00:00
Ilya.Kazakevich
e4a56dc87f [python] PythonPsiApiIcons moved to com.jetbrains.python package, as whole community.python.impl must be there
GitOrigin-RevId: 0c38ddbdd5b0588ed4ec09c1d447248678974323
2024-01-11 20:29:55 +00:00
Ilya.Kazakevich
f8a5625f99 [python] packages moved to com.jetbrains.python package, as whole community.python.impl must be there
GitOrigin-RevId: 339a5be4b4c260ce0c31ee2245870ef953065b2d
2024-01-11 20:29:48 +00:00
Mikhail Golubev
fa168f4a00 PY-36444 Remove @contextlib.contextmanager from PyKnownDecoratorUtil.KnownDecorator
This decorator is fully type hinted in Typeshed, so, with the changes introduced
for PY-60104, it's no longer necessary to special-case it anywhere.
PyDecoratedFunctionTypeProvider can infer the correct type after application
of this decorator to a generator function just as for any other typed decorator.

The original problem was caused by the fact that PyDecoratedFunctionTypeProvider
didn't process declarations having any decorator listed in the KnownDecorator enum,
as presumably all of them were too "magical" to analyze.

Co-authored-by: Daniil Kalinin <daniil.kalinin@jetbrains.com>

GitOrigin-RevId: 53b277803a1eb42784131d0dae5bb7ace173c017
2024-01-09 20:49:13 +00:00
Mikhail Golubev
3079150697 PY-60104 Don't try to infer side effects of not type hinted decorators
Assume that such decorators as well as "well-known" decorators, which we special-case,
don't change signatures of decorated functions and classes.

This change effectively stops the long-standing policy of safe-listing a few recognized
"well-known" decorators and assuming everything else can change a definition in any
way. This approach doesn't apply well to the current state of the Python world, where most
of the common side effects of decorators, such as adding new parameters, can be expressed
in type hints.

In 2021.1 we added PyDecoratedFunctionTypeProvider that was able to infer a return type of
decorator over its body, as for any other function, and then correctly apply this information
to a decorated definition. It led to a number of problems.

First of all, depending on whether TypeEvalContext allowed us to access AST of a decorator's
body, we inferred different signatures for functions decorated with an imported decorator in
inspections and in user-initiated actions, such as Parameter Info.

Secondly, we started inferring useless `(*args, **kwargs)` signatures in case of decorators
defined following the common pattern of returning a wrapper function accepting arbitrary
parameters and itself decorated with @functools.wraps (PY-48338). In some sense, our code
analysis was "too smart" in its type inference in this case.

Lastly, we diluted the return types of functions decorated with unknown decorators, even
fully typed, by uniting these types with Any (so-called "weak" types). This logic
existed before PyDecoratedFunctionTypeProvider, but it became more problematic now
than we were able to propagate this artificial union through generic decorators.

This change in behavior might lead to some false positives for untyped Python code
with non-pure decorators. However, given that other type checkers are also likely to hit these
problems, there is now a stronger incentive to add type hints for such problematic APIs.
In the worst case, we can special-case some heavily requested decorators as we did before.

GitOrigin-RevId: db11fb3573bda5da155cb921a30adc31d5c841e2
2024-01-09 20:49:13 +00:00
andrey.matveev
52f21cc60d PY-48338 PY-60104 Make decorators pure functions if not annotated
GitOrigin-RevId: fed5c22c9114a5dcfb882be367c570baf8ba3e5a
2024-01-09 20:49:13 +00:00
Ilya.Kazakevich
0bb35f314f Move ext classes to the correct package
GitOrigin-RevId: 7caba83654fff8b721a5c7c238f582358af7eebe
2024-01-09 03:00:22 +00:00
Ilya.Kazakevich
66856780b6 Move NNP to the correct package
GitOrigin-RevId: 741f097ea8f599a182f8b44ae0e55fee15e7b09f
2024-01-09 03:00:16 +00:00
Ilya.Kazakevich
7d6afbdf7e Move tensorflow to the correct package as everything must be in com.jetbrains.python in this module
GitOrigin-RevId: e684b59a25303e4ed7f41a109a58bc424a532c1d
2024-01-09 03:00:09 +00:00
Ilya.Kazakevich
fc2c5e4389 Move numpy to the correct package as it sits inside of includable module
GitOrigin-RevId: 3f697f59e60c11b03a1cc04649b864d510310cd3
2024-01-09 03:00:02 +00:00
Georgii Ustinov
e904a3fe51 Migrate AddParameterQuickFix and PyJoinIfIntention to ModCommand
PY-65297

GitOrigin-RevId: 6ed09dbd203e8267472b13298c40a143595d2696
2024-01-08 17:23:49 +00:00
Georgii Ustinov
841df0c0a2 Remove old template builder and assert on valid psi in StatementEffectIntroduceVariableQuickFix
PY-65297

GitOrigin-RevId: 62ab94ec16f9cce0ac7606c5da48422d7512dc5e
2024-01-08 17:23:43 +00:00
Georgii Ustinov
76691e44e9 Migrate RenameParameterQuickFix and StatementEffectIntroduceVariableQuickFix to ModCommand
PY-65297

GitOrigin-RevId: 8d9763a3039f26ab65557721682ce9f409e7f72b
2024-01-08 08:42:52 +00:00
Georgii Ustinov
4d2e4a3197 Migrate UnresolvedReferenceAddSelfQuickFix to ModCommand
PY-65297

GitOrigin-RevId: 4265fda32fa1fe27fe04e7cdea98840cc90c7eee
2024-01-05 09:10:51 +00:00
Georgii Ustinov
007259a141 Migrate PyReplaceTupleWithListQuickFix and UnresolvedRefTrueFalseQuickFix to ModCommand
PY-65297

GitOrigin-RevId: e0abfb5676823e1a70d5aac605da7844ca170ee4
2024-01-05 09:10:47 +00:00
Georgii Ustinov
bf7b728383 Migrate RemovePrefixQuickFix and RemoveTrailingSuffixQuickFix to ModCommand
PY-65297

GitOrigin-RevId: a1ce25b66db97aec5aa3cdc6b15f521628971814
2024-01-05 09:10:43 +00:00
Georgii Ustinov
cf043445b0 Migrate RemoveUnnecessaryBackslashQuickFix and ReplaceBackquoteExpressionQuickFix to ModCommand
PY-65297

GitOrigin-RevId: 4ce00d9b64e1ec4df6ef95784df9f9cd54e21dfa
2024-01-05 09:10:39 +00:00
Georgii Ustinov
9beee6f18c Migrate ReplaceBuiltinsQuickFix and ReplaceExceptPartQuickFix to ModCommand
PY-65297

GitOrigin-RevId: 0c64bd5e5f4fb68f0d41640896470d429865b3d2
2024-01-05 09:10:35 +00:00
Georgii Ustinov
c90238e42d Migrate ReplaceFunctionWithSetLiteralQuickFix and ReplaceListComprehensionsQuickFix to ModCommand
PY-65297

GitOrigin-RevId: c5cd524b2c845f45267fa2820d0a4793c132f403
2024-01-04 16:41:37 +00:00
Georgii Ustinov
2fffdde734 Migrate ReplaceNotEqOperatorQuickFix and ReplaceOctalNumericLiteralQuickFix to ModCommand
PY-65297

GitOrigin-RevId: b6b50c5b6e2d1377447eb1e0efe0e7e8bc57fed1
2024-01-04 16:41:30 +00:00
Georgii Ustinov
3e0851d3ad Migrate ReplaceRaiseStatementQuickFix and SimplifyBooleanCheckQuickFix to ModCommand
PY-65297

GitOrigin-RevId: 00073926ac8a9423db5eec815452ef4242b2fad8
2024-01-04 16:41:23 +00:00
Georgii Ustinov
b5d9bfc271 Migrate StatementEffectFunctionCallQuickFix and TransformClassicClassQuickFix to ModCommand
PY-65297

GitOrigin-RevId: 19cf199f074e8b213f1353a2a56b2782b2fe69dc
2024-01-04 16:41:17 +00:00
Georgii Ustinov
88ec839d3e Remove PsiElement#isWritable check for expression in ChainedComparisonsQuickFix
PY-65297

GitOrigin-RevId: ab932391aa90a290c10b7fefc670ec6a0f9df9b2
2024-01-04 11:06:11 +00:00
Georgii Ustinov
dadc1846d5 Change PyRemoveAssignmentStatementTargetQuickFix to PsiUpdateModCommandQuickFix + revert PyUnusedLocalInspectionVisitor
PY-65297

GitOrigin-RevId: f7f456bd8fb9cb2a3be8a48b8f01daa01f869c4b
2024-01-04 11:06:07 +00:00
Ilia Zakoulov
240815345a PY-63758: Provide correct type eval context for resolving parents of django app config class
GitOrigin-RevId: a7a1e1f72c9b512b5ea0e661528642de15ec01bf
2023-12-20 20:33:51 +00:00
Ilia Zakoulov
ed22c3d8b4 PY-65418: Update already evaluated result when .extend only if the result not null
GitOrigin-RevId: 14c8e909913819ec62f629266b026b866d07a01b
2023-12-19 12:56:07 +00:00
Georgii Ustinov
286bf8bddf Migrate RemoveDecoratorQuickFix and RemoveTrailingSemicolonQuickFix to ModCommand
PY-65297

GitOrigin-RevId: 8b76c57a5224e18d9cf6f12f62862ecc6d7b03ed
2023-12-18 21:24:23 +00:00
Georgii Ustinov
e69a429eb3 Migrate PyUpdatePropertySignatureQuickFix and RedundantParenthesesQuickFix to ModCommand
PY-65297

GitOrigin-RevId: c8c81e09ff6459f385437da50acc481afcd991ae
2023-12-18 21:24:19 +00:00
Georgii Ustinov
530b79d991 Migrate all QuickFixes in PyTypeHintsInspection
PY-65297

GitOrigin-RevId: e71c1074779ea706511fff07db0053f1335f6cc4
2023-12-18 21:24:16 +00:00
Georgii Ustinov
4d1b5b0bd0 Migrate AddFixtureToFuncParametersQuickFix and PyUnpackTypeVarTupleQuickFix to ModCommand
PY-65297

GitOrigin-RevId: 2695f20eb27475245fb48a93c5ee874041e54463
2023-12-18 21:24:12 +00:00
Georgii Ustinov
58cf31d9f8 Migrate PyRemoveWithTargetQuickFix and PyReplaceStarByUnpackQuickFix to ModCommand
PY-65297

GitOrigin-RevId: 1530cfd4c31b48f980953538f3211c41902076bd
2023-12-18 15:25:34 +00:00
Georgii Ustinov
4f7601c1ed Migrate PyRemoveExceptionTargetQuickFix and PyRemoveUnderscoresInNumericLiteralsQuickFix to ModCommand
PY-65297

GitOrigin-RevId: 1d0f3761b74a11403a729e6504e46dc7e83ef0a7
2023-12-18 15:25:30 +00:00
Georgii Ustinov
7131f79163 Migrate PyRemoveCallQuickFix and PyRemoveDictKeyQuickFix to ModCommand
PY-65297

GitOrigin-RevId: 79257ed2504ca8e50a1b8b13bda18d5ea20f2b03
2023-12-18 15:25:26 +00:00
Georgii Ustinov
959ae914d8 Remove unnecessary updater#getWritable and fix incorrect cast in ChangeTypeQuickFix#applyFix
PY-65297

GitOrigin-RevId: 417550a121276358adc7297b6c5b301da9249bff
2023-12-18 10:34:53 +00:00
Georgii Ustinov
1c3b5dba6b Replace template builder updater#templateBuilder in PyChangeBaseClassQuickFix and remove unnecessary updater#getWritable
PY-65297

GitOrigin-RevId: 3b0409ed601be86543f3ed5cd6e46d5fd096d076
2023-12-18 10:34:49 +00:00
Anton Lobov
3f30ddebff [fleet] inline refactoring for python
GitOrigin-RevId: 8b17bfd232e7daaa7203b156724ec402252000d7
2023-12-15 21:02:51 +00:00
Anton Lobov
1bd891a46d [fleet] inline refactoring for python wip
GitOrigin-RevId: 1e23109e11a5f1bc67aa9d0159353a5bf827867f
2023-12-15 21:02:51 +00:00