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 type hints in ModelNotFoundException #41068

Closed
wants to merge 1 commit into from
Closed

Improve type hints in ModelNotFoundException #41068

wants to merge 1 commit into from

Conversation

spawnia
Copy link
Contributor

@spawnia spawnia commented Feb 17, 2022

I am using this class in my unit tests to build up an exception I expect
to be thrown in the code under test. My model is using string keys, so
both my IDE and static analysis tooling complain about passing its ID.

Additional work on this could be done by introducing generic types for both the model and its ID. However, this would most likely require moving the hydration of the exception into __construct() and thus breaking the interface. I kept it light and simple for now and only changed the type hints.

I am using this class in my unit tests to build up an exception I expect
to be thrown in the code under test. My model is using string keys, so
both my IDE and static analysis tooling complain about passing its ID.

Additional work on this could be done by:
- introducing generic types for both the model and its ID
- using strong type hints
I kept it light and simple for now and only changed the type hints.
@github-actions
Copy link

Thanks for submitting a PR!

In order to review and merge PRs most efficiently, we require that all PRs grant maintainer edit access before we review them. For information on how to do this, see the relevant GitHub documentation.

@driesvints driesvints marked this pull request as draft February 17, 2022 09:07
@spawnia
Copy link
Contributor Author

spawnia commented Feb 17, 2022

I would love to grant edit access to the PR, but apparently it is not possible yet for organization repositories - see isaacs/github#1681

@driesvints
Copy link
Member

Please re-create this PR from your personal account. Thanks

@driesvints driesvints closed this Feb 17, 2022
@spawnia spawnia deleted the improve-model-not-found-exception-types branch February 17, 2022 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants