Commit Graph

327 Commits

Author SHA1 Message Date
Morgan Bartholomew
7ce9158c26 [python] refactor stub suggestions to use PythonPackageManager
(cherry picked from commit d370e9fb005f850246a377ae10e4e87ba924efbd)

GitOrigin-RevId: aea57ce2819119f7f8cb877def6f13a65dc5e754
2025-07-16 12:11:36 +00:00
David Lysenko
ffa6c4c9e9 [pycharm] PY-79081 Fix working dir initialization for uv plugin
GitOrigin-RevId: f2f0c738c4eafc3e04be680b8d6ece59ca447a6e
2025-07-09 13:53:14 +00:00
Ilya.Kazakevich
cd9fd36b44 PY-81939: Do not show the full log on exec error dialog.
`PyError.message` contains the full log: all `orReturn("some text")` messages.

While they help user sometimes, some of them duplicate otuput and mustn't be displayed two times.

GitOrigin-RevId: 9a726cfcc8cb6b23825adc5d7dd505e1b8afd9c2
2025-06-14 03:52:50 +00:00
Ilya.Kazakevich
105554c91d Python: introduce getOr("message"){} API to add errors on an appropriate level.
See `getOr` extension doc.

GitOrigin-RevId: 859af221e99f03b99ee2f82e829e83e0f00a9e6d
2025-06-07 22:05:56 +00:00
Ilya.Kazakevich
2e14347844 Python: extract python-specific extensions from exec service to simplify API and make it extendable for intepreters.
Use `ExecService` `api.kt` to exec any binary and extensions from `execService.python/api.kt` for python-specific things (i.e helpers)

GitOrigin-RevId: bb217798a9d1ee886c4b12220ec1f66a5ef08336
2025-06-07 22:05:56 +00:00
Vladimir Krivosheev
65fe061584 IJ-MR-162467 don't export intellij.platform.analysis
GitOrigin-RevId: fcbcb68010b58cb507fee2c47473758b999e471b
2025-06-04 11:16:33 +00:00
Vitaly Legchilkin
50995c2812 [python] migration from kotlin.Result to python.PyResult in package managers (PY-81238)
* introduce PyResult.localizedError() (instead of failure()
* get rid of obsolete kotlin.Result.failure(..) extension
* add errorOrNull to python.Result, to access it from Java classes

Merge-request: IJ-MR-163973
Merged-by: Vitaly Legchilkin <Vitaly.Legchilkin@jetbrains.com>

GitOrigin-RevId: 2bd8336cf4c53170eea5d050f609fd64541ebd99
2025-05-27 07:18:45 +00:00
Nikita.Ashihmin
ebaf7afd67 PY-81238 Packages: add space for better format
Signed-off-by: Nikita.Ashihmin <nikita.ashihmin@jetbrains.com>

GitOrigin-RevId: 8ad78f68d857afc9f00bc77009b631522900c25e
2025-05-19 01:36:51 +00:00
Ilya.Kazakevich
6bf17f551a Python: introduce PyExecResult as an alias for Result<T, ExecError>.
It is just more convenient to right less generic params.

GitOrigin-RevId: cd33be23da4bb3cb09658aa6564e4d298a3ba72d
2025-05-14 20:47:57 +00:00
Ilya.Kazakevich
01754edfcb Python: drop unused, deprecated symbols.
Still used symbols are in `DeprecatedUtils` now to be dropped later

GitOrigin-RevId: 550eab3d417185b868072b06101bf7634263b4a2
2025-05-12 18:17:00 +00:00
Ilya.Kazakevich
11c31cfde7 Python: refactor ExecService to get rid of ProcessOutput and better support interactive execution.
1. `ProcessOutput` is a legacy thing with some redundant flags: replaced with modern `EelProcessExecutionResult`.

2. There was a bug in `ProcessInteractiveHandler`: one could fetch all data from stdout, and we then did that again to get a result. That leads to an empty result. It is now fixed, see `executeInteractive` doc.

GitOrigin-RevId: 7fa57f8110a202a32a3531ff6507d42a270075a3
2025-05-08 23:32:15 +00:00
Ilya.Kazakevich
5eac555264 Python: add mapError to Result
GitOrigin-RevId: 4fc242454dc016fdc84d0f2ce4937f13e1b0fc2b
2025-05-08 22:43:34 +00:00
Ilia Kirianovskii
1a2088f2c7 [bazel] Update build files
GitOrigin-RevId: 7c67cec8f9c7bb49918dec997484b7d24431e564
2025-05-01 18:01:00 +00:00
Ilya.Kazakevich
0d1edf1017 ExecService clean-up, add eel-test.
`Command` was a mistake: we should use `Binary` but with the ability to resolve it.

GitOrigin-RevId: 5151c6131af0338ea919d650c317cd9b88baeb12
2025-05-01 16:38:08 +00:00
Ilya.Kazakevich
43618513c0 Python: make runExecutable interface return the only error it can return
GitOrigin-RevId: 30f11900a7bf1085c405d92e6f58f771ed1c9004
2025-04-30 14:02:00 +00:00
Vladimir.Koshelev
67594cdaad [pycharm] finish community migration to v2
# Conflicts:
#	community/python/pluginCore/resources/META-INF/plugin.xml

GitOrigin-RevId: e4d6969fd15a3fddc4d6a03491fb9f9634285edf
2025-04-30 10:08:56 +00:00
Ilya.Kazakevich
1d8be676cd Python: Migrate runExecutable to ExecService + PyResult
GitOrigin-RevId: 4e76993685f02f90cb2e4d0d8e8384aa47102eb9
2025-04-30 00:56:41 +00:00
Ilya.Kazakevich
60420e1175 Python: unused symbols removed
GitOrigin-RevId: 9847e831bcc3535fb2cc65f15567ea5ea8abe0ac
2025-04-29 15:04:39 +00:00
Ilya.Kazakevich
803e270d45 Python: refactor PyError hierarchy, migrate to PyResult.
DO:
For upper-level (public) API use `PyResult`.
(Optionally) for low-level APIs inside your modules use python `Result<S, E>`.
Represent errors as `PyError` whenever possible.
Report `PyError` to `ErrorSink` at the top of your code.

DON'T:
Use `kotlin.Result`
Use `PyExecutionException`
Use any exception to represent user errors.

GitOrigin-RevId: 4ecf69e1fae8be9192cd33b90e0147c725a98964
2025-04-29 00:43:56 +00:00
Aleksandr Sorotskii
6030f18c30 cleanup package name normalization; PY-79870
GitOrigin-RevId: cfc8e220df5d7a2a33b2c027bbf37a7d5055ffc5
2025-03-25 21:27:18 +00:00
Timur Malanin
a7bdd63a2e PY-54850 Normalized package names in PyPackageRequirementsInspection for consistent matching and refactored requirement satisfaction checks. Unified normalizePackageName logic. introduced a test to verify that requirement mismatch warnings disappear upon package installation.
GitOrigin-RevId: edb02fa9c575b3cc51d95bbe21bf5cd2f0d25cba
2025-02-27 16:12:15 +00:00
David Lysenko
a782da7be5 [pycharm] PY-78648 Resolve uv correctly on windows
GitOrigin-RevId: f280a79ce566d43682fd77da735d037fff2e9ed3
2025-02-17 13:58:20 +00:00
Vitaly Legchilkin
d1bac97eb8 [python] ExecService / PyError adjustments (PY-60410)
+ replace processDescription and timeout fields with ExecOptions
+ add workingDirectory and env variables to exec options
+ support ProcessOutputTransformer for cases when both stdout/stderr and custom error handling is needed
+ make PyError classes open to have custom business errors

GitOrigin-RevId: 99c969e730cdbf23df4c9b176a43f78ede43001a
2025-02-12 21:19:30 +00:00
Leonid Shalupov
e4e5753846 housekeeping: remove unused imports
GitOrigin-RevId: ccba6d05260f5eb551ffa87e0d8a38dc93148a3a
2025-02-04 11:00:15 +00:00
Ilya.Kazakevich
6b6658fbc9 Python: make system python service available from community.
We make it a part of PythonCore module to use it from community

GitOrigin-RevId: ea6b00b6ac1a24478f9ff74cb34beffab0942089
2025-02-03 22:07:16 +00:00
Aleksandr Sorotskii
e0e9e611a6 support for listing uv provided pythons PY-77537
GitOrigin-RevId: 7003a66ba729d7565c1cf876198d85d45d025659
2025-02-03 17:10:53 +00:00
Ilya.Kazakevich
69d4f52dbb Python tests: move venv test fixture into a separate module
We finally decouple test framework from community impl

GitOrigin-RevId: 87178107f2fe785d295aca4cb46527634f465f90
2025-02-02 21:05:54 +00:00
Vladimir Krivosheev
b8245e1370 IJ-CR-146078 update bazel files
GitOrigin-RevId: 3bcfd10f71c84283bded464e142ead99edc6a278
2025-02-02 15:20:11 +00:00
Ilya.Kazakevich
dafe83d2c7 Python: temporary hack: Move SPP to community to break cyclic dependency.
Will move it back soon.

GitOrigin-RevId: b2f032dbc9926b2e23c0438d2ce522985c7a6ad4
2025-01-30 17:45:52 +00:00
Ilya.Kazakevich
eab4466488 Python: move VirtualEnvReader out of psi-impl module
GitOrigin-RevId: c4d7bd0bf0c5592b13a2ccffcd217c1bae819637
2025-01-29 21:40:40 +00:00
Ilya.Kazakevich
4678462b27 Python: move PyError and ErrorSink into api to reuse it in modules
GitOrigin-RevId: 44eeac6d4a44a4ce095a1b4aed1cccca61a4efbb
2025-01-29 02:33:56 +00:00
Ilya.Kazakevich
0ef4f9cb65 Python: extract venv var to reuse it between modules
GitOrigin-RevId: d04c02a9cab979b86a2b97a13edc834f883025be
2025-01-28 04:12:03 +00:00
Vladimir Krivosheev
97eb8081ed update bazel files
GitOrigin-RevId: fc8f02d9532ef4f014925f793434e9b0bcfd9317
2025-01-26 19:04:16 +00:00
Ilya.Kazakevich
d1b441d0bb Python: Replace localized string class with string with annotation.
No need to have a separate class

Signed-off-by: Ilya.Kazakevich <ilya.kazakevich@jetbrains.com>

GitOrigin-RevId: 9af33f30bbab9a85609c0c6536cb3120347fa20b
2025-01-24 02:02:40 +00:00
Ilya.Kazakevich
6b4fabf59a PY-78649: Migrate to Result with PyError (first steps).
`com.jetbrains.python.Result<Something, PyError>` is supported by `com/jetbrains/python/util/ErrorSink.kt`

The idea: if your function executes some external command, return an error as the aforementioned class. `ErrorSink` will display it nicely.

GitOrigin-RevId: d8a7d6997a9aded91691dbb531c3d4286de85f15
2025-01-23 04:42:24 +00:00
Ilya.Kazakevich
ca2148932f PY-78649: Improve error handling.
There were three problems:

1.
There was `PyExecutionException` with an optional message which was intended to be displayed via dialog using a message as a title.
It breaks an exception contract (code that isn't aware of this particular class should still be able to fetch info, and a message is usually blank).

2.
Moreover, `ErrorSink` wasn't aware of it either and displayed it as a plain text.

3.
`PyExecutionException` didn't distinguish between "process can't be started" and "process died with error code != 0". Those are different cases.

This change:
1. Fixes `PyExecutionException` for 1 and 3.
2. Introduces API in `ErrorSink.kt` to display `PyExecutionException`

GitOrigin-RevId: a8d835afb086b23c73ced15f243d2b27b59dcf82
2025-01-22 23:07:52 +00:00
Ilya.Kazakevich
4b22bc0b72 Python: add method to Result to simplify migration
GitOrigin-RevId: 05983eae9d6e6f4047d62abdd690d3bc80d2b2da
2025-01-22 22:18:20 +00:00
Vladimir Krivosheev
0bc1cf1557 update bazel files
GitOrigin-RevId: 7320d3eff3aba093692ce66839c720ece6d7c4db
2024-12-30 11:28:24 +00:00
Vladimir Krivosheev
7b9ec58009 do not export intellij.database.connectivity.tests
GitOrigin-RevId: a1ef44dfa34cde110c9e6cad19d11b5e3019ab72
2024-12-28 21:45:55 +00:00
Vladimir Krivosheev
68d99c6550 cleanup
GitOrigin-RevId: 9cb238c220249088bfc75a448eb310b93c7fc45c
2024-12-26 14:56:01 +00:00
Ilya.Kazakevich
6f0f9cc8eb Python: move PythonBinary to reuse across the modules
GitOrigin-RevId: 4e79a8fd330e95eca09d81386ab6e143f8ad2c4a
2024-12-17 20:01:59 +00:00
Ilya.Kazakevich
9f37594a1f Python test: move test to module with code as PoC that tests can be accessed via cross-module deps
GitOrigin-RevId: 7819273fccb719ea065611f3f2e26bf3f13fe558
2024-12-17 19:38:33 +00:00
Vladimir Krivosheev
98799639aa do not use _test as lib - test targets do not support this
GitOrigin-RevId: f2f49db4294b6a64040dbbd5f1d95e972cbd70a3
2024-12-15 18:32:30 +00:00
Ilya.Kazakevich
6398eecad3 Python: mark old API deprecated
GitOrigin-RevId: c579d6fbd17f0006c1270d3f6536312e4310fcdf
2024-12-02 18:43:50 +00:00
Vladimir Krivosheev
17916c90f8 libraries -> lib, resources, opt-in, test deps
GitOrigin-RevId: db66ee95dcb0f0553b40c9cc56cd6afed8634cdd
2024-11-27 13:53:42 +00:00
Ilya.Kazakevich
e271220bac Python Result: create aliases to simplify migration from kotlin Result
GitOrigin-RevId: 64b9ad7f1d458253c7d43bef74bef9f8fd88f697
2024-11-13 19:24:52 +00:00
Ilya.Kazakevich
842895c01e Python Result: orThrow throws ERR if ERR is exception: no need to wrap it
GitOrigin-RevId: 39cf9b43268be1a02b7bc54fc08bbb37881faabf
2024-11-13 18:03:50 +00:00
Konstantin Nisht
a2982b95da Refactor Python Result to simplify getOr{ return it }
With `Nothing` we can replace `getOr{ return it.convertErr() }` with `getOr{ it }`

GitOrigin-RevId: 5aad2e455f02899b87975366205d7e3bb2b425a0
2024-11-11 23:32:33 +00:00
Ilya.Kazakevich
20bf407b28 Python: Result documented, show cases added
GitOrigin-RevId: 0acfe32c2db90a3e2dbe58e4b087d581d82ea23a
2024-10-24 19:44:26 +00:00
Ilya.Kazakevich
f72d7f04b6 Python: Various Result improvements
We still use it, because Kotlin result only supports `Throwable`

GitOrigin-RevId: b66d4cd8382174829bb8027e8384780a7b2b1198
2024-10-24 14:18:08 +00:00