Commit Graph

12 Commits

Author SHA1 Message Date
Mikhail Golubev
3079150697 PY-60104 Don't try to infer side effects of not type hinted decorators
Assume that such decorators as well as "well-known" decorators, which we special-case,
don't change signatures of decorated functions and classes.

This change effectively stops the long-standing policy of safe-listing a few recognized
"well-known" decorators and assuming everything else can change a definition in any
way. This approach doesn't apply well to the current state of the Python world, where most
of the common side effects of decorators, such as adding new parameters, can be expressed
in type hints.

In 2021.1 we added PyDecoratedFunctionTypeProvider that was able to infer a return type of
decorator over its body, as for any other function, and then correctly apply this information
to a decorated definition. It led to a number of problems.

First of all, depending on whether TypeEvalContext allowed us to access AST of a decorator's
body, we inferred different signatures for functions decorated with an imported decorator in
inspections and in user-initiated actions, such as Parameter Info.

Secondly, we started inferring useless `(*args, **kwargs)` signatures in case of decorators
defined following the common pattern of returning a wrapper function accepting arbitrary
parameters and itself decorated with @functools.wraps (PY-48338). In some sense, our code
analysis was "too smart" in its type inference in this case.

Lastly, we diluted the return types of functions decorated with unknown decorators, even
fully typed, by uniting these types with Any (so-called "weak" types). This logic
existed before PyDecoratedFunctionTypeProvider, but it became more problematic now
than we were able to propagate this artificial union through generic decorators.

This change in behavior might lead to some false positives for untyped Python code
with non-pure decorators. However, given that other type checkers are also likely to hit these
problems, there is now a stronger incentive to add type hints for such problematic APIs.
In the worst case, we can special-case some heavily requested decorators as we did before.

GitOrigin-RevId: db11fb3573bda5da155cb921a30adc31d5c841e2
2024-01-09 20:49:13 +00:00
Daniel Below
87d76c25d1 CPP-34359: Remove empty DEFAULT_PARAMETER key
Default theme's DEFAULT_PARAMETER should fallback to IDENTIFIER, just like in Darcula.
This fixes issues where an external highlighter returns a DEFAULT_PARAMETER highlighting, but a wrong highlighting is applied instead. This happens because looking up the key in the scheme finds the empty DEFAULT_PARAMETER value with null colors, thus we fallback to the other highlighter's colors, which may be incorrect.

GitOrigin-RevId: ea4fb9fccf4f164c677d1eb5ce09638c0c402b49
2023-08-23 11:32:04 +00:00
Irina Fediaeva
bb882b63f5 PY-55118: Syntax highlighting for definition signatures in Quick Documentation
GitOrigin-RevId: b8a27a048772a0af7fcc36a9cba0d308e0ace8cc
2023-02-10 22:44:22 +00:00
Irina Fediaeva
c44fb89c28 PY-56609: Refactoring in quick documentation
Migrate to DocumentationMarkup elements

GitOrigin-RevId: ea4d71638b1dd3a160521e655fd2a1670ea27701
2023-01-23 13:39:02 +00:00
Irina Fediaeva
bd1c830040 PY-56609: Refactoring in quick documentation
Remove ChainIterable usages from quick documentation and replace with HtmlChunk/HtmlBuilder.
I18ize some fragments.

GitOrigin-RevId: c9b1197efcb17de92361426759a7840ee1be8e4b
2023-01-23 13:38:53 +00:00
Irina Fediaeva
a143468daa PY-56609: Refactoring in quick documentation
Migrating PyQuickDocTest.py to Python 3

GitOrigin-RevId: 2ad69939a695066d92f7c8c937828f8097110a62
2023-01-23 13:38:46 +00:00
Mikhail Golubev
69d61a8316 PY-29717 Get rid of excess escaping of spaces in function signatures
It's not necessary as in Quick Documentation a definition is wrapped in
<pre/> tag according to new guide lines, and in tooltips line breaks are
preserved thanks to UIUtil.getHtmlBody() used in HintUtil.prepareHintText().
2018-06-09 15:59:39 +03:00
Mikhail Golubev
f94e80c996 PY-29717 Display qualified name/path of a module for a top-level definition 2018-06-09 15:59:38 +03:00
Mikhail Golubev
407ed5f127 PY-29717 Display inferred function type together with its signature 2018-06-09 15:59:35 +03:00
Semyon Proshev
68b17b57c0 Make return type weak for functions decorated with unknown decorator (PY-28626)
Or decorator that could change return type.
2018-03-27 21:33:54 +03:00
Semyon Proshev
ed3672ce40 Update PythonDocumentationProvider.describeFunction 2017-09-22 15:52:16 +03:00
Semyon Proshev
2c536c6461 Simplify and make describing decorators methods more flexible 2017-09-22 15:52:14 +03:00