[New-bugs-announce] [issue43746] Weird typing annotation closure behavior

conchylicultor report at bugs.python.org
Tue Apr 6 06:37:43 EDT 2021

New submission from conchylicultor <etiennefg.pot at gmail.com>:

I observe some strange closure behavior for typing annotations when the name is defined

x: x = 1  # Works, __annotation__ == {'x': 1}

This creates issue, for example:

from ... import losses

class A:
  # AttributeError: 'Losses' object has no attribute 'Losses'
  losses: losses.Losses = losses.Losses()

messages: 390304
nosy: conchylicultor
priority: normal
severity: normal
status: open
title: Weird typing annotation closure behavior

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list