Commit Graph

1409 Commits

Author SHA1 Message Date
Sergey Karpov
e371768835 [pycharm] PY-40180. Moved the check inside checkReturnValueAllowed. Added a regression test.
(cherry picked from commit 0367ac9bba083eb46f5759f7fa102cf1545215be)

IJ-CR-124368

GitOrigin-RevId: 0998aaaa50d2d8b6efc49295b22c2245f5477878
2024-03-07 12:55:42 +00:00
Sergey Karpov
8387d7f29f [pycharm] PY-40180. Added a check for protocol. If true, then the warning is skipped.
(cherry picked from commit dbe8d89894671ddd858483910185cca3f2113b7a)

IJ-CR-124368

GitOrigin-RevId: 1dd37468343dcf0f9b4a197d97a761a59d119620
2024-03-07 12:55:38 +00:00
lada.gagina
2f4f004d11 [python] requirements.txt: Rename the visitor, remove extra inspection description
GitOrigin-RevId: 17f897c74dee05cf1fdc128d124a8a493586b45e
2024-03-05 15:56:14 +00:00
lada.gagina
e97eeace5c [python] requirements.txt: Add an in-place inspection for not installed packages (PY-65403)
GitOrigin-RevId: 29d5b17ce5946c807afa635ac11ea9bdaf200999
2024-02-26 03:26:30 +00:00
Georgii Ustinov
8f39e87344 Replace grouping elements by their virtual file path to PsiFile in CompatibilityPrintCallQuickFix
PY-65297

GitOrigin-RevId: cc32d7a2099b0f5b08c8e9d2c2a9700febf9e639
2024-02-22 15:44:38 +00:00
Mikhail Golubev
8ebcb1ec88 PY-59241 Restore compatibility of PyTypeCheckerExtension with the "dev.ngocta.pycharm-odoo" plugin
However, the plugin is seemingly modifying type parameter substitutions in this extension, which
is discouraged and won't work from now on. We should contact its author about it.

GitOrigin-RevId: 3438afa86f6330386c52f58f5a98d1271c05e006
2024-02-20 14:40:31 +00:00
Mikhail Golubev
470ff54632 PY-59241 Mark PyGenericType as scheduled for removal
GitOrigin-RevId: 1003aa9e2438952fb03928fc68fd811e6412bff1
2024-02-20 12:21:53 +00:00
Mikhail Golubev
ea23931911 [python] Return unmodifiable maps from GenericSubstitutions
GitOrigin-RevId: 130cfb308dc625017c66ebf86233b38b84e7c8c4
2024-02-20 12:21:50 +00:00
Mikhail Golubev
7874bb7b29 PY-59241 Remove remaining usages of the deprecated PyGenericType
GitOrigin-RevId: 336204a04abd6c488d42ef4c52d6803d3e078abe
2024-02-20 12:21:47 +00:00
Mikhail Golubev
474431fcef [python] Refactor type parameter substitution for ParamSpec and Concatenate
I clearly split the substitution logic into separate branches for ParamSpec,
Concatenate and ordinary callable parameters instead of the previous "do-all"
loop. It additionally fixed a bug with using TypeVarTuple inside Concatenate.

GitOrigin-RevId: 19e880e4a129ac5bbd0520e26899334f0aa6bb51
2024-02-19 16:30:00 +00:00
Mikhail Golubev
f7adf25ecb PY-70484 Replace unbound ParamSpecs in result types with (*args: Any, **kwargs: Any)
GitOrigin-RevId: 5e6950217409b690993d75bc0fdfdada5420f08f
2024-02-19 16:29:55 +00:00
Mikhail Golubev
7320815ad2 PY-65385 Retain unbound ParamSpecs as-is during type parameter substitution
The original problem with @contextlib.asynccontextmanager was due to a bug
in PyTypeChecker.substitute introduced in the TypeVarTuple support. Namely,
we started to substitute unmatched ParamSpec types with null, effectively
replacing them in a callable signature with a single parameter of type Any.
Then the special logic in PyCallExpressionHelper.mapArguments that treated
unmatched ParamSpecs as "catch-all" varargs stopped working, and we started
to highlight all extra arguments in the substituted callable invocations.

In other words, binding type parameters from decorator targets, e.g.
ParamSpecs or function return types, never worked because we can't resolve
functions passed as decorator arguments in "de-sugared" expression fragments
in the codeAnalysis context, i.e. when we replace

```
@deco
def f(x: int, y: str): ...
```

with `deco(f)` and then try to infer its type in PyDecoratedFunctionTypeProvider,
but we didn't report it thanks to that special-casing of unmatched ParamSpecs
(other type parameters replaced by Any don't trigger such warnings).

Ideally, we should start resolving references in arguments of function calls
in such virtual expression fragments in some stub-safe manner instead of relying
on this fallback logic. In the general case, however, complete stub-safe inference
for decorators is a hard problem because arbitrary expressions can affect types of
their return type, .e.g.

```
def deco(result: T) -> Callable[[Callable[P, Any]], Callable[P, T]]: ...

@deco(arbitrary_call().foo + 42)  # how to handle this without unstubbing?
def f(x: int, y: str): ...
```

GitOrigin-RevId: adeb625611a3ebb7d5db523df00388d619323545
2024-02-19 16:29:50 +00:00
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