Skip to content

Commit

Permalink
Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
brentyi committed Dec 18, 2024
1 parent 55f0e20 commit f07374d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/tyro/_unsafe_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ def wrapped_f(*args, **kwargs):


def unsafe_hash(obj: Any) -> Any:
"""We include the types to match functools.
Some context: https://github.com/brentyi/tyro/issues/214"""
try:
return type(obj), hash(obj)
except TypeError:
Expand Down
5 changes: 3 additions & 2 deletions tests/test_dcargs.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@
)

import pytest
from typing_extensions import Annotated, Final, Literal, TypeAlias, runtime_checkable

import tyro
from typing_extensions import Annotated, Final, Literal, TypeAlias, runtime_checkable


def test_no_args() -> None:

Check failure on line 28 in tests/test_dcargs.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (I001)

tests/test_dcargs.py:1:1: I001 Import block is un-sorted or un-formatted
Expand Down Expand Up @@ -957,6 +956,8 @@ class NumericTower:


def test_runtime_checkable_edge_case() -> None:
"""From Kevin Black: https://github.com/brentyi/tyro/issues/214"""

@runtime_checkable
class DummyProtocol(Protocol):
pass
Expand Down
2 changes: 2 additions & 0 deletions tests/test_py311_generated/test_dcargs_generated.py
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,8 @@ class NumericTower:


def test_runtime_checkable_edge_case() -> None:
"""From Kevin Black: https://github.com/brentyi/tyro/issues/214"""

@runtime_checkable
class DummyProtocol(Protocol):
pass
Expand Down

0 comments on commit f07374d

Please sign in to comment.