20 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
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 7afb41757c PY-29717 Don't render type for "self"/"cls" method parameters
These are mostly obvious at the call site.
2018-06-09 15:59:39 +03:00
Mikhail Golubev 530c7d2d74 PY-29717 Display qualified names of classes above methods
Use "containing class" type of link only as a fallback for local classes
2018-06-09 15:59:37 +03:00
Mikhail Golubev 505efb9982 PY-29717 Remove excess trailing spaces and line breaks from plain text docstrings 2018-06-09 15:59:37 +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
Dmitry Trofimov e38b35ada5 Links for function types in quickdoc (PY-3404). 2012-11-04 19:11:48 +01:00
Andrey Vlasovskikh e5049069cc Initial type checker inspection for Python 2011-06-15 21:21:09 +04:00
Dmitry Cheryasov 86da4b3d72 PY-895: show constructor's quickdoc on constructor call.
Also: links to classes inside method and class quickdocs.
Adds tests for property quickdocs.
2010-09-03 18:10:12 +03:00
Dmitry Jemerov 8ae978c816 enable showing inferred return types for methods in quick doc; fix quick doc tests 2010-04-26 22:13:38 +04:00
Dmitry Cheryasov 676b2243da Rewrote QuickDoc code, cleaner HTML creation, closes PY-231 partly. 2009-11-29 05:07:35 +02:00
Dmitry Cheryasov 384c584ae7 Tiny fixes in PyQuickDocTest data 2009-11-11 14:05:22 +02:00
Dmitry Cheryasov a714346454 Forgotten change of testMethod for corrected decorators rendering. 2009-07-17 12:41:52 +04:00
Dmitry Cheryasov 801ea7b5c4 Enhance quick doc generation; copy inherited docs for overridden methods. Add module quickdoc (PY-166). Add tests. 2009-06-08 01:33:35 +04:00