-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Allow initialization of MeasurementKeys with empty strings #4445
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
Allow initialization of MeasurementKeys with empty strings #4445
Conversation
- An empty string is still a string and is used occasionally as a placeholder in user code. We should support creation of measurement keys with empty strings.
Question to cirq-maintainers. Is this sufficient to prevent problems with backward incompatibility or should we roll back instead? |
@@ -41,7 +41,7 @@ class MeasurementKey: | |||
path: Tuple[str, ...] = dataclasses.field(default_factory=tuple) | |||
|
|||
def __post_init__(self): | |||
if not self.name: | |||
if self.name is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name
has annotated type str
, not Optional[str]
. How can it be None
? Just from the code it looks like this should be an isinstance check, but I know you intend None to be some kind of placeholder instead.
Can you add a reference to the PR that introduced the change so we have it on the record. GitHub will also show this PR to any future viewers of the previous one |
The PR introducing this change was intentionally breaking since
So, either we could keep this inconsistency, change |
@smitsanghavi At the very least, we have to at least temporarily roll this change back, since a significant amount of internal code uses the empty string as a placeholder for "anonymous" measurements. If we want to re-break this, we need to migrate that code first. |
…b#4445) - An empty string is still a string and is used occasionally as a placeholder in user code. We should support creation of measurement keys with empty strings.
…b#4445) - An empty string is still a string and is used occasionally as a placeholder in user code. We should support creation of measurement keys with empty strings.
placeholder in user code. We should support creation of measurement
keys with empty strings.