Support for overloads
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 42/100
Research direction
No source files, tests, or entry points are named in the issue. Start by tracing how pyannotate currently consumes signature data and writes .py versus .pyi files; implement the proposed overloads behavior for both formats and verify generated output against the JSON example.
Written by the indexing model from the issue text.
Description
I've written a tool that extracts signature data for a C extension from doxygen xml files, and I have stubs that I created using mypy's stubgen, and I'd like to use pyannotate to combine the two. In order to do that I need pyannotate to support @overloads.
I'm happy to make the PR for this.
I was thinking that we can add support for a "overloads" key that contains a list of signature data. The behavior will be slightly different depending on whether the target file is a .py or .pyi
- For .py files: If the
"overloads"key is present, a new@overloadfunction will be created for each entry. If the"signature"key is present, it will be applied to the target function (this means in the presence of"overloads","signature"is optional) - For .pyi files: If the
"overloads"key is present, a new@overloadfunction will be created for each entry, and the target function will be deleted (we assume the target function represents the "real" function, which is superseded by overloads, and may have a completely different arg signature than the overloads. This means we assume the list of overloads is complete, not sparse). The"signature"key will always be ignored.
Here's an example json file:
[
{
"func_name": "my_command",
"line": 16,
"path": "/Users/chad/dev/mymodule.py",
"samples": 0,
"overloads": [
{
"arg_types": [
"str"
],
"return_type": "str"
},
{
"arg_types": [
"int"
],
"return_type": "None"
}
],
"signature": {
"arg_types": [
"Union[str, int]"
],
"return_type": "Optional[str]"
}
}
]
- Dominant language
- Python
- Stars
- 1.4k
- Forks
- 59
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dropbox/pyannotate
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
dropbox/pyannotate#124 · 3 reactions ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
dropbox/pyannotate#123 ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
dropbox/pyannotate#115 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
dropbox/pyannotate#109 ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
dropbox/pyannotate#103 · 6 comments · 1 reaction ·
All issues in dropbox/pyannotate
Similar issues
-
adr
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
kristofdegrave/homeassistant-smart-charging#1607 ·
Maintainers usually reply within 1 day
-
namespace operations
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
EclipseFdn/open-vsx.org#13665 ·
Maintainers usually reply within 1 day
-
doc good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
collective/icalendar#1865 · 2 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
canonical/opentelemetry-collector-operator#409 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
mozilla/addons-release-tests#1243 ·
Maintainers usually reply within 1 day