Commit Graph

514 Commits

Author SHA1 Message Date
Mikhail Golubev
b023313048 EA-240096 Fix SOE when adding type hints for augmented assignments
It could happen when several augmented assignments are referencing
each over but don't have an ultimate target expression with a higher
resolve priority because of the CFG.

GitOrigin-RevId: 4e908f04103cc131ec48dca95a775406235228a5
2020-12-02 11:02:58 +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
Yann Cébron
66b0e41e9d PythonUnitTestDetectors.kt: fix KDoc
GitOrigin-RevId: 978f19d280e3b26b945878447fbc14980d76556d
2020-12-01 15:21:41 +00:00
Alexey Kudravtsev
f8c986128d replace long/erroneous strings in Logger.getLogger() with class reference for brevity, readabilty and maintainability
GitOrigin-RevId: f0db256fe8127e0f16b834d395525231d5f7ccdf
2020-12-01 12:52:22 +00:00
alla redko
21fd617dde IDEA-248847
GitOrigin-RevId: bb376e267543e459a630b5802399cd6c0467ddff
2020-11-30 22:16:31 +00:00
Semyon Proshev
28036fddc8 Don't run background task under write action (EA-233615, EA-246627)
GitOrigin-RevId: f82111b88643f8f82033b0d511e80e6f43733361
2020-11-26 13:51:30 +00:00
Vladimir Krivosheev
b15ed213b6 IDEA-CR-68974 unambiguous names when imported statically
GitOrigin-RevId: beed01f4c6a533fa694ec0b4f36e5d305b80874b
2020-11-26 10:48:08 +00:00
andrey.matveev
4580864d68 PY-45114 Fix import prioritizing for same directory elements
Now import elements from the same directory have priority in resolve
over other equally named elements in plain directories and other equally
named elements have priority over same directory modules in ordinary and
namespace packages.
In libraries, the same directory elements should not be resolved in import.

(cherry picked from commit 2b5103dae6ca3828eee7891be248acf99bc7eb56)

IJ-CR-3755

GitOrigin-RevId: 52161f5ba43415d3ceb2ce3dc2122832da2c6197
2020-11-25 16:44:48 +00:00
Ilya.Kazakevich
a94ea7ef34 Wrap sdkHome with class. There is a mess now: sdkHome is string and it is not clear if it is a path to python installation or binary file. This leads to misuse and test failures like "c:\python is not executable". Lets wrap it with appropriate class and add ability to search for installed binaries. By implementing this I fixed Jupyter tests on Windows, and it is now not possible to create broken one.
GitOrigin-RevId: 22e28fb047f9188c59753cbdd614658b34778cdc
2020-11-24 21:19:00 +00:00
Semyon Proshev
48a952a327 Make parser stricter for for statements and expressions (PY-36478)
Now it more follows original python grammar.

GitOrigin-RevId: 199f30b819c85a4eba5cab9b3f67fbf1bb7f18b6
2020-11-24 17:35:00 +00:00
Semyon Proshev
9335c066f5 Make parser stricter for assignment expressions (PY-33886, PY-36478)
Now it more follows original python grammar.

GitOrigin-RevId: f2b45554d16ff87d946950591f0e92fedcfdfaf0
2020-11-24 17:34:59 +00:00
Semyon Proshev
d96a172a6c Fix matching *args callable against one parameter callable (PY-44575)
GitOrigin-RevId: 851d3d53ff7232785032783fa8abd1b27b10938c
2020-11-23 19:37:16 +00:00
Vladimir Krivosheev
f6011fec8d remove unused trove library dependency
GitOrigin-RevId: 080cc3322ca0925166339c38dcf23849b5f16c0b
2020-11-23 17:34:22 +00:00
Semyon Proshev
042387052f Fix processing null resolve result (EA-246306)
GitOrigin-RevId: f2c2b6342b8818a410618d9a3cce94314e1b86d9
2020-11-19 09:51:58 +00:00
Semyon Proshev
aad1dff938 Make metaclass-related code more clear using annotations
GitOrigin-RevId: 9c9c8ab8e5683cf6edb8e17d40f8fa57b9267096
2020-11-19 09:51:57 +00:00
Vladimir Krivosheev
9308349e09 reduce usages of deprecated NotNullFactory
GitOrigin-RevId: 13aded593835b3a88e8fde8f27ea6120670279b9
2020-11-18 19:35:46 +00:00
Semyon Proshev
6fcdc21997 Support type inference for cls inside namedtuple's class methods (PY-30870, PY-33140, PY-45473)
GitOrigin-RevId: a299d681d20230acd9443f0fa37c7fd64a51d76a
2020-11-18 18:45:09 +00:00
Semyon Proshev
b017f822c2 Verify that PyFindUsagesHandlerFactory.proxy overrides all the necessary methods (PY-41790)
Leave comments in all related places to reduce possible regressions in the future.

GitOrigin-RevId: d4fbe3e75f67a1ec0f94e7a7ed6c58d2dbf6a1e7
2020-11-18 18:45:07 +00:00
Petr Golubev
1e0a48cb6c mv PySignatureCacheManagerImpl to intellij.python.psi.impl
GitOrigin-RevId: eb8f8dbe0db9396ba9339d605ce726e99062dc15
2020-11-17 16:45:17 +00:00
Mikhail Golubev
9590c3643e PY-45459 Make f-string like completion available after "{" on explicit invocation
GitOrigin-RevId: fe609b6a572f2ac971b2cf34eb92afe529708628
2020-11-15 16:10:47 +00:00
Semyon Proshev
0a6951352a Reduce code duplication in forEveryScopeTakeOverloadsOtherwiseImplementations
GitOrigin-RevId: 600e9b32781e24b0ab28da8cddc11c2f82f81562
2020-11-12 17:30:24 +00:00
Semyon Proshev
9dda7af81a Return rated results from PyCallExpressionHelper.resolveImplicitlyInvokedMethods
As a result code insight will be able to select top priority overloads
And navigation will choose top priority implementations

GitOrigin-RevId: 4c06039ed322eeab427decdcefdf5e1037e20387
2020-11-12 17:30:23 +00:00
Semyon Proshev
6bc9d4fb1e Use forEveryScopeTakeOverloadsOtherwiseImplementations in implicitly invoked methods and implicit results processing
Return list in forEveryScopeTakeOverloadsOtherwiseImplementations

GitOrigin-RevId: c3dddea449c393ce81e7e3e5bf00dc99ba94b443
2020-11-12 17:30:21 +00:00
Semyon Proshev
c19b6a98cc Performance optimizations in call expressions processing
GitOrigin-RevId: b651ccd9d9bbaed2357b274ae2b3fc033e4a770d
2020-11-11 19:30:39 +00:00
Semyon Proshev
cdf3989cc0 Don't consider reference as a descriptor if its type is a definition.
Fix AppEngineCompletionTest.testListProperty.

GitOrigin-RevId: fa3e4449d636b76666479ed4eb087ad7d6dee46e
2020-11-11 19:30:38 +00:00
Semyon Proshev
9207b888e9 Check if resolved element is also global as the element we're checking reference to.
Previously we looked for target element with fallback type eval context and resolved global statement received NORMAL rate and didn't filter out.
With code analysis context it receives LOW rate and is removed.
Fix PyRenameTest.testRenameGlobalWithoutToplevel.

GitOrigin-RevId: c8ecdff95c7dfff2e07a027adc9a4bf9e32a7ff7
2020-11-11 19:30:37 +00:00
Semyon Proshev
ca8d1827a7 Create type eval context based on file used for configuring project.
Fixture.getElementAtCaret goes to target that could be in another file.
And that target could run un-stubbing resolve. Check context constraints and stub presence in PyTargetReference.multiResolve as a result.
Fix PyiTypeTest.testInstanceAttributeAnnotation.

GitOrigin-RevId: f5f505dbcc8ef21aaeaa8edf275b513777924534
2020-11-11 19:30:35 +00:00
Semyon Proshev
fbbb78bc4e Change receiver for initialization calls and don't resolve callee to constructors
Callee is now a receiver for these cases, previously it was `null`.
Callee is not replaced with constructors to have an ability to map it onto self/cls parameters and process `(cls: Type[T], ...) -> T` annotations.
Stay with the previous behaviour for navigation and looking for target element.

GitOrigin-RevId: c0f9894cf50fd5d7fd325f095976d096fb948e89
2020-11-11 19:30:34 +00:00
Semyon Proshev
be15656e6d Move PyCallExpression.getReceiver implementation to its inheritors
GitOrigin-RevId: 3aa2361564964ed01e96cc72e2601d8d3793b154
2020-11-11 19:30:32 +00:00
Semyon Proshev
7aef8300b4 Reduce unnecessary resolve in type providers
GitOrigin-RevId: e870ae4e4f5ec206c2389c62f3d8f74c6ff824a3
2020-11-11 19:30:30 +00:00
Irina Fediaeva
1e8a086708 PY-35698, PY-33565: Delete obsolete PyCallByClassInspection. Type checker inspection covers most of the cases since there is always some type inferred for cls/self.
IDEA-CR-68591

GitOrigin-RevId: fef66f2e1e4d17de50fcca248a3ddc957f3c316d
2020-11-10 13:31:16 +00:00
Semyon Proshev
51e8ed79bb No more explicit highlighting types in type checker inspection (PY-44957)
And hence no more weak warnings for the cases with generics.

GitOrigin-RevId: 5413395e8eff8ab0a2b87ec0cce92902f4b9bedc
2020-11-05 19:27:29 +00:00
Irina Fediaeva
8acc4ecf8a PY-43915: Fix of incorrect arguments highlighting on weak union class method call.
IDEA-CR-68254

GitOrigin-RevId: aa76636854317e57a0225ab4a98114295777fa72
2020-11-05 08:23:38 +00:00
Mikhail Golubev
cf443d3061 PY-45115 Don't cache same directory import resolve results in Python 3
The cache of resolved qualified names is not context aware, so it's not safe to
keep such results in it. The legacy same directory imports in Python 2 have
already been taken into account and excluded, but we forgot to do the same for
recently enabled same directory imports in Python 3 project sources.

GitOrigin-RevId: f8885543ffa34ea652368a4f190210439173bdfc
2020-10-27 15:59:51 +00:00
Mikhail Golubev
5b650a5383 Make Python keyword completion dumb aware
It doesn't use indexes anyhow, and it's very inconvenient not to have it
available while they are being updated. It becomes especially noticeable with
"Idle Indexing" plugin that postpones the indexing on startup.

GitOrigin-RevId: 78dbe4399a38376ae519025e7bbe09906a7d0905
2020-10-22 17:22:28 +00:00
andrey.matveev
c5ae9550ce PY-42750 Allow same directory imports in Python 3 and introduce explicit namespace packages
There are 3 types of directories: plain directories, ordinary packages (with
__init__.py) and PEP 420 namespace packages. There are 3 types of imports:
absolute (from a root), same directory (absolute import from the current
directory when it's not explicitly marked as a root) and relative imports
(imports that start with dot).

Absolute imports are correct in all kinds of directories.
Same directory imports are correct in Python 2 in all cases and in Python 3 if
we have the directory containing the script with this import in Python path at
runtime. Users of Python 3 often face the problem when they can run the script
from the console because the directory containing this script got into Python
path but still have red underline and an unresolved reference error in the same
directory import because PyCharm didn't know that this file will be used as a
program's entry point. Previously, the way to fix such a problem was marking it
as a source root. But this action was not so obvious, especially for newcomers.
With this feature, such imports resolve successfully and now it is not necessary
to mark directories as source roots.

Relative imports are correct only in Python 3 namespace or ordinary packages and
should not be used in plain directories. If we have a relative import in plain
directory we highlight it with a weak warning and suggest 2 ways of fixing that:
marking directory as a namespace package explicitly (with quick fix or with Mark
As | Namespace Package) or changing this import to the same directory import
with a quickfix or manually.

Explicitly marking namespace packages can later be used for automatically
running files from them and ordinary packages with "-m".
The new resolve policy and explicit namespace packages can be disabled with the
Registry flag "python.explicit.namespace.packages".

These changes also address PY-40396. Namely, now any directory with __init__.py
inside or explicitly marked as a namespace package has a package icon,
regardless of its name or parents.

GitOrigin-RevId: 310fa562eb60121243cb6d68386ffc3e45c73245
2020-10-21 16:04:26 +00:00
KotlinIsland
1fdb8235e9 PY-44714 PyTypedDictInspection: don't register problem with None
Fix false positive with None as TypedDict value type
close #1452

GitOrigin-RevId: 7c02d8928f2e9ef3612aaf69d6daeb5a1b71cb95
2020-10-20 16:11:42 +00:00
Mikhail Golubev
bb31fdc67d PY-42334 Add support for PEP 613 typing.TypeAlias
Both typing.TypeAlias (available only in 3.10) and typing_extensions.TypeAlias
names are supported.

RHS values of assignments annotated with TypeAlias are always retained in
stubs and injected into (if it's a string literal), regardless of whether
they look similar to a well-formed type hint. It seems natural to assume
that if a user employs such as specific marker as "TypeAlias" at all, they
clearly indicate that the value is supposed to be a type.

The inspections "Type hints definitions and usages" and "Final classes, methods
and variables" properly analyse RHS of assignments annotated with TypeAlias.
Type hinting inspection also reports illegal usages of TypeAlias, as it was
done for other special forms in the typing module.

The type of such variables themselves is Any, however they're still displayed
as having the type "TypeAlias" in Quick Documentation to avoid confusion.

GitOrigin-RevId: fab02f6e1060c0994e1d21201768e7b28ba7d9e0
2020-10-19 19:46:54 +00:00
Semyon Proshev
5cc837abf5 Minor review fixes
GitOrigin-RevId: 9e7619d7aeb964f20b72504c7ac5f6cf34be64bc
2020-10-19 16:36:21 +00:00
Semyon Proshev
3d31f690f3 Re-use already calculated sdks in guessing language level
Drop `isPythonModule` call since it breaks PyStringLiteralTest.testEscapedUnicodeInLiterals.

GitOrigin-RevId: 6f5ea083a72bdb29826466a50f62cdf84cd26960
2020-10-19 16:36:20 +00:00
Semyon Proshev
4bda118750 Make LanguageLevel.toPythonVersion instance method
GitOrigin-RevId: 133ad26d0952922b57b090dc4e597dc6e3be003e
2020-10-19 16:36:19 +00:00
Aleksei Kniazev
0831f572e4 PY-15046: fixed comparison detection
close #1350

GitOrigin-RevId: dad0c658d5d1d5a3a6d92ecc9cc544f9b7ac0ff4
2020-10-19 15:47:29 +00:00
Vasya Aksyonov
5372947ac0 PY-15046: Review fixes
GitOrigin-RevId: 7d8062b0d0efdb614b421b2e4088a6ec4bcf5413
2020-10-19 15:47:26 +00:00
Vasya Aksyonov
226cf2c350 PY-15046: Invert 'if' statement implementation
GitOrigin-RevId: 86ddfbe04b635d9db288b273540d06d83963cebe
2020-10-19 15:47:25 +00:00
Semyon Proshev
603ae74c21 Make python disposable name more descriptive and not looking like interface
GitOrigin-RevId: 5009db52c121efbbf04952d3843b64ff4dc5888d
2020-10-16 14:44:56 +00:00
Semyon Proshev
00eb505497 Python 2.6 is no more supported in compatibility inspection
Because 2.6 is not supported since 2019.1 in IDE.

GitOrigin-RevId: 3dee3e941c921ad3a5dc6d72cca840eb5d811691
2020-10-16 12:24:45 +00:00
Semyon Proshev
7ec52fb1e6 Don't pass future feature to parsing since it is either null or no more actual
GitOrigin-RevId: 23e266850c1b65facf135248be206387e8284c54
2020-10-16 12:24:41 +00:00
Semyon Proshev
3a14be417f Replace StatementParsing.FUTURE with FutureFeature
GitOrigin-RevId: dc8084755485048edff4659dde551f0b54e2c9c2
2020-10-16 12:24:38 +00:00
Semyon Proshev
08a5ecdd86 Remove future features that are mandatory in the supported python versions, change bounds type to language level
GitOrigin-RevId: 13c3e6ec4248d38338d09d1c3f87da6006d1ce5a
2020-10-16 12:24:36 +00:00
Semyon Proshev
d30fc4f7bc Inline language level flags that are constants in supported python versions
GitOrigin-RevId: 5e381b72505c1d896028da83b7044be51e408f0b
2020-10-16 12:24:31 +00:00