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

Make validation errors immutable #610

Open
4 of 5 tasks
dsleiter opened this issue May 13, 2021 · 0 comments
Open
4 of 5 tasks

Make validation errors immutable #610

dsleiter opened this issue May 13, 2021 · 0 comments
Labels
category: enhancement improvements of code or code behavior topic: validator issues related to validation of files

Comments

@dsleiter
Copy link
Contributor

In #609 (assuming some version of it is accepted), eq and hash functions were defined for validation Errors in order to make them comparable. Equality is based on the name, reason, and location attributes, however the location attribute is mutable which means that the hash value could change if the location value is changed. This opens the door for potential bugs in the future.

Instead, it would be better to make Errors immutable, or at least remove the setter for location.

This will require an update to the way attribute validation errors are created, as they use the location setter.

Is your feature request related to a problem? Please describe.
No, this is not an existing problem, but the current implementation leaves opportunities for bugs and is more complex.

Describe the solution you'd like

  1. refactor the attribute validation to not require the location setter
  2. either make Error immutable or at the minimum remove the location setter

Describe alternatives you've considered
Remove the hash implementation for Error and refactor GroupValidator._remove_duplicates to not require a hashable object.

Additional context
Ref: #528

Checklist

  • Have you ensured the feature or change was not already reported ?
  • Have you included a brief and descriptive title?
  • Have you included a clear description of the problem you are trying to solve?
  • Have you included a minimal code snippet that reproduces the issue you are encountering?
  • Have you checked our Contributing document?
@dsleiter dsleiter added the category: enhancement improvements of code or code behavior label May 13, 2021
@rly rly added the topic: validator issues related to validation of files label Jan 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: enhancement improvements of code or code behavior topic: validator issues related to validation of files
Projects
None yet
Development

No branches or pull requests

2 participants