Skip to content

Fix Version.__hash__ to be consistent with __eq__. - #208

Open
selsky wants to merge 1 commit into
aboutcode-org:mainfrom
selsky:issue-189
Open

Fix Version.__hash__ to be consistent with __eq__.#208
selsky wants to merge 1 commit into
aboutcode-org:mainfrom
selsky:issue-189

Conversation

@selsky

@selsky selsky commented Aug 20, 2026

Copy link
Copy Markdown

Two bugs:

  1. hash uses _unparsed (raw string) but eq uses _parsed, so "1" == "1.0" but hash differs.
  2. _normalize doesn't recurse into sublists, so _parsed isn't fully canonical: "1-2-0" gets (1,(2,())) instead of (1,(2,)).

Fix _normalize to recurse into sublists first, making _parsed canonical, then use hash(_parsed) for hash.

Fixes #189

Two bugs:
1. __hash__ uses _unparsed (raw string) but __eq__ uses _parsed, so "1" ==
   "1.0" but hash differs.
2. _normalize doesn't recurse into sublists, so _parsed isn't fully canonical:
   "1-2-0" gets (1,(2,())) instead of (1,(2,)).

Fix _normalize to recurse into sublists first, making _parsed canonical, then
use hash(_parsed) for __hash__.

Fixes aboutcode-org#189

Signed-off-by: Matt Selsky <matthew.selsky@twosigma.com>
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.

maven.py: Version.__hash__ inconsistent with __eq__ due to _unparsed hash and non-recursive _normalize

1 participant