Commit Graph

1427 Commits

Author SHA1 Message Date
Alexander Koshevoy
1dba282b9b PY-71284 Prevent Python plugin in CLion from logging lots of assertion errors when dealing with Python interpreters
Being a paid IDE, CLion users get the community version of Python plugin. In such configuration, successfully passing the condition `PlatformUtils.isCommercialEdition()` the further call of `PythonHelpersLocator.getHelpersProRoot()` method resulted in the assertions logged and a non-existent path of the Python Pro helpers returned.

GitOrigin-RevId: bca751f5524ad137f721af76c475905c54638177
2024-04-04 16:00:40 +00:00
Petr
4e2f6f2685 PY-28076 Type of assignment target in parentheses is not inferred
GitOrigin-RevId: 457adb65fea311a169ae8fd4ca78a6915518b378
2024-04-02 19:04:20 +00:00
Mikhail Golubev
f24e4f0fff [python] Cleanup in ImportToImportFromIntention: replace two mutable fields by one final
GitOrigin-RevId: ea3f453568709059eb2b14d35940d95596b49733
2024-04-02 18:57:35 +00:00
Mikhail Golubev
126b58d099 [python] Cleanup in ImportToImportFromIntention: remove redundant casts
GitOrigin-RevId: 28ba26e6c199d57052bab81f32a9b20e1a990ff2
2024-04-02 18:57:35 +00:00
Mikhail Golubev
79d991a338 [python] Cleanup in ImportToImportFromIntention: remove a meaningless loop
GitOrigin-RevId: e28fdc30bbf378784bb3f2753490e83125e624f4
2024-04-02 18:57:35 +00:00
Mikhail Golubev
0a7cb22aa2 [python] Cleanup in ImportToImportFromIntention: use simpler API for replacing a PSI element
GitOrigin-RevId: 815e6d1d879d3d8ee85cccf43b73ea2797687d61
2024-04-02 18:57:35 +00:00
Mikhail Golubev
9cfd020b2a [python] Cleanup in ImportToImportFromIntention: remove pointless validity checks and sure() usages.
GitOrigin-RevId: 16b43f86c27c82abe2a170a3852d91cba5e0a619
2024-04-02 18:57:35 +00:00
Mikhail Golubev
c9613fd97b [python] Cleanup in ImportToImportFromIntention: use ModCommand API for locating a target element
GitOrigin-RevId: 8aa1e79216362b48074868eefa6b4bfa2496faed
2024-04-02 18:57:35 +00:00
Mikhail Golubev
bfdf267830 [python] Cleanup in ImportToImportFromIntention: add nullability annotations, use simpler API
GitOrigin-RevId: 2d2d044475270f5bce6a7cc1bfed9c50fa1e8fb3
2024-04-02 18:57:35 +00:00
Petr
cdfef53944 PY-52760 Type checker fails at tuple unpacking into a dictionary
GitOrigin-RevId: dbf1181099501764ac9b0d42813b37b48882379c
2024-04-02 15:05:56 +00:00
Mikhail Golubev
cef42660a3 PY-17627 PY-17733 Resolve class attributes defined in @classmethods
The logic is similar to that for instance attributes. Top-level class
attributes and methods defined in the class body get the precedence,
followed by class attributes defined with assignments in @classmethods
unless the latter would resolve to the same assignments as in

cls.attr = cls.attr + 1

finally, we scan through all other class methods resolving the name
to the first definition inside one of them.

So far, I intentionally didn't expose such attributes in findClassAttribute()
or getClassAttributes() because users of these methods assume that
this API considers only attributes defined immediately in the class body.
Adding extra definitions from class methods might break these usages.

I had to update the inspection about typing.Final, because it relied
on the fact that resolve() on assignment targets on class objects can
lead only to those top-level class attributes, where type hints are normally
located, but now it can lead to assignments to a qualified attribute inside
a containing class method.

GitOrigin-RevId: 0ca5bdaa4efca127ac187e822a49df6795e1028a
2024-03-28 12:17:37 +00:00
Petr
4602d09655 PY-61639 Extracted PyHighlightingAnnotator
GitOrigin-RevId: 432bcb87b77fa55f1ccb26000d91ae021cebcc6b
2024-03-27 15:05:16 +00:00
Petr
3a8596a0e3 PY-38928 Parentheses around unpacking for "for" loop target variables break type inference
GitOrigin-RevId: 9debb720880dd77b47c325e426e2d76c74135192
2024-03-27 13:36:38 +00:00
Bernhard Geisberger
d0867b6470 [python] Fall back to name for isObjectClass if qualifiedName is not available
GitOrigin-RevId: e743c243ef7a8e3e57e18a9a763625e2fc77f5a7
2024-03-26 18:41:13 +00:00
Petr
2133229b97 PY-45863 Fixed import element resolve
GitOrigin-RevId: a4b4a912826c1be12cc87de47c75a54ac2592751
2024-03-26 13:07:38 +00:00
Petr Golubev
6a9ce08850 PY-45863 Suggest ImportToImportFromIntention on usages of a name
IJ-CR-121086

GitOrigin-RevId: f46dcf05acb37633bf19d20c91524b9be604723e
2024-03-25 17:55:17 +00:00
Petr
6b3d789a4b PY-61639 Client keyword highlighting
GitOrigin-RevId: 5af1268616b174cf1c163d60e8c41c02897ecbf7
2024-03-19 20:04:36 +00:00
Vladimir Dolzhenko
2f3425afe5 Add fast applicability check
GitOrigin-RevId: a7702d51d6f31eb64ccfb7bd95c4eb7d90179690
2024-03-15 18:51:35 +00:00
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