Commit Graph

1397 Commits

Author SHA1 Message Date
Petr
b9167aef8b PY-61639 Move PyPreFormatProcessor to python.syntax.core
GitOrigin-RevId: 30d204206de9e09eae34baf0555fc9be5822ba68
2024-02-16 15:53:21 +00:00
Petr
d7630f0ef5 PY-61639 Move PyTrailingBlankLinesPostFormatProcessor to python.syntax.core
GitOrigin-RevId: a33777ac12163807f1395cbb8b03c58df506c3cf
2024-02-16 15:53:16 +00:00
Petr
2c7f5b4b32 PY-61639 Move PyPreFormatProcessor to python.syntax.core
GitOrigin-RevId: 4832fe901219342bb7f1babf41280830e16fec49
2024-02-16 15:53:11 +00:00
Petr
f6cad19f19 PY-61639 Move PyKeywordTypeHandler to python.syntax
GitOrigin-RevId: 3e0e70f5868b0fc09c35e571db0d0e553902eb6d
2024-02-16 15:52:56 +00:00
Petr
3b9b10b296 PY-61639 Move extendWordSelectionHandlers to python.syntax
GitOrigin-RevId: d5957878544a0026f249109ca1df0a18e20a8a55
2024-02-16 15:52:51 +00:00
Petr
85c54b3a4c PY-61639 Move PythonFormattingModelBuilder to python.syntax.core
GitOrigin-RevId: bdcbd076cd3c1531204eff35515b44cd0edc9f68
2024-02-16 15:52:22 +00:00
Petr
da4a4b066b PY-61639 Move PyLanguageCodeStyleSettingsProvider to python.syntax
GitOrigin-RevId: 547f75fe15a4164ee317fe16b693233ca620a558
2024-02-16 15:52:17 +00:00
Piotr Tomiak
99e342f7c5 CPP-37547 Updated CLion Quick Doc for new rendering
GitOrigin-RevId: 79534937dde46f9dfbb51de97b16f61751ef6b67
2024-02-16 15:29:35 +00:00
Georgii Ustinov
6b66104764 Add support to replace old print to the new one in different files for CompatibilityPrintCallQuickFix
PY-65297

GitOrigin-RevId: 6e35127178c19e3197b7442bcadc274114c5571f
2024-02-16 13:07:00 +00:00
Georgii Ustinov
644da8b8be Add old-style methods PyQuotedStringIntention#isAvailable and PyQuotedStringIntention#invoke to preserve compatibility
PY-65297

GitOrigin-RevId: 8fb88685801410af2dd00bd55cc43b92a38b863e
2024-02-15 09:37:26 +00:00
Egor.Eliseev
5ef4bd59e7 PY-30279, PY-40318 Add correct type resolve for async and iterated fixtures
Merge-request: IJ-MR-108198
Merged-by: Egor Eliseev <Egor.Eliseev@jetbrains.com>

GitOrigin-RevId: dfd6501f64be944bff21621bce6ef45218912337
2024-02-13 20:54:32 +00:00
Piotr Tomiak
d491d45155 IDEA-345694 Rework margins and font-size for quick documentation popup - use consts for available style classes
GitOrigin-RevId: 2a362437da13754188ef11040c79eaa2f5da62a8
2024-02-13 00:16:06 +00:00
Tagir Valeev
ef147ff3a0 Fix warnings
GitOrigin-RevId: be3b4d86bb00598497392303899ca3fded10e3f9
2024-02-12 19:12:58 +00:00
Georgii Ustinov
10964f31fc Improve public API in PyQuotedStringIntention
PY-65297

GitOrigin-RevId: 6965f9b558ca278708c39e9ed37ec7b629f8554a
2024-02-12 16:48:35 +00:00
Georgii Ustinov
ad7870a802 Adapt PyQuotedStringIntention to use as public API
PY-65297

GitOrigin-RevId: 0d5184be120393144eaf10c66d7dd2c1ed219ede
2024-02-12 12:17:43 +00:00
Petr Golubev
25b8ebcf83 PY-61639 Extracted PythonEnterHandler
GitOrigin-RevId: 8fd0c063c917e07c3f1bf98533c3de867f770ee9
2024-02-08 13:58:08 +00:00
Petr Golubev
1a73bd2d21 PY-61639 Extracted PyAstElementGenerator
GitOrigin-RevId: 915c235120b079188d81efaa9ccf9728131fa3df
2024-02-08 13:58:08 +00:00
Petr Golubev
c90db007c0 PY-61639 Lift PyFile.getTopLevelAttributes(), PyFile.findTopLevelAttribute() to PyAstFile
GitOrigin-RevId: 373accde23bb2c55d1d23266da7874e34da96ea3
2024-02-08 13:58:08 +00:00
Petr Golubev
f818966298 PY-61639 Lift PyParameter.isSelf() method to PyAstParameter
GitOrigin-RevId: 919518e5d06f2b968974bfdbd8deea2ced03c822
2024-02-08 13:58:08 +00:00
Petr Golubev
223013dad1 PY-61639 Introduced PyAstElementVisitor
GitOrigin-RevId: 6ee69922a4ade172dba5abb3ea3b13d01c2b0ebc
2024-02-08 13:58:08 +00:00
Mikhail Golubev
2c1f92d396 [python] Cleanup in PyStringConcatenationToFormatIntention
- use more modern API where applicable
- give more descriptive names to variables and methods
- remove unnecessary abstraction of Lists as Collections
- remove a usage of PyClassTypeImpl
- remove a redundant counter variable
- remove casts
- remove now discouraged final modifiers
- add nullability annotations

GitOrigin-RevId: bfcd08760d1901417a6f662f8ea0205351fd28e5
2024-02-07 17:34:54 +00:00
Mikhail Golubev
454deac682 [python] Fix PyStringConcatenationToFormatIntention for enclosing string concatenations
Noticed in IJ-CR-123777.

GitOrigin-RevId: f32832bca10e805fc609babf81382709d58fc480
2024-02-07 17:34:49 +00:00
Mikhail Golubev
c432ce7605 [python] Reformat PyStringConcatenationToFormatIntention
GitOrigin-RevId: 05130866b9bc3d80d2fa6a66a0241b4fd8ab9c1e
2024-02-07 17:34:43 +00:00
Mikhail Golubev
442c4a0408 [python] Don't re-create TypeEvalContext and LanguageLevel in PyStringConcatenationToFormatIntention
GitOrigin-RevId: c108290dba1057068480709787d356929860551d
2024-02-07 17:34:38 +00:00
Mikhail Golubev
d542f769ef [python] Remove redundant getContainingFile() calls for LanguageLevel.forElement(psiElement)
GitOrigin-RevId: 7000722c4aa3243b80556268d7221ecfea10910f
2024-02-07 17:34:33 +00:00
Mikhail Golubev
b55fd53258 PY-35627 Make Python formatter always add a line break after a decorator list
For regular non-async functions, it already worked thanks to PyTokenSeparatorGenerator.

GitOrigin-RevId: b60dba7b34710cad7dc46ad6f943b3944fc00c42
2024-02-07 17:34:28 +00:00
lada.gagina
6b89cfb4d2 [python] Stop replacing underscore with hyphen for requirements (PY-65170)
GitOrigin-RevId: ad7f3c578f797d974d73b82100f530591daab53d
2024-01-29 19:57:08 +00:00
Daniil Kalinin
c79da2708c PY-64074 Add Quick Documentation for type parameters and type alias statements
Merge-request: IJ-MR-119974
Merged-by: Daniil Kalinin <Daniil.Kalinin@jetbrains.com>

GitOrigin-RevId: fa0c57b3005b31d892a394b3a5f595ac10135a71
2024-01-23 09:50:49 +00:00
Alexandr Suhinin
79653f2633 CR-101244 clean up: remove redundant overriding methods
GitOrigin-RevId: d4d165c6280b7bead925940c82b20f5300c7750a
2024-01-20 15:47:17 +00:00
Vladimir Koshelev
aec2051aa9 [python] get rid of IStubElementType and move logic about working with stubs to impl classes PY-61639
GitOrigin-RevId: 062dead109c25d944d4f61e901dc3c64c00b392e
2024-01-19 23:14:49 +00:00
Petr Golubev
05484d8f97 PY-53120 "Add method" action does not create async def
GitOrigin-RevId: 8b2286a3f50d7b0d00ebbb0befc9811a80f7b304
2024-01-19 20:06:59 +00:00
Tagir Valeev
4b41b4d7de Fix warnings
GitOrigin-RevId: 7f254921acad08c7a2b6192b4e6b8aed5bb29c47
2024-01-19 11:20:43 +00:00
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