Skip to content

Cannot import TYPE_CHECKING from typing / TYPE_CHECKING not ignored #824

Description

@1998marcom-nelson

Python static analysis fails on some codon-specific code (i.e. u32, u64 used as types). An handy solution could be including for the type checkers a small section where necessary, like:

from typing import TYPE_CHECKING
if TYPE_CHECKING:
    u64 = int
    u32 = int

This should allow standard type checkers and static analysis to work decently with codon.

As of now, the above code results in the compilation error:

error: cannot import name 'TYPE_CHECKING' from 'typing'

A simple fix, I believe, would be adding TYPE_CHECKING = False in typing

EDIT: I am not sure the codon compiler skips entirely a block that is 100% sure not to be executed. If that's not the case, it might not be as easy :')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions