Skip to content

Commit

Permalink
fix mypy type error in meta.py (#8509)
Browse files Browse the repository at this point in the history
### Problem

`pants.util.meta.frozen_after_init` has a couple mypy type checking errors, specifically at: https://github.com/pantsbuild/pants/blob/00c4f8cc4a997f80a34f78b6d5fd6fca746befa7/src/python/pants/util/meta.py#L140-L144

This caused a failure on master, see https://travis-ci.org/pantsbuild/pants/jobs/600466692.

### Solution

- Add `# type: ignore` to the offending lines until #8496 is merged.

### Result

CI is unbroken!
  • Loading branch information
cosmicexplorer authored Oct 21, 2019
1 parent 4c72cfd commit 9ad14d3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/python/pants/util/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ def new_setattr(self, key: str, value: Any) -> None:

cls.__init__ = new_init # type: ignore
cls.__setattr__ = new_setattr # type: ignore
setattr(cls, frozen_after_init.sentinel_attr, True)
setattr(cls, frozen_after_init.sentinel_attr, True) # type: ignore

return cls

frozen_after_init.sentinel_attr = '_frozen_after_init'
frozen_after_init.sentinel_attr = '_frozen_after_init' # type: ignore
2 changes: 1 addition & 1 deletion tests/python/pants_test/engine/test_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,5 +428,5 @@ def f(x: NonFrozenDataclass) -> int:
with self.assertRaisesWithMessage(TypeError, dedent("""\
@rule output type <class 'pants_test.engine.test_scheduler.NonFrozenDataclass'> is a dataclass declared without `frozen=True`, or without both `unsafe_hash=True` and the `@frozen_after_init` decorator! The engine requires that fields in params are immutable for stable hashing!""")):
@rule
def f(x: int) -> NonFrozenDataclass:
def g(x: int) -> NonFrozenDataclass:
return NonFrozenDataclass(x=x)

0 comments on commit 9ad14d3

Please sign in to comment.