Skip to content

fix swapped argument required vars in bitmaptools args helper #10253

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

Merged
merged 1 commit into from
Apr 15, 2025

Conversation

FoamyGuy
Copy link
Collaborator

I believe the intention of this helper function is to have if_required1 be relvant for x1 and y1 and have if_required2 be relevant for x2 and y2.

That would mean that it is possible to control the required-ness of x1,y1 and x2,y2 independently.

As it is written now instead if_required1 is relevant for x1 and x2 and if_required2 is relevant for y1 and y2. If this functionality does match the intention then I would propose if_requiredX and if_requiredY as more descriptive variable names.

But I believe the x1,y1 and x2,y2 delineation was likely the original intention as it's plausible there could be a function that requires one coordinate point, but has the second one be optional. And seems less plausible to me that a function would have x1,x2 required and y1,y2 optional or vice versa for instance.

The only place where this helper function is called that the if_required arguments actually differ is here: https://github.com/adafruit/circuitpython/blob/main/shared-bindings/bitmaptools/__init__.c#L722

Using this statement which calls the affected function:

bitmaptools.arrayblit(bmp, array_2d, x2=32, y2=32)

under 10.0.0-alpha.2 results in this exception:

TypeError: 'y1' argument required

using this PR branch instead successfully runs as the docstrings indicate it should if x1 and y1 are omitted.

I do also believe there are other issues with the arrayblit() arg validation and/or docstrings, but it's separate from this issue with the swapped values in the helper function here, it just so happens to make use of this.

Copy link
Collaborator

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with your conclusion -- not sure why it was the other way. I checked the other uses and the meaning you suggest remains consistent.

@dhalbert dhalbert merged commit 52336ef into adafruit:main Apr 15, 2025
513 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants