Commit Graph

3664 Commits

Author SHA1 Message Date
Mikhail Golubev
479b06eaed PY-31442 Add test cases for various scenarios when f-string is terminated by a line break 2018-10-01 12:46:42 +03:00
Mikhail Golubev
cd3122c7c1 PY-31442 Implement "rich" methods of PyFormattedStringNode including decoding
Also fixed the problem that whitespaces inside literal parts of f-strings were
matched as PsiWhitespaces instead of FSTRING_TEXT tokens and updated all relevant
test data.
2018-10-01 12:46:42 +03:00
Mikhail Golubev
68f72f3dd9 PY-31442 Handle f-strings terminated by other string literals in fragments
When the terminating quote is either at the beginning of a string literal or
inside it, either in the given f-string itself or inside a nested one and
either in normal fragment or in a fragment located inside a format part of
another fragment. Normal string literals and nested f-strings are also checked
separately.
2018-10-01 12:46:42 +03:00
Mikhail Golubev
50383b4768 PY-31442 Properly detect end quotes inside literal and format parts of f-strings 2018-10-01 12:46:42 +03:00
Mikhail Golubev
815d919abb PY-31442 Add test cases for various scenarios of preliminary terminated f-strings 2018-10-01 12:46:42 +03:00
Mikhail Golubev
0300a411d6 PY-31442 Parse type conversions (!r/!s/!a) inside fragments
Also, improved handling of incomplete fragments inside f-strings.
2018-10-01 12:46:42 +03:00
Mikhail Golubev
40c1e8b949 PY-31442 Parse format parts of f-string fragments 2018-10-01 12:46:42 +03:00
Mikhail Golubev
81afd74ed9 PY-31442 Started working on format parts of fragments 2018-10-01 12:46:41 +03:00
Mikhail Golubev
c13a63958d PY-31442 Parse simplest possible f-strings together with other expressions
- no nested f-strings
- no formatting parts after colon
- no illegal escapes detection
- no quote mismatch detection
2018-10-01 12:46:41 +03:00
Mikhail Golubev
841fcbc914 PY-20159 Add an option to make optimize imports case-insensitive
Both packages/module names and names of individual imported symbols in
"from" imports are sorted case-insensitively if it's enabled.
To keep things simple I decided not to replicate the exact scheme used
by isort to order names in "from" imports where they have different priority
depending on whether they are ALL_CAPS or CamelCased (check the issue for
related discussion).
2018-10-01 12:07:13 +03:00
Bas Leijdekkers
d8fbb19781 RegExp: handle unicode character values outside of the BMP correctly (PY-24172) 2018-09-28 18:18:42 +02:00
Bas Leijdekkers
c7f9300541 RegExp: correct whitespace handling in comment mode (PY-31505) 2018-09-28 18:18:41 +02:00
Mikhail Golubev
cd53226019 PY-31299 Fix resolution of built-in classes' names in PyPsiFacade
Additionally, I extracted tests on PyPsiFacade implementation into a dedicated
test case.
2018-09-26 19:51:17 +03:00
Mikhail Golubev
2d2976a889 PY-31299 Migrate PyPsiFacade#createClassByQName implementation to PyResolveImportUtil
Using PyTypeParser for this purpose is, first, too heavyweight since it does a lot of
unnecessary work, and, second, introduces unexpected problems related to the fact
that it was originally intended to resolve types in docstrings and thus too permissive
and depends on surrounding context such as existing imports.
2018-09-26 18:15:23 +03:00
Mikhail Golubev
2289223414 PY-31795 Don't suggest removing parentheses when there is no expression inside 2018-09-25 15:56:54 +03:00
Mikhail Golubev
0ebde2269f PY-31862 Escape the content of a docstring summary in Quick Navigate Info 2018-09-25 15:56:54 +03:00
Ilya.Kazakevich
5e62b87288 test fix 2018-09-06 21:15:58 +03:00
Ilya.Kazakevich
4020d3b5f8 PY-25260: test added 2018-08-29 23:36:35 +03:00
Ilya.Kazakevich
d48ce2af51 PY-27267: swap diff in pytest (Sync tcmessages and add test)
Actual and expected are in wrong order.
Fixed on tcmessages side, test added.

Use swapdiff in pytest.ini to switch it back
2018-08-24 17:56:25 +03:00
Ilya.Kazakevich
3a4b52660e PY-31051: pytest fixtures may use yield
In this case we must fetch real type from generator.
We also should open union if one is returned instead
of generator itself.

Any decorator leads to weak type (Union[Any, T]). To fix it, we use KnownDecorators (its better to use EP there)
2018-08-21 22:26:43 +03:00
Semyon Proshev
0f257db99f Ignore method usages via super(...) in call hierarchy (PY-29841) 2018-08-20 15:13:32 +03:00
Mikhail Golubev
a28f8a4668 PY-31424 Adjust the signature to TypeVar to accept type references
One can pass string literals containing such references both to "*constraints"
and "bound" parameters.
2018-08-17 12:57:03 +03:00
Mikhail Golubev
7c2b079481 PY-24161 Properly treat variables annotated with Type[...] as callable 2018-08-15 12:44:23 +03:00
Mikhail Golubev
58a25d2c34 PY-24450 Suggest importing modules for unresolved decorators without arguments
Because it can be just an incomplete qualified name of the needed callable.
2018-08-15 12:44:23 +03:00
Mikhail Golubev
56c6c787ec Remove the logic that prevented one-letter docstrings from being rendered
We don't have it elsewhere, thus, there is little sense in keeping it
specifically for inherited documentation.
2018-08-13 14:58:36 +03:00
Mikhail Golubev
e00ac80dbe PY-20777 Disable commenting inside injected Python expressions in f-strings
This solution uses a custom key to mark an injected file as unsuitable for line
commenting, but we should rather generalize it in some other way instead of
further hardcoding language-specific string prefixes in CommentByLineCommentHandler.

Reviewed in IDEA-CR-35030.
2018-08-13 14:58:36 +03:00
Mikhail Golubev
1f7f9c496d PY-31074 Use constructor docstring in case a class lacks its own
Python Console generates declaration stubs where docstring for a class is moved
to its __init__. It's a somewhat add-hoc solution for the problem, we should
probably fix this controversial behavior of the debugger as well.
2018-08-13 14:58:36 +03:00
Mikhail Golubev
0a1db27b68 PY-31033 Render parameters and exceptions in monospaced font to make them more noticeable 2018-08-07 13:04:07 +03:00
Mikhail Golubev
d84a93525e PY-31033 Render parameter default values in Quick Documentation
At the moment we render them "as is" only escaping their text
similarly to how it's done for TypeScript, not trimming it
to the first line as in case of target expression initializers.
2018-08-07 13:04:06 +03:00
Mikhail Golubev
34925eb8bc PY-30825 Unify how we find the element to refactor in type hinting intentions
Extracted detection of the right reference owner under the caret.
Resolving in all the different places now uses the same resolve context.
Also I reduce visibility of the shared methods.
2018-08-06 19:13:21 +03:00
Mikhail Golubev
618921d8bc PY-30825 Remove the controversial logic regarding annotating of a reference qualifier
Otherwise, we can't really tell whether the use wants to annotate the return type
of the method or the type of the qualifier in cases like the "param.met<caret>hod()".
It's better to be more explicit and ask them to invoke the intention on the right
element directly.

Handle the cases when the caret is at the end of an identifier using
TargetElementUtil#adjustOffset.
2018-08-06 19:13:21 +03:00
Mikhail Golubev
6baab8c3e3 PY-30713 Use the same logic in isAvailable and doInvoke of type hints related intentions
Additionally, manually check that these elements are actually writable
before applying the respective changes and don't suggest these intention actions
if there are several possible definitions (though, we'd better show them all
in a popup in this case).

Otherwise, we may end up modifying dozens of library definitions without notifying
user about it anyhow in case of ambiguity in resolve results.
2018-08-06 19:13:20 +03:00
Mikhail Golubev
4017063bff PY-31148 Properly extract description from Sphinx ":param" tags containing type 2018-08-06 18:30:14 +03:00
Mikhail Golubev
a41986b1b4 PY-31025 Properly extract description of the return value in Google docstrings
when both its type and optional name are omitted. Just as the reference implementation
in sphinxcontrib.napoleon we now require a trailing colon on the first line of a field
to treat this text as the return type, otherwise it's considered the return value description.

Also, I dropped support for named return and yield values in Google Code Style docstrings,
as Napoleon doesn't feature them as well.
2018-08-06 18:30:14 +03:00
Andrey Vlasovskikh
94923b4447 PY-30803 Ignore requirements with environment markers
Environment markers are not supported yet, see PEP 496.
2018-08-03 17:10:29 +03:00
Mikhail Golubev
2f62a7a131 PY-31146 Accept None literal as a valid expression inside type hints 2018-08-01 14:04:15 +03:00
Mikhail Golubev
c9da929d3d PY-31004 Remember LHS of a type alias, not the assigned value to prevent recursion
because the latter is constructed anew from the text stored in stubs every time
and therefore shouldn't be used for caching.
2018-08-01 14:04:15 +03:00
Semyon Proshev
c1cd227e56 Fix test data after syncing with typeshed 2018-07-23 18:11:07 +03:00
Ilya.Kazakevich
3f2ae3caa3 PY-26263: test fix 2018-07-18 00:12:40 +03:00
Semyon Proshev
c579994aec Quick fix to set abc.ABCMeta as metaclass (PY-30789) 2018-07-17 20:27:51 +03:00
Semyon Proshev
fff6955833 Move adding metaclass method (PY-30789) 2018-07-17 20:27:51 +03:00
Semyon Proshev
e2855325d1 Quick fix to add abc.ABC to superclasses (PY-30789) 2018-07-17 20:27:51 +03:00
Semyon Proshev
b8f5298ee3 Consider class inheriting abc.ABC as abstract (PY-30789) 2018-07-17 20:27:51 +03:00
Elizaveta Shashkova
717484f15a PY-29894 Fix Python quick fixes for PSI consistency 2018-07-17 14:58:31 +03:00
Ilya.Kazakevich
9328593cd2 PY-30762: Test added 2018-07-17 01:32:22 +03:00
Mikhail Golubev
6caccc8e4d PY-21493 Python regexp injector is aware of f-strings 2018-07-16 22:38:21 +03:00
Semyon Proshev
9f9608ae4b Provide resolve result for __builtins__ (PY-30512) 2018-07-16 21:04:59 +03:00
Semyon Proshev
17f543fdc9 Infer Any return type for abstract methods (PY-29704)
Sync overriding and implementing abstract methods.
Make `PyFunction.getReturnStatementType` accepting only non-null contexts.
2018-07-16 16:54:34 +03:00
Semyon Proshev
8b0dbf4e1b Ignore init=False attributes while inspecting fields order (PY-30880) 2018-07-16 15:44:23 +03:00
Anton Bragin
2b5e738a5a PY-30827 PyRenameElementQuickFix changed to avoid special handling of unit test cases
Test data and PyQuickFixTest are updated accordingly. Test for renaming in language injection added.
2018-07-13 10:46:32 +03:00