apache / apache/beam

typehints.TypeVariable issues with __hash__

Open
#18,633 0 comments 0 reactions 0 assignees View on GitHub
bug core P3 python
Dominant language
Java
Stars
8.7k
Forks
4.7k
Avg merge
2d 2h
Merged PRs (30d)
205

Description

This class currently does not define a __hash__ function. This defies the assumption made by sets and dicts which contain TypeConstraint objects.

In Python 3, classes which define ___eq___ also need to explicitly define ___hash___ to be hashable. However, this causes _combiners_test.CombineTest.test_to_list_and_to_dict_ to throw an error in slow_stream.py (adding NoneType and long).

There are multiple TypeVariable instances with name 'K' or 'V' throughout the codebase. The equality of these instances may possibly cause issues.

 

Imported from Jira [BEAM-3730](https://issues.apache.org/jira/browse/BEAM-3730). Original Jira may contain additional context.
Reported by: luke-zhu.

Contributor guide

Open the contributing guide

Research direction

Start with the TypeVariable and TypeConstraint definitions and reproduce _combiners_test.CombineTest.test_to_list_and_to_dict_, which currently fails in slow_stream.py when adding NoneType and long. Trace the equality and hashing behavior of TypeVariable instances, including repeated names such as K and V. Done means the relevant collections remain usable and the named test passes without introducing incorrect equality between distinct variables.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-engineering
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.