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

INP001 outputs the code of the file which is part of an implicit namespace package #12291

Closed
adamtheturtle opened this issue Jul 11, 2024 · 5 comments · Fixed by #12304
Closed
Assignees
Labels
cli Related to the command-line interface

Comments

@adamtheturtle
Copy link

adamtheturtle commented Jul 11, 2024

ruff 0.4.10 Edit: I pasted wrong! ruff 0.5.1

This makes me think that the code has an error in it, that I am looking for, but that is not the case.

@zanieb
Copy link
Member

zanieb commented Jul 11, 2024

Hi! Can you share a brief example?

@adamtheturtle
Copy link
Author

Sure @zanieb ,

I create:

foo/bar/example.py

with the contents:

STRING = "This code is not relevant"
STRING1 = "This code is not relevant"
STRING2 = "This code is not relevant"
STRING3 = "This code is not relevant"
> ruff check foo/bar/
foo/bar/example.py:1:1: INP001 File `foo/bar/example.py` is part of an implicit namespace package. Add an `__init__.py`.
  |
1 | STRING = "This code is not relevant"
  |  INP001
2 | STRING1 = "This code is not relevant"
3 | STRING2 = "This code is not relevant"
  |

I infer from the output that there is a problem to be fixed on line 1 of the file.

@dhruvmanila
Copy link
Member

I think file level diagnostics by default uses an empty range at the start of the file which is what you're seeing here.

@dhruvmanila dhruvmanila added the cli Related to the command-line interface label Jul 12, 2024
@charliermarsh
Copy link
Member

Lets omit the code frame for empty files?

@dhruvmanila
Copy link
Member

Lets omit the code frame for empty files?

Yeah, that seems reasonable. I think we would want to check for an empty range at byte 0 (TextRange::new(0, 0)) which is where this is being raised.

@charliermarsh charliermarsh self-assigned this Jul 12, 2024
charliermarsh added a commit that referenced this issue Jul 12, 2024
## Summary

Closes #12291.

## Test Plan

```shell
❯ cargo run check ../uv/foo --select INP
/Users/crmarsh/workspace/uv/foo/bar/baz.py:1:1: INP001 File `/Users/crmarsh/workspace/uv/foo/bar/baz.py` is part of an implicit namespace package. Add an `__init__.py`.
Found 1 error.
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli Related to the command-line interface
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants