Hello, I love Python annotations and I use them in all my projects where backwards compatiblity to 2.x is not an issue, really helps with documenting intent (and code completion in PyCharm!).
But one thing that I find really puzzling is why CPython's "Annotations engine" can't be fixed to support referencing a name before it is defined. For example, this leads to a runtime error: class Foo: def some_meth(self, other_foo: Foo): pass This seems like a wart; having to use a string is just counter-intuitive and ugly and takes away from Python's beauty, simplicity and cleanness. As a workaround, we define our own decorator that allows us to mark a class as a "forward declaration for annotation", like this: @fwd_declaration class Foo: pass Then when the actual "class Foo" definition has Foo as annotation, the Foo is the forward-declared one, keeps the interpreter happy. So it does the job but because it is non-standard, IDE's don't know how to make use of this information, and it is a bit annoying to have to write. Is there really no way that this will *ever* be fixed so we don't need to use strings or forward declaration hack? -- Oliver My StackOverflow contributions My CodeProject articles My Github projects My SourceForget.net projects
_______________________________________________ pytest-dev mailing list pytest-dev@python.org https://mail.python.org/mailman/listinfo/pytest-dev