Skip to content
This repository was archived by the owner on Sep 3, 2026. It is now read-only.
This repository was archived by the owner on Sep 3, 2026. It is now read-only.

Inner class can't be used as type #611

Closed

Description

@srittau

Please consider the following stub file:

class Foo:
    bar: Bar 
    class Bar: ...

pytype 2020.06.01 complains:

third_party/3/test2/__init__.pyi: pytype.pytd.visitors.SymbolLookupError: Couldn't find Bar in test2

As stub files should generally be considered to be using from __future__ import annotations, I believe this should work. (mypy accepts it also.) Easily worked around, so just a minor issue.

Activity

  1. srittau commented on Jun 26, 2020

    @srittau
    ContributorAuthor

    Actually, this is not related to order. Even if Bar is defined before bar, it fails. Using Foo.Bar to reference it seems to work.

  2. changed the title [-]Inner class defined after use in stub[/-] [+]Inner class can't be used as type[/+] on Jun 26, 2020
  3. rchen152 commented on Jun 26, 2020

    @rchen152
    Contributor

    Ah, I vaguely recall dealing with this a couple years ago when I was trying to figure out how to handle nested classes. I don't remember anymore why I could only get things working with the fully qualified name, but it might be time to take another look.

  4. added
    cat: stubs and 3p
    on Jan 19, 2021
  5. martindemello commented on May 25, 2022

    @martindemello
    Contributor

    this works now, after @rchen152's work on inner class support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcat: stubs and 3p

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions