-
-
Notifications
You must be signed in to change notification settings - Fork 43
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
add opt-in strict string format #451
base: main
Are you sure you want to change the base?
Conversation
92dee76
to
a69a432
Compare
47c3aab
to
571edfa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome hard work! thank you! speaking of your gotten knowledges about how to contribute we need to write CONTRIBUTING.md
someday. but this will be separated PR for sure
6ad722a
to
6de9cac
Compare
7bcd93e
to
eb1d28b
Compare
@pytest.fixture | ||
def invalid_data() -> dict: | ||
return { | ||
'handle': get_test_cases('handle_syntax_invalid.txt')[0], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we parametrize it as well? to use all the test cases from .txt files instead of the first one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aha good call. yeah this definitely opened a new can of worms 🙂
there are a couple straggler cases I couldn't quite figure out right away that I've explicitly skipped for now, just a few of the many. let me know if anything jumps at you, ill come back to dig more later
8d7deee
to
1c82c73
Compare
RKEY_RE = re.compile(r'^[A-Za-z0-9._:~-]{1,512}$') | ||
TID_RE = re.compile(rf'^[2-7a-z]{{{TID_LENGTH}}}$') | ||
CID_RE = re.compile(r'^[A-Za-z0-9+]{8,}$') | ||
AT_URI_RE = re.compile( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry for the long response! i am busy at work :(
as I can see this regex is different to official one:
We use official in our AtUri class:
_ATP_URI_REGEX = r'^(at:\/\/)?((?:did:[a-z0-9:%-]+)|(?:[a-z0-9][a-z0-9.:-]*))(\/[^?#\s]*)?(\?[^#\s]+)?(#[^\s]+)?$' |
(btw probably you could just use AtUri class to validate string instead of duplicating regex)
Probably, your regex come from re-impl mentioned in the issues. But it would be awesome to align with official one! And as I can see you can get everything from the syntax
package! https://github.com/bluesky-social/atproto/tree/53fcc2fbcbda9b325eeffb5705126831baf2a427/packages/syntax/src. With it all the tests should pass and no need for excluding test cases
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry for the long response! i am busy at work :(
no worries! so am I 🙂
ack! I missed that - thank you!
I will update the regexs to follow those as soon as I can 👍
34d0101
to
34444be
Compare
remove example file update codegen run the things add tests
lint doh appease old python tests n tweaks checkpoint
34444be
to
9807a81
Compare
hi @MarshalX - ok all of the cases are passing with no skipping! I found that the spec and test cases in the interop valid/invalid For example, looking at the AT-URI validation, I noticed what appear to be few differences between the regex I added and
let me know if you think i'm missing something here or if you think I should move some of these requirements into the types in also, just in case it comes up: i had a tricky problem with loading the test cases where I was calling |
adds pydantic validation per #406 (comment). see the usage example
did
did:plc:z72i7hdynmk6r22z27h6tvur
did:[a-z]+:[a-zA-Z0-9._%-]+
(max 2KB, no /?#[]@)handle
alice.bsky.social
at-uri
at://alice.bsky.social/app.bsky.feed.post/3jxtb5w2hkt2m
at://
+ handle/DID + optional/collection/rkey
. Max 8KB. No query/fragment in Lexicon.datetime
2024-11-24T06:02:00Z
nsid
app.bsky.feed.post
tid
3jxtb5w2hkt2m
record-key
3jxtb5w2hkt2m
uri
https://example.com/path
did:plc
did:plc:z72i7hdynmk6r22z27h6tvur
does not address open questions regarding the language types or
re2
. happy to chat on those if they'd be blocking heremay close #406
notes
I ran this to generate models
and this to update docs
and this to run the new tests
if desirable, I can follow up this PR to add contribution instructions to the current README section (for
uv
at least, and perhaps a TODO for properpoetry
usage, since I don't really use that) - let me know!in/valid examples for tests are sourced from https://github.com/bluesky-social/atproto/tree/main/interop-test-files/syntax