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

fix(v1.51): #1948 passing wrapper class to struct logging config causes pydantic exception #2105

Merged
merged 2 commits into from
Aug 4, 2023
Merged

fix(v1.51): #1948 passing wrapper class to struct logging config causes pydantic exception #2105

merged 2 commits into from
Aug 4, 2023

Conversation

JacobCoffee
Copy link
Member

Pull Request Checklist

  • New code has 100% test coverage
  • (If applicable) The prose documentation has been updated to reflect the changes introduced by this PR
  • (If applicable) The reference documentation has been updated to reflect the changes introduced by this PR

Description

Close Issue(s)

@JacobCoffee JacobCoffee changed the title fix(v1.5x): #1948 passing wrapper class to struct logging config causes pydantic exception fix(v1.51): #1948 passing wrapper class to struct logging config causes pydantic exception Aug 2, 2023
@JacobCoffee
Copy link
Member Author

JacobCoffee commented Aug 2, 2023

It is made about the non-method member _context, but I am not sure how we resolve this in 2.x besides dropping the BaseModel. I tried making a LocalBindableLogger, but that that lost _context and having wrapper_class inherit that
wrapper_class: Optional[Type[LocalBindableLogger]] = Field(default_factory=default_wrapper_class) felt wrong? Open to learn..

pydantic.error_wrappers.ValidationError: 1 validation error for StructLoggingConfig
wrapper_class
  Protocols with non-method members don't support issubclass() (type=type_error)
@runtime_checkable
class BindableLogger(Protocol):
    """
    **Protocol**: Methods shared among all bound loggers and that are relied on
    by *structlog*.

    .. versionadded:: 20.2
    """

    _context: Context

    def bind(self, **new_values: Any) -> BindableLogger:
        ...

    def unbind(self, *keys: str) -> BindableLogger:
        ...

    def try_unbind(self, *keys: str) -> BindableLogger:
        ...

    def new(self, **new_values: Any) -> BindableLogger:
        ...

@JacobCoffee JacobCoffee merged commit 9c27b3b into litestar-org:v1.51 Aug 4, 2023
7 of 8 checks passed
@JacobCoffee JacobCoffee deleted the 1948_bug_passing_wrapper_class_to_StructLoggingConfig_causes_Pydantic_exception branch August 4, 2023 16:05
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