Skip to content

Source code that has @final decorator does not require @final in stub #14921

Closed
@sobolevn

Description

@sobolevn

Today I got hit by this. This was the source code:

from typing import final

@final
class A: ...

This was the stub:

class A: ...

But, stubtest allowed this.
I think that we should also check for __final__ attribute.

For example, some stdlib code already has @final decorators applied, like: https://github.com/python/cpython/blob/e1e9bab0061e8d4bd7b94ed455f3bb7bf8633ae7/Lib/asyncio/timeouts.py#L26

I will send a PR with the fix.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions