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

Bug array of one #34

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Bug array of one #34

wants to merge 7 commits into from

Conversation

dmweir
Copy link
Contributor

@dmweir dmweir commented Mar 6, 2025

Allow arrays of length one for most date types. If the field was created using array syntax in the message def, use an index to access the single element in the array, i.e msg.arr[0] not msg.arr.

Exceptions:
Fields that use a char array of length one will resolve as a scalar i.e. char[1] will become char. We only allow char arrays of size greater than one to ensure that there is spot for a null terminator byte. This logic is validated in the String validator type.

  • Auto padding with now use the byte type and will internally always be ByteArray instead of a mix Char and String
  • Accessing individual elements of ByteArray field will return an int, a slice will return a python bytearray.
  • Unit tests for setting and getting fields that are arrays of length one have been added.

@dmweir dmweir requested a review from jmw182 March 6, 2025 14:26
@dmweir dmweir linked an issue Mar 6, 2025 that may be closed by this pull request
dmweir and others added 2 commits March 6, 2025 11:40
Do not set a value as these types only exist for type checking and this is an abstract base class

This fixes pylance warnings
@jmw182 jmw182 added the v3.0 Include in v3.0 release label Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v3.0 Include in v3.0 release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Arrays of length one are not considered arrays
2 participants