Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Fix decorator parsing for async functions #577

Merged
merged 8 commits into from
Jan 8, 2023
Merged

Fix decorator parsing for async functions #577

merged 8 commits into from
Jan 8, 2023

Conversation

cdce8p
Copy link
Member

@cdce8p cdce8p commented Feb 16, 2022

This PR addresses an issue with parsing decorators right before async function definitions.
A good example to illustrate the issue is overload.

from typing import overload

@overload
async def func(x: int) -> int:
    ...

async def func(x: int | str) -> int | str:
    """Do something."""
    pass

At the moment, this would emit a D103 error for the first definition.

D103: Missing docstring in public function

That's because, parsing the decorator name wasn't stopped with async and thus overload became overloadasync and didn't match any is_overload checks anymore.

@adamjstewart adamjstewart mentioned this pull request Jan 2, 2023
@@ -25,6 +25,8 @@ New Features
Bug Fixes

* Fix ``--match`` option to only consider filename when matching full paths (#550).
* Fix decorator parsing for async function. Resolves some false positives
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cdce8p thanks for the PR! Could you please move the release notes under a 6.2.1 heading instead? Thanks!

@cdce8p
Copy link
Member Author

cdce8p commented Jan 3, 2023

Moved the changelog entry again, since I didn't saw that 6.2.1 was released an hour ago.

@samj1912 samj1912 enabled auto-merge (squash) January 8, 2023 17:52
@samj1912 samj1912 merged commit 302bb78 into PyCQA:master Jan 8, 2023
@cdce8p cdce8p deleted the fix-async-func-decorators branch January 8, 2023 17:57
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants