Commit Graph

6262 Commits

Author SHA1 Message Date
Mikhail Golubev
0d34a0e88f PY-59594 PEP 701: Make the intention for flipping string quotes aware of the syntax
(cherry picked from commit a62f78cfdee24eccf3fcf2d341807565f26d2fbd)

IJ-MR-115763

GitOrigin-RevId: 059a289a9006d592a88a677137647c0660c68fc2
2023-09-29 09:33:49 +00:00
Mikhail Golubev
b3351b941e PY-59594 PEP 701: Stop recovery of incomplete f-string fragments at statement-only keywords
(cherry picked from commit 7aa912a43d63f6c9867d772e120c5b45adb10be3)

IJ-MR-115763

GitOrigin-RevId: ca6909a8e7a59e06eae69b631160e4d48541ce58
2023-09-29 09:33:45 +00:00
Mikhail Golubev
37d25ee815 PY-59594 PEP 701: Allow quote-reuse and line breaks inside f-strings. Keep reporting these problems for Python <3.12.
PEP 498 required f-strings to be recognizable by existing tooling, such as syntax highlighters,
by prohibiting re-using quotes of the same kind and having line breaks inside expression fragments.
We used to detect these problems already at the lexer level, correctly replacing violating quotes
with FSTRING_END token, and appending STATEMENT_BREAK tokens to illegal line breaks inside expressions,
depending on the lexer's state. Now, thanks to a general f-string grammar in PEP 701, most of this
bookkeeping could be moved from the lexer to the CompatibilityVisitor (to still be reported
for previous versions of the language and by the compatibility inspection).

Previously forbidden backslashes and line comments are now also detected by the CompatibilityVisitor
instead of the version-agnostic FStringAnnotator.

One side effect of the new grammar is that parser recovery in pre-3.12 version of Python became
slightly worse. For instance, something like `f'{foo'` used to be recognized as an f-string
with an incomplete fragment lacking its closing brace. Now, it's parsed as an incomplete
f-string, lacking its own closing quote, containing an incomplete string literal inside
an incomplete fragment. What's more, parsing of this fragment's expression doesn't terminate
until the end of a file, because STATEMENT_BREAK is never produced by PythonIndentingProcessor
while it's inside an f-string fragment, and every quote is considered a new string literal.

Examples of parsing tests affected by this are:
PythonParsingTest.testFStringFragmentIncompleteTypeConversionBeforeClosingQuote
PythonParsingTest.testFStringIncompleteFragmentWithTypeConversion
PythonParsingTest.testFStringIncompleteFragment

I also had to simplify some scenarios from PythonHighlightingTest, removing snippets
with incomplete fragments or moving such examples to the very end of a file.

It's not clear how to handle these situations not overcomplicating the lexer.

(cherry picked from commit 03ba6d7fba1b45a84aa92221e6a452645a765205)

IJ-MR-115763

GitOrigin-RevId: cd36470d9cae353fe3caeb2d3b628d8743b46cbb
2023-09-29 09:33:42 +00:00
Daniil Kalinin
9249e0a15c PY-61856 PEP 695 Type Parameter Syntax: Code compatibility inspection and unsupported features annotator
GitOrigin-RevId: 164a07daff1059ac1a421e1a883168924f82559e
2023-09-28 15:05:34 +00:00
Daniil Kalinin
65cc3ddfd0 PY-61877, PY-61878 PEP 695 Type Parameter Syntax: Control flow for type parameters and type aliases
GitOrigin-RevId: 2db381cbb97891296bae09e48c17b46eefa57a04
2023-09-28 15:05:31 +00:00
Daniil Kalinin
1c5b0c5ac3 PY-62608 PEP 695 Type Parameter Syntax: PSI stubs for type parameter lists and type aliases
GitOrigin-RevId: b8707b4677519bab5bcf922c9747eb8388e3157b
2023-09-28 15:05:30 +00:00
Mikhail Golubev
a639a793c6 [python] Better failure messages for Python lexer tests
GitOrigin-RevId: d73a4cd02768912098206ea8fbc1b77973fe97db
2023-09-28 11:39:15 +00:00
Vladimir Koshelev
60090602b4 [python] treat as bool type guards in return types PY-62476
GitOrigin-RevId: 0b59fd99aeaece087837858fb13376370d0d225b
2023-09-19 12:11:20 +00:00
Vladimir Krivosheev
b67de4a4b0 IJPL-238 remove the unnecessary usage of commons-lang library (part 3)
GitOrigin-RevId: dec81af8deb5d9b396e9150538bdca1d951b1d80
2023-09-15 20:50:02 +00:00
Daniil Kalinin
3a70f1d22d PY-61854 PEP 695 Type Parameter Syntax: Formatting
GitOrigin-RevId: 272f956033d82626d7cf689aa561cdeab3f951da
2023-09-15 16:04:46 +00:00
Daniil Kalinin
4b6848cb9f PY-61855 PEP 695 Type Parameter Syntax: Highlighting
GitOrigin-RevId: 498ab5e3a697c2eb616ae3d0820f99c480596306
2023-09-15 16:04:43 +00:00
Daniil Kalinin
8b217ed53a PY-61853 PEP 695 Type Parameter Syntax: Parsing
GitOrigin-RevId: 286b53bb4e69cf1deb58dc75f41652e6a12a3af3
2023-09-15 16:04:41 +00:00
Daniil Kalinin
067452815f PY-20861 Python support with the Move Element Left/Right feature
Merge-request: IJ-MR-111447
Merged-by: Daniil Kalinin <Daniil.Kalinin@jetbrains.com>

GitOrigin-RevId: a4fbe9d1a8634a7ad8f0893266e26738be993cea
2023-09-15 11:11:04 +00:00
Vladimir Krivosheev
125c41869b IDEA-332023 cleanup
GitOrigin-RevId: bae557ac0e0a4ef66918cb6c1d0118b6f0dcf615
2023-09-10 18:20:42 +00:00
Bart van Helvert
a60df36d06 Make tests that shouldn't be runnable abstract
GitOrigin-RevId: dbab3037050ef932897675781949e86dd05bce40
2023-09-10 16:40:07 +00:00
Dmitry Batkovich
93b4bab1e0 deprecate FileBasedIndex#scheduleRebuild
GitOrigin-RevId: 8935eadcf5129cbf599acb88b8721ababf08821b
2023-09-07 16:57:06 +00:00
Egor.Eliseev
fbf14c190d PY-43327 Add parameters to doctest configuration
Remove pydev warning if old trace function equals to new one.
Add argparse for `docrunner.py`.
Add tests for `doctest` with parameters.
Add debugger tests for `doctest` with parameters.


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

GitOrigin-RevId: 608080b3b5db93718f62a3dddd17893fe8118539
2023-09-04 13:18:44 +00:00
Egor.Eliseev
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
Egor.Eliseev
78c09fe774 PY-59189 Renaming parametrized fixture argument does not rename literal
Add PyTestParametrizedContributor that handles renaming the test function parameter and renames the decorator's `@pytest.mark.parametrize` argument

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

GitOrigin-RevId: e544298036603462379adcf7a452e65c22e002f6
2023-09-01 15:20:55 +00:00
Egor.Eliseev
bd1b43401c PY-36696 Add caret movement for the Python Console
When a user calls `Previous Entry in Console History` action, move the caret to the end of the first line

IJ-CR-111281

GitOrigin-RevId: a351f264722b74c89692963ead0467250ac01a68
2023-08-30 16:01:10 +00:00
Andrei.Kuznetsov
4d2ae3adfa IJPL-158: Move test-only runInDumbModeSynchronously and computeInDumbModeSynchronously to DumbModeTestUtils
And re-implement them using public DumbService API

GitOrigin-RevId: 71c350df1b606fda9158187d537453d4daa006ac
2023-08-27 09:59: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
Andrey.Matveev
b3463bd84c PY-60848 Fix order in getIteratedItemType get type from __next__ first
Changes in typeshed:
1) intellij repo: f7bacdc0
2) typeshed: a094aa09c2/stdlib/builtins.pyi (L1207)

Now Self became enumerate[T] instead of Iterator[tuple[int, _T]] and necessary to take __next__ to take tuple[int, _T]
Also, add check for typing.Awaitable[T] in __next__ return type and unbox T in cases like
```
async def asyncgen():
    yield 10
[i async for i in asyncgen()]
```

GitOrigin-RevId: 05453fcfcf8a212ff73665a7df8f67ccdc1e4603
2023-08-24 17:36:07 +00:00
Andrei.Kuznetsov
ddb58bd9e5 IJPL-158: Migrate (trivial) "community" tests to runInDumbMode/computeInDumbMode/runInDumbModeSynchronously
This commit removes usages of deprecated `DumbServiceImpl.setDumbMode` and replaces them with modern API.

GitOrigin-RevId: d3fa0e8eec04d7b10a0b98ff46c2f4bb5a8197b9
2023-08-21 21:51:19 +00:00
Egor.Eliseev
85f315a921 PY-61231 DeprecationWarning pkg resources is deprecated as an API
Use `importlib.metadata` for the new Python versions (>= 3.10).
Ignore `DeprecationWarning` for old versions of Python.


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

GitOrigin-RevId: a639ae84016a85d508484e31e48913543d4e51f1
2023-08-21 09:55:07 +00:00
Egor.Eliseev
130740bbf0 PY-61613 Turn on static code completion for Python Console by default
Change setting CheckBox to ComboBox

IJ-CR-110807

GitOrigin-RevId: 911407a78a5f444a81315dbca3e92d916b4abf30
2023-08-18 14:08:46 +00:00
Egor.Eliseev
c368c2f4f1 PY-48235 Add quoting policy for PyXCopyValueAction
IJ-CR-110671

GitOrigin-RevId: 768a88b91943de9dcab5c5023073c82c5f8c93d7
2023-08-18 12:11:01 +00:00
Egor Eliseev
edd05b77c0 PY-37668 Copy full value from Variable view
IJ-CR-110411

GitOrigin-RevId: f2daf5ff2aea1c94acf2e796db02efd121655a99
2023-08-17 17:02:52 +00:00
Mikhail Golubev
63d24cbb9d PY-34493 Enable back copying annotations from third-party .py files on Override/Implement
Since disabling turned out to be controversial. Even in the ticket some users were
against this decision claiming that it heavily annotated code bases it might be necessary
to retain all annotations from inherited method signatures. We need to think of a better
solution for controlling this behavior on case-to-case basis.

GitOrigin-RevId: c68763f0cad23de8975085e9bc8a6fd99013de3b
2023-08-09 20:53:35 +00:00
Mikhail Golubev
c7bba04743 PY-45588 Generalize PyOverrideImplementUtil.addImports to cover parameter defaults
GitOrigin-RevId: 828305e2a7449704c08503d8d68394d28ce98c83
2023-08-09 20:53:35 +00:00
Mikhail Golubev
a7a54e1152 PY-34493 Don't copy annotations from .pyi stubs and libraries on Override/Implement
GitOrigin-RevId: 7e40d4a520d46ad65a31ee5898af89ad870dc6c3
2023-08-09 20:53:35 +00:00
Mikhail Golubev
fbfaf24bc3 [python] Make PyOverrideTest work with the latest Python 3 by default
GitOrigin-RevId: fd44fa8ca8a0f3eed2b710a65225979569023d3f
2023-08-09 20:53:35 +00:00
Mikhail Golubev
250ee7e314 [python] Unify the test logic in PyOverrideTest
GitOrigin-RevId: 3e0d896c8e904996828364e1d29e1c39472f7e79
2023-08-09 20:53:35 +00:00
Mikhail Golubev
88da33b182 [python] Define a test data root for PyOverrideTest
GitOrigin-RevId: 0f77722768215515c5fd2b6c3fbd5c025bb902ba
2023-08-09 20:53:34 +00:00
Mikhail Golubev
69219902f3 [python] Reformat PyOverrideTest
GitOrigin-RevId: 7af5086bc76ca3dce99546d4e487b934849c9fe8
2023-08-09 20:53:34 +00:00
Ilya.Kazakevich
7bf11d3b6f Disable python2 for jupyter tests: jupyter can't be installed on py2
```
ERROR: No matching distribution found for comm>=0.1.3 (from ipywidgets->jupyter)
```

There is no 2.7 in the latest analysis

GitOrigin-RevId: 170b98f048b88a62d2695d375b780ee707e79330
2023-08-04 23:46:44 +00:00
Ilya.Kazakevich
2bb2ea60fc Various validation refactorings
`readableFs` is redundant and unstable. Remove it: we will migrate to ijent anyway.
All validations are in `PathValidator.kt` now. They are used by `ManualPathEntryDialog` and sdk validation.
Lots of thread annotations added to prevent calling validation code from EDT.

In general, this change makes path validation ready for ijent: validation based on nio with slow IO access.

Validation is removed from old, non-target classes

(cherry picked from commit 185b4f7fe8cbd5d7a37dad609c8a4cb8163d6eed)

IJ-MR-112281

GitOrigin-RevId: 12c4a4f3d459d0523ef6694a9e4bb2db7a1582b7
2023-08-04 13:42:38 +00:00
Vladimir Koshelev
7aeb74fe0a [PY-49040] add support for TypeGuards
Merge-request: IJ-MR-109904
Merged-by: Vladimir Koshelev <Vladimir.Koshelev@jetbrains.com>

GitOrigin-RevId: 8441ce35b2fc97fb0cdaf747feff2cf9ba3347ea
2023-08-02 22:27:54 +00:00
Sergey Karpov
c0842a6fde [pycharm] Squashed commits. PY-52478 Improve the names of quick fixes for "Unresolved references" and "Non-optimal list declaration"
(cherry picked from commit bce089714657aef8634ffb9c58da57fdb576b297)

IJ-CR-112218

GitOrigin-RevId: 8857c2951e44a1e9d0b54af1eb7c584f64fbc40d
2023-07-31 16:31:00 +00:00
Ilya.Kazakevich
edb8edf72c increase timeout
GitOrigin-RevId: cce7baeaeac8f43dcdd5ebf377a7ae96d6796b6e
2023-07-27 19:51:59 +00:00
Ilya.Kazakevich
de70549f24 Fix PySDKRule for tests: path should point to python binary
GitOrigin-RevId: 6d35027a039ebeb603e254d88cd5e826b406266b
2023-07-27 19:45:35 +00:00
Ilya.Kazakevich
bc39172e97 Synchronize access to console in tests
GitOrigin-RevId: 81b588591e858fb9e2dd30c1681d6664bbd1b254
2023-07-26 21:35:54 +00:00
Ilya.Kazakevich
66baa2f76a [python tests] experiments: pregenerate pyc, get rid of useless sleep
GitOrigin-RevId: ff9a258059aba45c28c62b2d370464e2bb500599
2023-07-25 23:12:31 +00:00
Egor.Eliseev
7dafb6bea5 PY-61304 Add searching in import elements in "conftest.py" file
In addition to searching for fixtures as functions in the "conftest.py" file, add also searching in import elements.


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

GitOrigin-RevId: fe2832b23db8b5fda461b1e07a129975b2dd57bf
2023-07-25 06:23:01 +00:00
andrey.matveev
213b82bde3 PY-54905 PY-54620 PY-61740 Fix goto declaration and implementation resolved pyi not py
PyDefinitionsSearch.java: replace psi element on original element if it is from pyi and then search for overrides, inheritors etc.

PyiUtil.java: recursively get original element while it is in stub (see the comment) and tests testGoToImplementationNameReExportedThroughAssignmentInPyiStub, testGoToImplementationNameReExportedThroughAssignmentInPyiStubTwice

PyUtil.java: make different methods turnDirIntoInitPy, turnDirIntoInitPyi instead of only turnDirIntoInit to handle cases when the same directory contains __init__.pyi and __init__.py files (PY-54620)

GitOrigin-RevId: 8f0d8a8133548e1a9f52f93b42aa9cae2302e8d7
2023-07-24 14:30:11 +00:00
andrey.matveev
272da294c3 PY-9045 Fix false positive cannot perform refactoring when execution flow is interrupted
Delete targets condition in createCodeFragment and filter duplicates

GitOrigin-RevId: 474f3634a06c9cff25bafc94e1651d4fe61fb2a0
2023-07-24 09:26:14 +00:00
Mikhail Golubev
07cdec4e06 PY-53599 Enable PyTensorFlowTest env test on TC
GitOrigin-RevId: 45b60ff82ee8f1f9ddad9bd9b7246e65914cf392
2023-07-20 19:36:11 +00:00
Mikhail Golubev
9b4bd066fa PY-53599 Simpler env smoke test for Tensorflow module structure
Namely, test only against the latest version of the library. Check completion
only for a few common submodules of tensorflow. Check resolve for all of them
in one inspection pass, instead of resolving each separately. Generate expected
test data dynamically through module introspection.

GitOrigin-RevId: df5c4c4f765116bc7329454d5cc0b2aa1a6a86b5
2023-07-20 19:36:11 +00:00
Egor.Eliseev
ebf5d71eef PY-35529 Use repr by default in Variables View
1. If `__repr__` is overridden - use `reprlib` or `repr()`
2. If `__str__` is overridden - use `str()`
3. Use `reprlib` or `repr()` otherwise

IJ-CR-110917

GitOrigin-RevId: dff583d556600a8c77024a4d1bd86034f24f9bf9
2023-07-18 08:33:05 +00:00
Ilya.Kazakevich
2326177bc4 Test timeout increased: slow agents
GitOrigin-RevId: 74d9c96801e763fac0afd77f0fe50d3f1c498181
2023-07-17 19:40:23 +00:00