Skip to content

Add strict parameter to remove() TaggableManager.remove() method (fixes #928)#937

Open
Dzhud wants to merge 1 commit intojazzband:masterfrom
Dzhud:fix-issue-928
Open

Add strict parameter to remove() TaggableManager.remove() method (fixes #928)#937
Dzhud wants to merge 1 commit intojazzband:masterfrom
Dzhud:fix-issue-928

Conversation

@Dzhud
Copy link

@Dzhud Dzhud commented Mar 16, 2026

Summary

Fixes #928

This PR adds an optional strict parameter to the TaggableManager.remove() method, allowing users to opt-in to receiving an error when attempting to remove tags that are not associated with the object.

Changes

managers.py: Added strict=False parameter to remove() method. When strict=True, raises ValueError listing any tags not found on the object.
tests.py: Added 4 test cases covering the new functionality.
CHANGELOG.rst: Added entry for the new feature.
api.rst: Updated documentation with the new parameter.

Behaviour

# Default behavior (backwards compatible) - silently ignores missing tags
apple.tags.add("red", "green")
apple.tags.remove("blue")  # No error, nothing happens

# Strict mode - raises ValueError for missing tags
apple.tags.remove("blue", strict=True)  
# ValueError: The following tags are not associated with this object: blue

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.

Tags Manager does not show an error if we try to remove a tag that is non-existent.

1 participant