Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve tests of typing.override #102324

Closed
sobolevn opened this issue Feb 28, 2023 · 0 comments
Closed

Improve tests of typing.override #102324

sobolevn opened this issue Feb 28, 2023 · 0 comments
Assignees
Labels
tests Tests in the Lib/test dir topic-typing type-bug An unexpected behavior, bug, or error

Comments

@sobolevn
Copy link
Member

sobolevn commented Feb 28, 2023

Right now we have several things to improve:

  1. This branch is not covered by tests:
    pass
    We don't have a single test that ensures that @override will not fail for some weird cases. Since 99.99% of use-cases will simply be @override def some(...): ..., it is not very important - but still desirable
  2. We don't test @classmethods, I guess it is special enough to be included
  3. @property is also missing from tests, but is mentioned in PEP: https://peps.python.org/pep-0698/#specification and https://peps.python.org/pep-0698/#limitations-of-setting-override
  4. PEP also mentions @functools.lru_cache and similar decorators as an example of how wrappers should be nested. Why don't we test it? Right now there are no tests for nested method decorators (except staticmethod)
  5. It might not hurt to test that parent's methods definitions are not mutated (I think this is a part of the contract)

PR is on its way :)

Linked PRs

@sobolevn sobolevn added type-bug An unexpected behavior, bug, or error tests Tests in the Lib/test dir labels Feb 28, 2023
@sobolevn sobolevn self-assigned this Feb 28, 2023
sobolevn added a commit to sobolevn/cpython that referenced this issue Feb 28, 2023
@sobolevn sobolevn closed this as completed Mar 3, 2023
carljm added a commit to carljm/cpython that referenced this issue Mar 4, 2023
* main:
  pythongh-102021 : Allow multiple input files for interpreter loop generator (python#102022)
  Add import of `unittest.mock.Mock` in documentation (python#102346)
  pythongh-102383: [docs] Arguments of `PyObject_CopyData` are `PyObject *` (python#102390)
  pythongh-101754: Document that Windows converts keys in `os.environ` to uppercase (pythonGH-101840)
  pythongh-102324: Improve tests of `typing.override` (python#102325)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Tests in the Lib/test dir topic-typing type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants