-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Metaclass related internal error #28
Comments
I modified def get_metaclass_hook(
self, fullname: str
) -> Optional[Callable[[ClassDefContext], None]]:
def analyze_metaclass(ctx: ClassDefContext) -> None:
metaclass = cast(NameExpr, ctx.cls.metaclass)
if isinstance(metaclass.node, Var):
return
info = cast(TypeInfo, metaclass.node)
expected = "zope.interface.interface.InterfaceClass"
if info and any(node.fullname == expected for node in info.mro):
self.log(f"Found zope interface: {ctx.cls.fullname}")
md = self._get_metadata(ctx.cls.info)
md["is_interface"] = True
return analyze_metaclass ...after looking at if isinstance(sym.node, Var) and isinstance(get_proper_type(sym.node.type), AnyType):
# 'Any' metaclass -- just ignore it.
#
# TODO: A better approach would be to record this information
# and assume that the type object supports arbitrary
# attributes, similar to an 'Any' base class.
return That made the error go away |
Yeah, these casts in front of |
I've got a small test-case:
I believe mypy gives you a |
Oh, thanks, I can add a test too then! |
my mypy.ini:
And the run: $ PYTHONPATH=$(pwd) mypy --show-traceback --show-error-codes --config mypy.ini z.py
z.py:4: error: INTERNAL ERROR -- Please try using mypy master on Github:
https://mypy.rtfd.io/en/latest/common_issues.html#using-a-development-mypy-build
Please report a bug at https://github.com/python/mypy/issues
version: 0.800
Traceback (most recent call last):
File "mypy/semanal.py", line 4835, in accept
File "mypy/nodes.py", line 950, in accept
File "mypy/semanal.py", line 1048, in visit_class_def
File "mypy/semanal.py", line 1125, in analyze_class
File "mypy/semanal.py", line 1134, in analyze_class_body_common
File "mypy/semanal.py", line 1187, in apply_class_plugin_hooks
File "/home/arni/.config/dohop/tools_venv3/lib/python3.8/site-packages/mypy_zope/plugin.py", line 270, in analyze_metaclass
if info and any(node.fullname == expected for node in info.mro):
AttributeError: 'Var' object has no attribute 'mro'
z.py:4: : note: use --pdb to drop into pdb |
Do you want a new release with this fix? |
Yes please :) |
0.2.10 is released |
Thanks. We hit this bug in our regression tests, so a new release helps. |
Hi,
We just ran into this stacktrace:
I haven't had time find exactly which piece of code is causing this, but will do so as soon as I can.
EDIT: this was tested on mypy 0.800. The line which hit this was something like this:
The text was updated successfully, but these errors were encountered: