mtdcr / pysml

Python library for EDL21 smart meters using Smart Message Language (SML)
MIT License
16 stars 8 forks source link

parse_frame returns unexpected result #13

Closed Schwaneberg closed 8 months ago

Schwaneberg commented 1 year ago

The type hint Tuple[int, Optional[SmlFrame]] is ok for the first return return [match.end(), obj] (hoewever, List[int, Optional[SmlFrame]] would be the acurate hint), but not for the second return [end].

This causes an unexpected ValueError, if you do stuff like _, frame = SmlBase.parse_frame(sml_frame).

Schwaneberg commented 1 year ago

I recommend to change the second return to return (end, None)

mtdcr commented 1 year ago

You're right. Would you mind creating a PR? Otherwise I'll fix it by myself, but it may take some more time.

I guess it would make sense to change the type annotation from Tuple to List and always return a list.

mtdcr commented 8 months ago

I failed trying to fix the signature of the existing function. Therefore, release 0.1.0 contains a new function called find_frame which always returns a fixed-size tuple. New code should prefer this function over the older parse_frame.

Thank you for your report! I'm sorry for the long delay.

Schwaneberg commented 7 months ago

Thank you very much! I could have created the PR - sorry I didn't respond in time.

Am So., 8. Okt. 2023 um 12:36 Uhr schrieb mtdcr @.***>:

Closed #13 https://github.com/mtdcr/pysml/issues/13 as completed.

— Reply to this email directly, view it on GitHub https://github.com/mtdcr/pysml/issues/13#event-10583794053, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIM6TNMLUMS2XF5L6ELKGSLX6J625AVCNFSM6AAAAAAYJUDAE6VHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJQGU4DGNZZGQYDKMY . You are receiving this because you authored the thread.Message ID: @.***>