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

Increase test coverage a bit #8015

Merged
merged 4 commits into from
Nov 6, 2023
Merged

Conversation

alexmojaki
Copy link
Contributor

@alexmojaki alexmojaki commented Nov 5, 2023

Change Summary

A few small tweaks and additions to tests to increase overall test coverage.

Related issue number

Part of #7656

Checklist

  • The pull request title is a good summary of the changes - it will be used in the changelog
  • Unit tests for the changes exist
  • Tests pass on CI
  • Documentation reflects the changes where applicable
  • My PR is ready to review, please add a comment including the phrase "please review" to assign reviewers

Selected Reviewer: @davidhewitt

@alexmojaki alexmojaki changed the title Test coverage Increase test coverage a bit Nov 5, 2023
@alexmojaki alexmojaki marked this pull request as ready for review November 5, 2023 12:25
@alexmojaki
Copy link
Contributor Author

please review

@sydney-runkle sydney-runkle added the relnotes-ignore Omit this PR from the release notes. label Nov 6, 2023
Copy link
Contributor

@davidhewitt davidhewitt left a comment

Choose a reason for hiding this comment

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

Thanks! Test additions look very welcome, just wondering about the justification for the pragmas.

@@ -130,7 +129,7 @@ def for_model(cls, bases: tuple[type[Any], ...], namespace: dict[str, Any], kwar
return cls(config_new)

# we don't show `__getattr__` to type checkers so missing attributes cause errors
if not TYPE_CHECKING:
if not TYPE_CHECKING: # pragma: no branch
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the justification for the pragma here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

coverage says this line is partially covered because the condition is never false. no branch (not no cover) says to ignore that, because not TYPE_CHECKING will never be false at runtime.

@@ -196,7 +196,7 @@ def wrapped_model_post_init(self: BaseModel, __context: Any) -> None:
# this is the BaseModel class itself being created, no logic required
return super().__new__(mcs, cls_name, bases, namespace, **kwargs)

if not typing.TYPE_CHECKING:
if not typing.TYPE_CHECKING: # pragma: no branch
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar question here.

@davidhewitt davidhewitt merged commit 1e32b01 into pydantic:main Nov 6, 2023
59 of 61 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready for review relnotes-ignore Omit this PR from the release notes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants