Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Specific type hints #2067

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

Closed
wants to merge 4 commits into from
Closed

Conversation

vectro
Copy link

@vectro vectro commented Jun 12, 2022

Update the type hints on Mixin objects to be more specific so that clients can know the specific RESTObject that would be returned.

Closes #2062

@nejch
Copy link
Member

nejch commented Jun 13, 2022

Hi @vectro. thanks for the earlier discussions and for looking into this. We use tox to manage our environments and versions so you can use that before pushing to make sure all the test & lint jobs succeed consistently with the versions we track.

https://github.com/python-gitlab/python-gitlab/blob/main/CONTRIBUTING.rst#running-unit-tests

One of these is a commitlint check as we parse commits to create changelogs so this might need a bit of a squash and amend once it's ready for review 🙇

@vectro
Copy link
Author

vectro commented Jun 14, 2022

@nejch I ran tox and see some errors that I'm not sure what to do with. What do you think?

  • At gitlab/v4/cli.py:352 related to SidekiqManager but I'm not really sure what that class should look like. Should it even have an _obj_cls attribute?
  • At tests/meta/test_mro.py:122 because Generic is now the final class in the MRO (I suppose) and not RESTManager.
  • cz is unhappy but presumably that can be resolved by squashing commits.

@nejch
Copy link
Member

nejch commented Aug 1, 2022

@vectro sorry for the super late response! I haven't checked this in depth myself but a few pointers:

I'm not sure your code gets checked by mypy as expected, as the generics part is defined outside the if TYPE_CHECKING block - unless I'm misunderstanding something here:

if TYPE_CHECKING:
# When running mypy we use these as the base classes
_RestManagerBase = base.RESTManager
_RestObjectBase = base.RESTObject
else:
class _RestManagerBase(Generic[T_obj, T_parent]):
_obj_cls: Type[T_obj]
_parent: Optional[T_parent]
class _RestObjectBase(Generic[T_obj, T_parent]):
_obj_cls: Type[T_obj]
_parent: Optional[T_parent]

Also keep in mind @JohnVillalovos did some work on typing recently so that might affect your rebase here.

@github-actions
Copy link

github-actions bot commented Jan 1, 2023

This Pull Request (PR) was marked stale because it has been open 90 days with no activity. Please remove the stale label or comment on this PR. Otherwise, it will be closed in 15 days.

@github-actions github-actions bot added the stale label Jan 1, 2023
@github-actions
Copy link

This PR was closed because it has been marked stale for 15 days with no activity. If this PR is still valid, please re-open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Type hint on ListMixin.list is too strict
3 participants