Commit Graph

257 Commits

Author SHA1 Message Date
Andrei Iurko
efbebbef0b [qodana] QD-9891 Add reviewed inspections categories and fix json schema validation
GitOrigin-RevId: 7ca2b2fde31a47b41b1940badee13d931bd91102
2024-11-06 14:28:05 +00:00
Mikhail Golubev
da2936d4a4 PY-42137 Report incorrect arguments if no overload matches
Previously, we reported call arguments only if either all callee
candidates have unmatched arguments or all call candidates have
unmatched parameters. When there was a mix of the two, we reported
nothing.


(cherry picked from commit 97b42faf10de74ee7cd10f934d9eb94e1c8bbb34)

IJ-CR-146869

GitOrigin-RevId: 8babfe6a8ad0152f985655eff27df4df68936594
2024-11-06 11:22:48 +00:00
Daniil Kalinin
ea62ea04bc IJ-MR-146029 PY-76149 simplify the check for expected type from __set__ and assigned value
Reword the inspection text
Co-authored-by: Mikhail Golubev <mikhail.golubev@jetbrains.com>

(cherry picked from commit cab3cb1bbb1316462ee3fd37e735765b31b8d5e8)

GitOrigin-RevId: e3288e503d714a1f76bd1a2e6a0553770e1cbad5
2024-10-28 20:14:19 +00:00
Daniil Kalinin
4ad6f08f45 PY-76399 Support __set__ descriptor
Add API for inferring the expected type of `__set__` from `value` parameter
Add corresponding logic to PyTypeCheckerInspection to check if assigned value matches the expected descriptor type
Add tests on it

(cherry picked from commit b14ab7b2e40e225b508875a778ceae8986cbb291)

GitOrigin-RevId: 2b15b2b4527a95e5912897ba256dcc73d71c3dcd
2024-10-28 20:14:19 +00:00
Andrey Vokin
63487fda41 PY-75580 Experiment with extended completion
GitOrigin-RevId: 8aeb4c123eb6c8eae3255c974d8630a0745df395
2024-10-14 13:15:14 +00:00
Andrei Iurko
4111cfc875 [qodana] QD-9891 Add aspects with the highest certainty for inspections
GitOrigin-RevId: 8fad66714287192bd5cbc8396a3d30f1ba139302
2024-10-11 14:49:57 +00:00
Ilia.Kondakov
fe4a6bf3a4 PY-50934 Implement features for ML ordering imports
add new features: info about underscores in path, info about lib location, info about context of original file(extension type, psi parents, size of project),
info about already existing imports from the same library(in this file, in other opened files, in other files in the same directory)

GitOrigin-RevId: ca8206d4d7db6bc79e8f1a78502bf33696a653e9
2024-09-27 10:33:53 +00:00
Irina Fediaeva
c4cb384bb7 PY-75246: Fix quick nav info for file and directory refs
GitOrigin-RevId: b2a6daaebf0f043f1bce2952637bf86c556e8646
2024-09-25 17:53:14 +00:00
Yuriy Artamonov
7810bf8adb [python] IJPL-158521 Actions: fix ellipsis in messages for actions
GitOrigin-RevId: c896f17db89f934ae64c24b920ed3684b605d168
2024-09-15 14:50:09 +00:00
Mikhail Golubev
1da22d34fd PY-54560 Support PEP-681 dataclass_transform
`dataclass_transform` support posed a number of challenges to the current
AST/PSI stubs separation in our architecture. For the standard "dataclasses"
module and the "attrs" package API, we could rely on well-known names
and defaults to recognize and preserve the information about decorator
arguments and field specifier arguments in PSI stubs. With `dataclass_transform`
however, effectively any decorator call or extending any base class can indicate
using a "magical" API that should generate dataclass-like entities.
At the moment of building PSI stubs we can't be sure, because we can't leave
the boundaries of the current file to resolve these names and determine if these
decorators and base classes are decorated themselves with `dataclass_transform`.

To support that, we instead rely on well-known keyword argument names documented
in the spec, e.g. "kw_only" or "frozen". In other words, whenever we encounter
any decorator call or a superclass list with such keyword arguments, we generate
a `PyDataclassStub` stub for the corresponding class.

The same thing is happening with class attribute initializers, i.e. whenever
we see a function call with argument such as "default" or "kw_only" in their
RHS, we generate a `PyDataclassFieldStub` for the corresponding target expression.
Both of these stub interfaces now can contain null values for the corresponding
properties if they were not specified directly in the class definition.

Finally, for the `dataclass_transform` decorator itself, a new custom decorator stub
was introduced -- `PyDataclassTransformDecoratorStub`, it preserves its keyword
arguments, such as "keyword_only_default" or "frozen_default" controlling
the default properties of generated dataclasses.

Later, when we need concluded information about specific dataclass properties,
e.g. in `PyDataclassTypeProvider` to generate a constructor signature, or in
`PyDataclassInspection`, we try to "resolve" this incomplete information from stubs
into finalized `PyDataclassParameters` and `PyDataclassFieldParameters` that
contain non-null versions of the same fields. The main entry points for that
are `resolveDataclassParameters` and `resolveDataclassFieldParameters`.
These methods additionally handle the situations where decorators, superclass
lists and field specifiers lack any keyword arguments, and thus, there were no
automatically created custom stubs for them.

All the existing usages of `PyDataclassStub` and `PyDataclassFieldStub`
were updated to operate on `PyDataclassParameters` and `PyDataclassFieldParameters`
instead.

Counterparts of the tests on various inspection checks for the standard dataclasses
definitions were added for dataclasses created with `dataclass_transform`, even
though the spec is unclear on some aspects the expected type checker semantics, e.g.
if combining "eq=False" and "order=True" or specifying both "default" and
"default_factory" for a field should be reported.
I tried to follow common sense when enabling existing checks for such arbitrary
user-defined dataclass APIs.

GitOrigin-RevId: 4180a1e32b5e4025fc4e3ed49bb8d67af0d60e66
2024-09-09 11:34:15 +00:00
Daniil Kalinin
82fca2f070 PY-71002 PEP-696: Add an inspection that checks that non-default Type Parameters in declarations cannot follow the default ones
GitOrigin-RevId: 29c63024a67802457e031821e33925287f21a2ab
2024-09-07 11:11:13 +00:00
Petr
5d2d6cc722 PY-23067 Pycharm not picking function metadata from functools.wraps with methods
GitOrigin-RevId: d95c1a8f64a6e58d1a6c6c65866b6ab08aaf71b3
2024-08-28 20:02:44 +00:00
Vladimir Koshelev
6c7c41abb8 [pycharm] add type hint checks about TypeGuard and TypeIs PY-74271
GitOrigin-RevId: 50835cffbddcb73ca0ec0aca2234a89f62d4b5fb
2024-08-23 17:26:21 +00:00
Daniil Kalinin
26124892cc PY-75416 disable reparseable statement lists as a workaround
GitOrigin-RevId: d8a5d80fff3886c4f864b2ec82ca8fdf38a9f2b8
2024-08-23 13:54:11 +00:00
Gleb Marin
dc3c5730ea JBAI-5408 Release ML Imports Ranking in 2024.3
[ml tools] Fix build issue

[ml tools] Fix build issue

[ml tools] Fix build issue

[ml tools] Replace task object with service

[ml tools] Fix rebase issues

Add session duration metric

[ml imports ranking] Log fully only during EAP

[ml imports ranking] Set up FUS logs

[ml tools] Add dependency on ml api library


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

GitOrigin-RevId: 69be00b4b8f38ec71208c3b17cd6566a34508859
2024-08-20 06:16:36 +00:00
Andrey Vokin
1be521e041 PY-73099 Support PEP 705 – TypedDict: Read-only items
GitOrigin-RevId: 24820bf7c9362d3b675ebfca16805744404ac2e9
2024-08-13 06:16:19 +00:00
Andrey Vokin
f4a04d15b6 PY-73099 Support PEP 705 – TypedDict: Read-only items
support for "ReadOnly" qualifier in chain with "Required" and "NotRequired"

GitOrigin-RevId: 4ee6d82f7153d4b65217acb34acc71c4b6c20dc6
2024-08-13 06:16:19 +00:00
Vladimir Koshelev
ec8c3a8aa3 [pycharm] remdev: migrate PyCharm Frontend launcher to v2 modules
GitOrigin-RevId: e2c62c23bd0a22c742a46177c1a1ad4c4b5b95d0
2024-07-24 13:13:53 +00:00
Vladimir Koshelev
c559ffab2b [pycharm] change the order of extended completion contributors to last, so they cannot pollute other stages.
GitOrigin-RevId: 675ead60c308a41142cc0abc1015d2aa50178e02
2024-07-22 12:26:17 +00:00
Daniil Kalinin
e9a6246df3 PY-72185 Implement incremental parsing for PSI leaves for Python
Merge-request: IJ-MR-138193
Merged-by: Daniil Kalinin <Daniil.Kalinin@jetbrains.com>

GitOrigin-RevId: 7d004677a5b7a4637ea956f13ed85abc0d88604e
2024-07-17 12:15:36 +00:00
Aleksandr Sorotskii
097939cc6b PY-11963: add package mappings for 5k most downloaded packages pypi
GitOrigin-RevId: 95cf83695ad0031ffb009cd5cca8b68a0b49d6d3
2024-07-10 11:34:52 +00:00
Aleksandr Sorotskii
8a4013db94 trim whitespaces
GitOrigin-RevId: 97014ede7f4df5b9ec07e9d6b64abe6878581df4
2024-07-10 11:34:52 +00:00
Aleksandr Sorotskii
292c6e0837 PY-11963 Sort lines
(cherry picked from commit 8c998e6ace23604f29382d4547bdeebb0583e954)

IJ-MR-139247

GitOrigin-RevId: c0d0f76a36073d25506e0446bbb406ea97f73d8f
2024-07-08 19:39:36 +00:00
Aleksandr Sorotskii
aa7a9353cf PY-11963 Add some packages
(cherry picked from commit 7d465f3823c0f9f0a31b49a0b675cbfda4a2f79b)

IJ-MR-139247

GitOrigin-RevId: 27c8ac0e17a2e04d2fd919b777ad98614dbb3bd9
2024-07-08 19:39:35 +00:00
Petr
5054f4a9b5 [python] Do not store unused decorator arguments in stubs
GitOrigin-RevId: d1a5f63dbed11a4f373d1d7936700af3bc74f70f
2024-07-02 14:04:36 +00:00
Egor.Eliseev
58d8eddeb8 PY-73525 Split HelpersLocator into Community/Pro versions
Merge-request: IJ-MR-138058
Merged-by: Egor Eliseev <Egor.Eliseev@jetbrains.com>

GitOrigin-RevId: cd82bc44337e7fdd182262c44ea5ca29e1804ad2
2024-07-02 11:43:46 +00:00
Daniil Kalinin
ba6015d27f PY-64326 implement incremental parsing for PyStatementList PSI elements
These changes make PyStatementList elements (which are function and class bodies, cycle bodies, if-else branches, etc.) lazy-parseable which means they can now be reparsed without reparsing the whole file if changes are happened inside them accepted as safe

The main reason behind these changes is to improve performance

GitOrigin-RevId: 892acbe0c95fde6aec74b7595b0a58f902c426f5
2024-05-07 17:30:41 +00:00
Vladimir Koshelev
8754f98cbe PY-72443 fix module => package mapping for some of the popular ml libs
GitOrigin-RevId: 962d57b87333c8c196dbd52bcfd4b5a41ba7317b
2024-05-06 15:20:45 +00:00
Mikhail Golubev
b9d7fee816 PY-64304 EA-247016 Don't report illegal "await" expressions used as assignment targets during parsing
Instead, parse them as usual and later report in the dedicated AssignTargetAnnotator
and TypeAnnotationTargetAnnotator. This way, a PsiError element appearing in the PSI
tree of a type declaration statement doesn't cause PyAstTypeDeclarationStatement.getTarget
nullability contract violation.

GitOrigin-RevId: a3e90088cfac7938c398d4d293a72dbd127a2cd0
2024-04-24 09:03:53 +00:00
Mikhail Golubev
5f6848fccb PY-65966 Disable partial tensorflow stubs in Typeshed with a registry flag
Otherwise, incomplete stubs break our custom logic for resolving tensorflow
modules re-exported from its _api.v2 subpackage, such as tensorflow.audio,
tensorflow.image, tensorflow.random, etc.

We did the same for Numpy stubs in the past, enabling them back once they
became mature enough.

GitOrigin-RevId: b1e46067406a592761f56b7d296a287e5282b079
2024-04-23 11:03:04 +00:00
Petr
e01b0b6beb PY-40480 Completion for argument passed to parameter hinted as Literal
GitOrigin-RevId: 462b03dc35eef70bc873b568cae239d40f1d4974
2024-04-18 20:55:14 +00:00
Petr
4602d09655 PY-61639 Extracted PyHighlightingAnnotator
GitOrigin-RevId: 432bcb87b77fa55f1ccb26000d91ae021cebcc6b
2024-03-27 15:05:16 +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
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
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
85c54b3a4c PY-61639 Move PythonFormattingModelBuilder to python.syntax.core
GitOrigin-RevId: bdcbd076cd3c1531204eff35515b44cd0edc9f68
2024-02-16 15:52:22 +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
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
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
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
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
lada.gagina
75b1ecd244 [python] Cleanup supported/unsupported versions xmls
- Drop support for python 3.5 & 3.6 in compatibility inspection
- Fix and remove some outdated tests
- Remove xmls for long-unsupported python 2.6 & 3.5
- Regenerate versions.xml
- Remove mentions of OS-specific modules

GitOrigin-RevId: 3265dd1de8a4f7a41119e10c95bb705ca5845efe
2023-11-17 18:57:31 +00:00
Daniil Kalinin
646ba00a3d PY-61857 Implement PEP 695 Type Parameter Syntax usage inspection:
Inspection covers such cases:
* Extending typing.Generic in new-style generic classes
* Extending parameterized typing.Protocol in new-style generic classes
* Using generic upper bounds and constraints with type parameters for ParamSpec and TypeVarTuple
* Mixing traditional and new-style type variables
* Using traditional type variables in new-style type aliases

GitOrigin-RevId: 8812959f64d2d87e1b72f713405edb86936220b9
2023-11-06 19:59:18 +00:00