Skip to content

Comments

Python: Replace NotImplemented with default values or errors#7978

Open
Alkalem wants to merge 2 commits intoVector35:devfrom
Alkalem:replace-python-notimplemented
Open

Python: Replace NotImplemented with default values or errors#7978
Alkalem wants to merge 2 commits intoVector35:devfrom
Alkalem:replace-python-notimplemented

Conversation

@Alkalem
Copy link

@Alkalem Alkalem commented Feb 21, 2026

In the python API the builtin value NotImplemented is sometimes used as return value. This is intended for operator implementations like __eq__, but may cause problems in other contexts. This PR only touches NotImplemented outside of operator implementations.

As an example why the current implementation might be problematic: The base Architecture class currently returns NotImplemented for patching methods. This leads to boolean evaluation of NotImplemented for is_xy_patch_available (evaluated to True). For that reason, all patches are listed as available, but their execution will finally fail because NotImplemented as return value for the patch methods is not of type Optional[bytes].

For unimplemented methods in API base classes NotImplementedError seems like a better solution if there are no good default values / default implementations available.

@CLAassistant
Copy link

CLAassistant commented Feb 21, 2026

CLA assistant check
All committers have signed the CLA.

@Alkalem
Copy link
Author

Alkalem commented Feb 21, 2026

The getters (for example get_length) might have a reasonable default, but a bad default is likely worse than an exception or the current NotImplemented return value. Because I have no experience with fileaccessor, filemetadata and interaction, I chose the error as solution.

@Alkalem Alkalem marked this pull request as ready for review February 21, 2026 22:57
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