Skip to content

allow traced validation of classes w/o a qualname #1

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
dist/
**/__pycache__
credentials
2 changes: 1 addition & 1 deletion Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ build:
poetry build

publish:
poetry publish --build
poetry publish --build --username __token__ --password $(<credentials/pypi-token)


5 changes: 3 additions & 2 deletions latch_data_validation/data_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def explain(self, indent: str = ""):

pretty_msg = prettify(
self.msg,
add_colon=True
add_colon=True,
# add_colon=len(self.children) > 0 or len(self.details) > 0
)
res = f"{indent}{pretty_msg}\n"
Expand Down Expand Up @@ -405,6 +405,7 @@ def validate(x: JsonValue, cls: type[T]) -> T:
"code.namespace": validate.__module__,
},
) as s:
s.set_attribute("validation.target", cls.__qualname__)
# ayush: union types dont have a `__qualname__` attr
s.set_attribute("validation.target", getattr(cls, "__qualname__", repr(cls)))

return untraced_validate(x, cls)