152 Commits
Author SHA1 Message Date
Aleksandr.Govenko d8f57b77c6 PY-80524 Explicit return statement expected false positive for an if inside try / except
(cherry picked from commit 6877fc7b34622d7ae884233af96e06ea92c918c1)

IJ-MR-161824

GitOrigin-RevId: 8c3219ea8bb8f547f7c314af8cb0d432c042cd7c
2025-05-11 22:28:24 +00:00
Aleksandr.Govenko 5bf9f9ff39 PY-80493 Inconsistent return inspection adding "return None" after every line in context manager
Merge-request: IJ-MR-160763
Merged-by: Aleksandr Govenko <aleksandr.govenko@jetbrains.com>

(cherry picked from commit b576e30d433d39e426c8854d3ad485594ac9e958)

IJ-MR-160763

GitOrigin-RevId: cf6a3a4c834ee1df160e1927af1b75eb16eec3dc
2025-04-24 02:27:25 +00:00
Morgan Bartholomew 57b4491fda [pycharm] PY-79331 render type as "type", not "Type"
IJ-MR-159663

GitOrigin-RevId: e346f761a0c07e6f5897d02f6529ad78a073daa5
2025-04-16 08:37:21 +00:00
Pavel Karateev 2c3f89d873 PY-79802 Fix tests
(cherry picked from commit e423287ff840e04cea0548fcc589d7b7dc37b105)

IJ-MR-157680

GitOrigin-RevId: 16494fb1755b181d31c1ec43752e8fa21a795d51
2025-03-26 12:41:47 +00:00
Aleksandr.Govenko e8f5b1c631 PY-52477 PY-78913 Add inspection for inconsistent returns
Merge-request: IJ-MR-154297
Merged-by: Aleksandr Govenko <aleksandr.govenko@jetbrains.com>

GitOrigin-RevId: e89225212cc981a5b256fca4ee23d77659b3ce5e
2025-02-14 17:21:51 +00:00
Alex Grönholm 02f5e3f522 PY-75291: Implemented auto-import for PEP 695 type aliases
GitOrigin-RevId: c15a6387785813688358e9695186a72dbdf35744
2025-01-23 15:46:39 +00:00
Aleksandr.Govenko 80ea4e852c PY-20710 Support 'Generator' typing class
Check YieldType of yield expressions in PyTypeCheckerInspection
Check that (Async)Generator is used in (async) function
Check that in 'yield from' sync Generator is used
Convert PyMakeFunctionReturnTypeQuickFix into PsiUpdateModCommandAction
Infer Generator type for lambdas
When getting function type from annotation, do not convert Generator to AsyncGenerator
Introduce GeneratorTypeDescriptor to simplify working with generator annotations


Merge-request: IJ-MR-146521
Merged-by: Aleksandr Govenko <aleksandr.govenko@jetbrains.com>

GitOrigin-RevId: b3b8182168c5224f0e03f54d443171ccf6ca7b89
2024-12-04 15:22:15 +00:00
Aleksandr.Govenko 31dd92576e PY-20611 Missing warning about functions implicitly returning None when return type is not Optional
Updated PyFunction to account for implicit 'return None' statements when inferring return statement types.

It affected return type inference of PyFunction.

Fixed a failing test related to formatted strings.

Added a quick fix to make all return statements explicit.

Updated the CFG to include PyPassStatements, enabling detection of exit points in empty functions.

Simplified PyMakeFunctionReturnTypeQuickFix to independently infer function types and handle required imports. Currently, it does not support specifying custom suggested types.



Merge-request: IJ-MR-148719
Merged-by: Aleksandr Govenko <aleksandr.govenko@jetbrains.com>

GitOrigin-RevId: 9f58961f9eb70e4f9dbba7359f5aafdfd392b7e2
2024-11-26 17:02:37 +00:00
Petr c8509ccc80 [python] Support TypeVarTuple from typing_extensions
GitOrigin-RevId: 02ed108a55d3feed54d95bfb5552f31cdf3e4880
2024-05-24 22:15:34 +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
Petr Golubev 05484d8f97 PY-53120 "Add method" action does not create async def
GitOrigin-RevId: 8b2286a3f50d7b0d00ebbb0befc9811a80f7b304
2024-01-19 20:06:59 +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
lada.gagina ad5b55918e Revert tests with over-inferring LiteralString
(cherry picked from commit 0c92e1c64362e2834b01b4e0bcbcedfefe4febe0)

IJ-MR-112631

GitOrigin-RevId: 233abfde16b19e96c5bc39c77eef1a240aa1b3e8
2023-11-07 22:10:23 +00:00
andrey.matveev a75c569022 PY-53105 Support TypeVarTuple
GitOrigin-RevId: f8160e9d802b09991daa710ed9a20f3e30d455da
2023-10-20 13:38:04 +00:00
lada.gagina 47b89847e6 Add language level for Python 3.13 (PY-63375)
GitOrigin-RevId: beb405baf746c1992d51118d660cb8c718deda62
2023-10-12 20:25:28 +00:00
Egor.EliseevandDenis Mashutin 540f24faa4 PY-34498 Add an inspection for pytest fixture that is not passed to test parameters
Report warning if a fixture is used without being passed to test function parameters or to
`@pytest.mark.usefixtures` decorator.


Co-authored-by: Denis Mashutin <Denis.Mashutin@jetbrains.com>


Merge-request: IJ-MR-108713
Merged-by: Egor Eliseev <Egor.Eliseev@jetbrains.com>

GitOrigin-RevId: 28d0711b99ab7ae180f672306dd4ab8a81f1feec
2023-09-04 09:53:07 +00:00
Andrey.Matveev f38d61eed6 PY-58464 Restore stdlib canonical path for Decimal
GitOrigin-RevId: 1c0df1d9c9e8ad22b464e54c4bc30dda4f903946
2023-08-26 09:33:54 +00:00
Lada Gagina 454b1287ae PY-58857 Infer typing.LiteralString for string literals
GitOrigin-RevId: 27507deabd61faedf7937415016f0f8334e5a418
2023-06-21 16:32:22 +00:00
Natalia.Murycheva 0d53aa47df DS-4878 Pandas-specific-quick-fix-replace-listdf.col.values-to-df.col.tolist
Add new intention and a corresponding quick fix for the usage pd.Series.values property from pandas library.

^DS-4878 Fixed

Merge-request: IJ-MR-106089
Merged-by: Natalia Murycheva <natalia.murycheva@jetbrains.com>

GitOrigin-RevId: 0c8dc40b09ee2d95ecd8ded532f31f5ef4a7740f
2023-05-13 20:44:29 +00:00
KotlinIsland 45dd0bf0e8 Add language level for Python 3.12
GitOrigin-RevId: 10d24da89149754de63c87ec9edc0a1b7f131f17
2022-11-13 01:47:35 +00:00
andrey.matveev b7398bb63d PY-10719 Fix add import above import with noinspection comment
GitOrigin-RevId: 6dd79b10e56b9e9e2eee76c83d5974dee43446a1
2022-07-26 13:17:54 +00:00
Mikhail Golubev 3b6dea06a3 PY-21398 Wrap batch updates of existing usages in quickfixes with PotemkinProgress
It also fixes EA-425763 about using incorrect parent and anchor elements
to insert a function generated from a method of a nested class.

GitOrigin-RevId: f9b9da303396eb78c2c12b2750065dbdc0ba70ed
2022-02-17 09:28:34 +00:00
Lada Gagina 315f1905fd PY-46344 Import abstract base classes from collections.abc, not collections
GitOrigin-RevId: d4b7165f09f47c7cca6c3eb47b1e254e5b855b40
2021-11-19 12:04:44 +00:00
KotlinIsland 119696be41 Add language level for Python 3.11 (PY-51300)
GitOrigin-RevId: bc2fd30744ca9c2a8023c718ade4689bfc9fef9b
2021-11-17 15:31:59 +00:00
andrey.matveev 1156723b14 PY-33055 Fix move attribute to __init__ method quickfix
(cherry picked from commit cd6abb8ad8a01b22066bed85639242b03a85d1d0)

IJ-MR-8050

GitOrigin-RevId: f8a350835ce303c96b7f404263d8367242f4eaa6
2021-10-12 06:16:05 +00:00
andrey.matveev 903f6e11ca PY-27128 PY-48466 Fix problem with imports in PyMakeFunctionReturnTypeQuickFix
(cherry picked from commit 9320c2e708afa2ddd025f60b0c122132387493b7)

IJ-MR-10124

GitOrigin-RevId: 219e646482999e8b81b77aaf52eb24574381af3d
2021-09-20 11:56:03 +00:00
andrey.matveev 1fe7e5443c PY-49283 Add quick fix for from future import annotations
(cherry picked from commit 7d26e211c67f2574078e1f0e8951f744889d82d6)

IJ-CR-10316

GitOrigin-RevId: 34d4bc72b11613c0603587c1c0a9e640b0add023
2021-08-30 20:48:41 +00:00
andrey.matveev 781d56deec PY-49935 Fix test after fix internationalization for type hints illegal first parameter
GitOrigin-RevId: 75e9239648869c264b242841fdd53486377a0e71
2021-08-25 09:57:49 +00:00
andrey.matveev 997b58df49 PY-49935 Impl type inference and type checking for PEP 612
Support type hints and type checking for typing.ParamSpec and typing.Concatenate

(cherry picked from commit 7854b3386ccdffc0091664e0923622cd8c093fc9)

IJ-MR-12970

GitOrigin-RevId: 4578cb463b6ab8fc244766bfaccb122d0e2b7479
2021-08-23 17:52:45 +00:00
andrey.matveev ebe8f93812 PY-44974 PEP 604: Support Python3.10 unions
Support | syntax for python unions.
Also support type | None as a new style for Optional.
Fix highlighting unresolved reference issues with | syntax.
Type inference from isinstance and issubclass.
Add quick fix to switch to old-style syntax in earlier python versions (<3.10)
Fix quick documentation to render new syntax.

(cherry picked from commit 6a64ee12c2d8503a0ef102e8b67cb0b95ce77999)

IJ-MR-8400

GitOrigin-RevId: c26b868fc61f26936a3316ec06f78b66d75f6857
2021-06-14 14:38:25 +00:00
Semyon Proshev 1f898d43af Remove PyStringExceptionInspection and PyWrapInExceptionQuickFix as no longer relevant for supported python versions
GitOrigin-RevId: 9718219e670d2fe0a8e7c710f9c789c9b8f25dd9
2021-04-30 10:35:10 +00:00
Semyon Proshev fbadbbc40d Sync with typeshed @ 2c8cb605961bf76a88f9c21624893e4368ac3638
Temporarily exclude https://github.com/python/typeshed/pull/4987
Temporarily exclude https://github.com/python/typeshed/pull/5206 from `collections/__init__.pyi`

GitOrigin-RevId: 78775cc6c09fd8d867d8f46bf9908bd5cdbb05f6
2021-04-28 00:06:58 +00:00
Semyon Proshev 56a1c00c2a Make python-latest project descriptor default in tests
Update test data and reduce manual language level setup

GitOrigin-RevId: d6ddec1b2b29a2b7f1a34cfb5982fd975de78d65
2021-03-15 17:33:04 +00:00
Semyon Proshev 2465b8a67d Enable pyi stubs for several modules (PY-41509, PY-46229)
_ast, _dummy_thread, datetimerange, dummy_thread, dummy_threading, formatter, jwt, platform, string, thread

GitOrigin-RevId: a8010a0bd2381712599be0f96b35ce74e3e0c7d2
2021-03-03 22:46:06 +00:00
Mikhail Golubev 55e52c42b6 PY-46361 Don't suggest stubs from legacy python-skeletons for auto import
GitOrigin-RevId: ec56e579d0240cb03b2f16bb468b7a1be6a95762
2021-01-08 16:51:06 +00:00
Mikhail Golubev 4ca188384d PY-46358 Add the actual "as" part to local imports for common package aliases
GitOrigin-RevId: ad1061472e98c66ce3abc0e6d5e633ab271c2b41
2021-01-07 17:25:43 +00:00
Mikhail Golubev 6f5997ee45 PY-46356 Suggest qualified import names for common aliases
I moved the custom index lookup, previously used in PyImportCollector to find
modules and packages, to PyModuleNameIndex, already utilized in other similar,
places such as PyModulePackageCompletionContributor. Two new methods where
introduced to the interface of PyModuleNameIndex for that. The first one
is a generalization of  find(), allowing to re-use an existing search scope, and
the second finds modules by their fully qualified name in the same fashion as
it was done in PyClassNameIndex.findClass().

GitOrigin-RevId: 2de5821351eacf08ddc045454eea189b21fa1186
2021-01-07 17:25:41 +00:00
Mikhail Golubev 8e53b39d77 PY-36374 Exclude subpackages such as "numpy" from suggestions for common aliases
GitOrigin-RevId: 057d139dbe331154f5c4d0106d0e3564d9eda0b8
2021-01-07 17:25:39 +00:00
Mikhail Golubev 3ba2747c51 PY-36374 When suggesting imports, don't shadow package aliases with namesake definitions
Previously, we suggested variants for these well-known aliases only if no
other symbols were found. In particular, having "np" name defined in the
sources of pandas prevented "import numpy as np" from being offered.

ImportCandidateHolder had to be refactored a bit to keep the name of
the corresponding symbol itself, because it used to be taken from the parent
AutoImportQuickFix, which now only holds the name of the reference, and, thus,
"numpy" ended up being imported as "import np as np".

Also, such imports are now suggested higher in the list than the rest.

GitOrigin-RevId: 75bed654431e81e6df40f1400ee4b02a4ab0dcca
2021-01-07 17:25:28 +00:00
andrey.matveev 3b99571638 PY-28782 Fix remove assignment expression target inspection for multiple targets
(cherry picked from commit 2a8862d459955a23def7941229007e26d076c54e)

IJ-CR-4054

GitOrigin-RevId: 0068c0195a89e2272e9c632acc5494ea7ff0b120
2020-12-17 12:54:21 +00:00
Irina Fediaeva 0f6abfba6a PY-44918: Fix resolve path in existing user file instead of the os.path
GitOrigin-RevId: cca701106e1c558a50ed61b85efc312ff9205b1c
2020-12-01 19:44:00 +00:00
Mikhail Golubev de08c2a947 Fix Python tests after the proofreading
GitOrigin-RevId: 2f6eb873d6321ef00d293377ec2c97195f72da21
2020-11-30 22:17:55 +00:00
Semyon Proshev feed56de02 Sync with typeshed @ 10d3c6c325090172d5dc1cb99c5ce8a9319d88b2 (PY-41509, PY-41510, PY-44819)
Enable stubs for contextlib, cprofile, fractions, keyword, pipes, pkgutil, typed_ast, zoneinfo.
Skipped several `__init__` to `__new__` changes in builtin classes.

GitOrigin-RevId: dad913f67c69396d0db2d5e550254535713ea2f3
2020-10-19 21:15:33 +00:00
Semyon Proshev 860672992e Add language level for Python 3.10 (PY-44857)
Additionally several mandatory python versions have been aligned in FutureFeature.

GitOrigin-RevId: bfeba8d465c593c1000ed0f5226a4ab2a918a2bf
2020-10-16 12:24:27 +00:00
Mikhail Golubev 0adac7f9ea i18n: Add initial support in PyCompatibilityInspection
All its warnings are extracted into the bundle, but they are still poorly
adapted for translation. Each of them in constructed from two separate
messages, a common prefix and an individual feature description, with negation
of the main verb being split. Only the first message can vary depending on
the affected versions number, but both parts of the verb need to agree in many
languages other than English. It's not clear how to address it without
overhauling inspection internals, thus it will be revised later.

I also slightly updated the warnings format. Namely, put "version" in plural,
if a warning applies to multiple Python versions, and removed trailing periods
from single-sentence messages.

GitOrigin-RevId: 51e577201b11fb4e8b6967e1f5ad27143ba9f82e
2020-08-19 14:22:06 +00:00
andrey.matveev 973e8d2a1b [PY-17901] Fix deleting code with side effects
GitOrigin-RevId: 099724adfd94a160e9a40df78dd621ca4f8f18e6
2020-08-17 11:13:32 +00:00
andrey.matveev 0b083cae06 [PY-32037] Fix deleting whole statement if generator iterator unused
GitOrigin-RevId: 28dc01d526b31ecc99f2137f4cfda6183a90bf49
2020-08-14 10:20:08 +00:00
andrey.matveev 965121e9dc [PY-26418] Fix removing whole with statement if target is unused
GitOrigin-RevId: 217ee91cebf600fa0035c2534d1b00878cf41858
2020-07-21 10:42:32 +00:00
andrey.matveev 49c99c9577 [PY-20893] Fix removing full block by quick fix unused local variable for exception
GitOrigin-RevId: a518e1edee1c52543e9059e98439573770bc746b
2020-07-13 12:39:38 +00:00
andrey.matveev abc2894e1d PY-21284 Fix add field quick fix with constructor with type annotation
GitOrigin-RevId: dc57a492cd7d7dff4ef856b488678778fea56d34
2020-06-26 19:36:44 +03:00