Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
make NoDefault immutable
  • Loading branch information
AlexWaygood committed May 10, 2024
commit ecd8b8e311a072a0ad23151fd23693c332d5e98b
8 changes: 8 additions & 0 deletions src/test_typing_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6300,6 +6300,14 @@ def test_no_call(self):
with self.assertRaises(TypeError):
NoDefault()

@skipIf(
sys.version_info[:5] == (3, 13, 0, "beta", 1),
"incorrectly raises TypeError in the first 3.13 beta"
)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

def test_immutable(self):
with self.assertRaises(AttributeError):
NoDefault.foo = 'bar'


class TypeVarInferVarianceTests(BaseTestCase):
def test_typevar(self):
Expand Down
2 changes: 2 additions & 0 deletions src/typing_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1361,6 +1361,8 @@ def TypeAlias(self, parameters):
NoDefault = typing.NoDefault
else:
class NoDefaultType:
__slots__ = ()

def __new__(cls):
return globals().get("NoDefault") or object.__new__(cls)

Expand Down