Skip to content
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

Compatibility issues with flake8 #63

Open
friggog opened this issue Apr 11, 2022 · 2 comments
Open

Compatibility issues with flake8 #63

friggog opened this issue Apr 11, 2022 · 2 comments

Comments

@friggog
Copy link

friggog commented Apr 11, 2022

After the syntax changes in 2.0 flake8 now gives false positives - I believe this is a pyflakes issue but reporting here too for awareness
See: PyCQA/pyflakes#687

def unproject(points_2d: NDArray[Shape["N, 2"], Float], camera_object: Camera) -> NDArray[Shape["N, 3"], Float]:
    ....

Throws

F722 syntax error in forward annotation 'N, *'
F821 undefined name 'N'
@ramonhagenaars
Copy link
Owner

Thank you for reporting this.

pyflakes gives this false positive because it does not deduce where Shape is coming from (as e.g. MyPy does). It looks no further than that single line and concludes that no type hint other than typing.Literal may contain a string value. Fun fact: Shape actually is an alias for Literal...

I'm afraid there's little nptyping can do here. I think you're left with 2 options:

  1. make pyflakes ignore that line or that/those code/codes in general;
  2. use typing.Literal instead of nptyping.Shape: this is accepted by nptyping (but it looks less nice imo).

@RemyLau
Copy link

RemyLau commented Aug 10, 2022

I'm encountering the same issue in this post.

RemyLau added a commit to krishnanlab/PecanPy that referenced this issue Aug 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants