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

[BUG] inlined with ':' for linters and type checkers #187

Closed
cheginit opened this issue Jan 6, 2023 · 3 comments · Fixed by #189
Closed

[BUG] inlined with ':' for linters and type checkers #187

cheginit opened this issue Jan 6, 2023 · 3 comments · Fixed by #189
Labels
bug Something isn't working changelog Changes should be written to the changelog file needs test Should be tested

Comments

@cheginit
Copy link

cheginit commented Jan 6, 2023

Describe the bug A clear and concise description of what the bug is.
pycln throws an UnsupportedCase if there's any : in the import statement. But there
are cases where we want to provide a comment to a linters or type checkers, like so:
import numpy # type: ignore.

To Reproduce Steps to reproduce the behavior:

  1. Take this code snippet:

    try:
        import numpy  # type: ignore
    except ImportError:
        numpy = None
  2. Run this Pycln command:

    $ pycln
  3. Error traceback or unexpected output (if present):

    UnsupportedCase: an import statement inlined with ':'. ⛔
  4. Unexpected fixed code (if present):

Expected behavior:

  1. Description: A clear and concise description of what you expected to happen.
    It would be helpful if using colon for after # is allowed.

  2. Expected output (if present):

  3. Expected fixed code (if present):

Environment (please complete the following information):

  • Python Version: Any
  • Pycln Version: v2.1.2
  • OS Type: macOS

Additional context Add any other context about the problem here.

@cheginit cheginit added the bug Something isn't working label Jan 6, 2023
@mskoenz
Copy link

mskoenz commented Jan 12, 2023

encountered the same, workaround with # nopycln: import. (https://hadialqattan.github.io/pycln/#/?id=pycln-skips)

@hadialqattan hadialqattan added needs documentation Should be documented needs test Should be tested changelog Changes should be written to the changelog file and removed needs documentation Should be documented labels Jan 16, 2023
@hadialqattan
Copy link
Owner

hadialqattan commented Jan 16, 2023

Hi @cheginit, briefly, the case was that Pycln was classifying comments with a colon or a semicolon as unsupported cases false positively... I've just shipped a PR(#189) that has the fix.

Thanks for reporting the bug.

@cheginit
Copy link
Author

That's great! Appreciate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working changelog Changes should be written to the changelog file needs test Should be tested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants