-
-
Notifications
You must be signed in to change notification settings - Fork 45
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
Implement Message and Interchange high-level containers #29
Implement Message and Interchange high-level containers #29
Conversation
First, without I have seen the code: whow, I'm impressed. It's still hard to believe for me that anyone else finds this code useful for "production" already - because for me it's still in "eats your dog" mode. ;-) So, to the "options" - API stability is no issue ATM, as it really is meant "pre-alpha". But, nevertheless, it would be fair to choose option 3, for anyone who already uses the low level API. And it's GoodProgrammingPractice anyway. So. Option 3 should be the way to go. |
One thing I see if I look at e.g. Message/Interchange: You use parameters of the class Message(AbstractSegmentsContainer):
def __init__(
self,
reference_number: str,
identifier: Tuple,
*options
): with gooooood documentation. And yes, there would be NO type whatsoever checking possibility when using str, tuples etc. |
And I see you are using the
This says the Python docs - but I think we can use it here to. |
Or maybe just keep EDISyntaxError but make it inherit SyntaxError ? |
Is there any recommendation to use SyntaxError only for Python syntax? I didn't find any. but naturally, I think using EDISyntaxError is the better way, so it's easier to distinguish. I'll make it inherit |
Yes, that is on my TODO for this PR :). But I would prefer to use the |
a5a2e97
to
5047490
Compare
"I would prefer to use the *options stared format" - you mean "not use"? class Message(AbstractSegmentsContainer):
def __init__(
self,
reference_number: str,
identifier: Tuple,
**options
): |
I'd prefer to allow adding arbitrary segment sections, rather than listing and handling all optional fields specifically. See my implementation in 5047490 WDYT ? |
(moreover, limiting the supported sections may force us to support all versions of the standard with their specificities, which is not a way I want to take as of now :-p). |
Hm. I think you want to support the newest version (4). Due to my own requirements, and why I started pydifact, I need to support the v3. That's why I created the syntax directory with the v[1-3].py files... (they're stubs for now) |
OK, thanks for the explanation, but within the scope of that PR, do my liberal implememantion of optional elements suits you ? |
Oh, yes, sorry for the late answer. For this PR this is ok, if you don't mind if I change the API later... |
Yes, sure. By the way, I'd be in favor of using semantic versioning : bump the major version when we break the API. |
yes, sorry. supporting arbitrary segments using dicts seems a bit inconsistent to me : as I am not going to document the allowed parameters for now (and they may vary from a version of edifact to another), telling users to pick arbitrary keys seems weird. So tuple for now, and we may switch to dict or named args later :) |
Adressed remaining issues and filled changelog. I think it is good to go :) |
5047490
to
934b4e6
Compare
Regarding semantic versioning - definitively. Just startend with a 0.0. Version as it's pre-alpha. So there is no major version until stable, API can change any time... But to address the changes we could use minor versions for "major" changes too until 1.0.0 |
OK, not a big fan, but you are the maintainer, and I do not want wasting our time with endless discussion on versioning scheme, so let's go for that :). OK to target SegmentCollection removal for v1.0 as I wrote in that PR, or before ? |
I maybe just misunderstood - I'm a BIG fan of SemVer. I just thought that UNTIL we reach 1.0.0 - API can change anyway. Because if not, I would have to change the major version with each API break - but the first break would then have to be 1.0.0 - which is not desirable - because 1.0.0 means stable.
That's exactly what I want. |
I would remove that before. Noone should use that any more when 1.0 is near ;-) |
698e923
to
e79acae
Compare
Ok for everything, thanks for taking time explaining :). So if I got it correctly, I think my PR is ready with latest push.
Sounds good to you ? |
b8acfe6
to
42929d9
Compare
- plan its removal for v1.0 - move from_file() method and UNA parsing to Interchange class - create a replacement RawSegmentCollection class for use cases with lousy structured segment bunches. Ref nerdocs#19
To detect early some invalid UNB segments (as we rely on the presence of those fields then in the code).
42929d9
to
eef1cb9
Compare
Fixed a few leftovers (nitpicking) and a bug |
Yes, this sounds fine! |
Sorry for the long delay. Looks all good to me. Thank you very much for your input. |
No prob, and thanks :-). |
This PR fixes #19
Limitations
TODO
(things I want to do before merging)
API breakage strategy discussion
Compared to what we discussed in #19, I have two tasks pending :
from_file()
toInterchange
classUNA
handling toInterchange
classI wanted to stop and discuss here because, those changes are going to break previous API. I see three options:
Option 1 : prioritize compatibility
Let it as-is, more or less : the API is a bit less clean but backward compatibility is ensured
Option 2 : prioritize API cleanness
RawSegmentCollection
that barely inheritAbstractSegmentsContainer
and maintains the possibility to parse random segments bucketsOption 3 : progressive breakage
WDYT? As of now, I myself have a preference for Option 3
Any comments on the PR are welcome, even if this is WIP (design and most of the code is here already).