Also fixes PY-59014, PY-39761. PyResolveImportUtil returns both .pyi stubs and the corresponding .py files for stub packages to support partial stub packages. See the line: ``` groupedResults.topResultIs(Priority.STUB_PACKAGE) -> firstResultWithFallback(groupedResults, Priority.STUB_PACKAGE) ``` in PyResolveImportUtil.filterTopPriorityResults. It means that, for instance, resolving the QuerySet name in type hints led to QuerySet definitions from both places. Then, PyTypingTypeProvider.getType() for the reference expression "QuerySet" returned a union type containing PyClassTypes for both of them, we couldn't parameterize it in PyTypingTypeProvider.getParameterizedType and returned Any. It's wrong that while evaluating type hints, we interpret multiple declarations as a union type. Those should only be explicitly expressed with typing.Union or "|" operator. This behavior was originally added in PY-18427 as an ad-hoc way to support version checks for type hints, but now it seems detrimental because it's unclear how to parameterize such implicit unions of generic types then. Other type checkers also don't treat conditional definitions like that. For instance, for conditional type aliases, Mypy complains about the name being defined twice and then uses only the first definition, and Pyright doesn't consider names under conditions other than version checks as valid type aliases at all. Both type checkers also support partial stub packages properly. GitOrigin-RevId: 1ecc7ab5d09625d10850ddc0e1f7761332ccddd5
PyCharm Community Edition
The "python" directory in the source repository contains the source code of PyCharm Community Edition and the Python plugin for IntelliJ IDEA Community Edition.
Building and Running
The code is part of the main IntelliJ IDEA Community Edition project and is compiled together with the rest of the codebase. To run PyCharm Community Edition, please use the provided run configuration "PyCharm Community Edition". To run IntelliJ IDEA with the Python plugin, please use the "IDEA with Python plugin" run configuration.
To run the test suite, use the built-in JUnit test runner and run all tests in the "python-community-tests" module.
Building from the Command Line
To build the distribution archive of PyCharm Community Edition, execute build.xml Ant build script in this directory. The results of the build execution can be found at out/artifacts.
Building the Python Plugin
To build the Python plugin for IntelliJ IDEA Community Edition:
-
Download the .tar.gz distribution of the most recent EAP or release build of IntelliJ IDEA Community Edition;
-
Run the following command:
ant -Didea.path= -Didea.build.number=<build number of the build you're using> plugin
The .zip file of the built plugin will be placed at distCE/python-community-.SNAPSHOT.zip