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

change isinstance(..., frozenset) to abc_Set, pt2 #825

Merged
merged 1 commit into from
Feb 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions loopy/translation_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"""

import collections
from collections.abc import Set as abc_Set
from dataclasses import field, dataclass, replace
from typing import FrozenSet, Optional, TYPE_CHECKING, Mapping, Callable, Union, Any
from warnings import warn
Expand Down Expand Up @@ -195,7 +196,8 @@ class TranslationUnit:
entrypoints: FrozenSet[str]

def __post_init__(self):
assert isinstance(self.entrypoints, frozenset)

assert isinstance(self.entrypoints, abc_Set)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please explain why this is needed? Thanks!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, these changes are necessary for compatibility with alternative set implementations, in particular https://github.com/matthiasdiener/orderedsets.

assert isinstance(self.callables_table, Map)

object.__setattr__(self, "_program_executor_cache", {})
Expand Down Expand Up @@ -239,7 +241,7 @@ def with_entrypoints(self, entrypoints):
entrypoints = frozenset([e.strip() for e in
entrypoints.split(",")])

assert isinstance(entrypoints, frozenset)
assert isinstance(entrypoints, abc_Set)

return self.copy(entrypoints=entrypoints)

Expand Down
Loading