Conversation
This requires reworking a bunch of operations to not directly depend on the __dict__
| PROGRAM_TEXT = 2 # type: ClassVar[int] | ||
|
|
||
|
|
||
| PER_MODULE_OPTIONS = { |
There was a problem hiding this comment.
Maybe add a short comment why PER_MODULE_OPTIONS and OPTIONS_AFFECTING_CACHE can't be ClassVars in Options (similar to what you did for fastparse.py IIRC)?
mypy/options.py
Outdated
|
|
||
| def __eq__(self, other: object) -> bool: | ||
| return self.__class__ == other.__class__ and self.__dict__ == other.__dict__ | ||
| return isinstance(other, Options) and self.snapshot() == other.snapshot() |
There was a problem hiding this comment.
This looks like this __eq__ will become much more expensive. Have you tracked where/how it is used?
There was a problem hiding this comment.
I remembered from when I was looking into this while doing the original snapshot stuff that the answer was "not often", but I looked more closely and the answer was: in exactly one test. I just removed __eq__ and made that test use snapshot directly
| """Produce a comparable snapshot of this Option""" | ||
| d = dict(self.__dict__) | ||
| # Under mypyc, we don't have a __dict__, so we need to do worse things. | ||
| d = dict(getattr(self, '__dict__', ())) |
There was a problem hiding this comment.
So IIUC under mypyc d will start out empty?
gvanrossum
left a comment
There was a problem hiding this comment.
OK. I hope that with some (not-too-far-in-the) future mypyc we will be able to simplify this -- it feels quite gnarly. But I do want to make progress!
This reverts commit b336dc8.
These silence errors about missing type annotations for calls
like these:
```
x = getattr(o, 'a', [])
y = getattr(o, 'b', {})
```
This is basically a generalization of #5518 and other overloads we already
have.
This works around #11572. I encountered the issue in several
places when testing recent typeshed against an internal repo.
Manually cherry-picked from python/typeshed#6355.
This requires reworking a bunch of operations to not directly depend
on
__dict__