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

Add MAC address type #15

Closed
JonasKs opened this issue Feb 17, 2023 · 6 comments · Fixed by #71
Closed

Add MAC address type #15

JonasKs opened this issue Feb 17, 2023 · 6 comments · Fixed by #71
Labels

Comments

@JonasKs
Copy link

JonasKs commented Feb 17, 2023

See #8

@JonasKs JonasKs changed the title MAC address type Add MAC address type Feb 17, 2023
@samuelcolvin
Copy link
Member

looking at https://github.com/mentalisttraceur/python-macaddress/blob/main/macaddress.py I think it would be easier to implement this directly ourselves.

@yezz123 yezz123 added the Types label Feb 17, 2023
@JonasKs
Copy link
Author

JonasKs commented Feb 17, 2023

I’m thinking:

  • strip separators (any non-hex char), so any MAC, written without :, written with - etc will still work
  • return MAC-object with : separators (like RFC suggests)

I know Cisco tend to return MAC and IPv6 with weird formats, such as HHHH:HHHH:HHHH:HHHH.

@JonasKs
Copy link
Author

JonasKs commented Feb 19, 2023

I suggest only supporting EUI48. Any other format should be explicit, in my opinion.

@samuelcolvin
Copy link
Member

Sounds good, from what little I know of Mac addresses.

We can do some of the checking in rust.

@JonasKs
Copy link
Author

JonasKs commented Feb 20, 2023

EUI-64 should probably be possible too, as I see PSQL supports both.

I'm not sure whether they should be the same, or have two different classes?

We can do some of the checking in rust.

I'll start with a pure Python implementation (unless someone beats me to it), and then I'll iterate on it with rust to see if it's faster (and worth the cost of maintenance). The decision can then be made at a later point.

As a side question, since the JSON schema org is no longer adding types ( json-schema-org/json-schema-vocabularies#49 (comment) ), is. @dmontagu (author of pydantic/pydantic#5029 (review) ) aware of this package? There might be a need for JSON schema extensions 😊

@samuelcolvin
Copy link
Member

These types should support JSON Schema via __pydantic_modify_json_schema__, or whatever we end up calling it.

No need for pydantic to know about them specifically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants