Skip to content

Commit

Permalink
remove @decorated_type_checkable from @frozen_after_init for now
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmicexplorer committed Dec 24, 2019
1 parent 481502f commit 431c42a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/python/pants/util/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,4 @@ def new_setattr(self, key: str, value: Any) -> None:
cls.__init__ = new_init # type: ignore[assignment]
cls.__setattr__ = new_setattr # type: ignore[assignment]

return frozen_after_init.define_instance_of(cls)
return cls
13 changes: 13 additions & 0 deletions tests/python/pants_test/util/test_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,19 @@ class C:
self.assertEqual(C._decorated_type_checkable_type, type(f))
self.assertTrue(f.is_instance(C))

# Check that .is_instance() is only true for exactly the decorator @g used on the class D!
@decorated_type_checkable
def g(cls):
return g.define_instance_of(cls)

@g
class D:
pass

self.assertEqual(D._decorated_type_checkable_type, type(g))
self.assertTrue(g.is_instance(D))
self.assertFalse(f.is_instance(D))


class FrozenAfterInitTest(unittest.TestCase):

Expand Down

0 comments on commit 431c42a

Please sign in to comment.