mirror of
https://github.com/astral-sh/ruff.git
synced 2025-12-23 09:19:39 +00:00
[ty] Disable possibly-missing-imports by default (#22041)
@carljm put forth a reasonably compelling argument that just disabling this lint might be advisable. If we agree, here's the implementation. * Fixes https://github.com/astral-sh/ty/issues/309 --------- Co-authored-by: Carl Meyer <carl@astral.sh>
This commit is contained in:
parent
45bbb4cbff
commit
2e44a861cb
5 changed files with 35 additions and 35 deletions
1
.github/mypy-primer-ty.toml
vendored
1
.github/mypy-primer-ty.toml
vendored
|
|
@ -4,5 +4,6 @@
|
|||
# Enable off-by-default rules.
|
||||
[rules]
|
||||
possibly-unresolved-reference = "warn"
|
||||
possibly-missing-import = "warn"
|
||||
unused-ignore-comment = "warn"
|
||||
division-by-zero = "warn"
|
||||
|
|
|
|||
64
crates/ty/docs/rules.md
generated
64
crates/ty/docs/rules.md
generated
|
|
@ -2511,38 +2511,6 @@ class A:
|
|||
A()[0] # TypeError: 'A' object is not subscriptable
|
||||
```
|
||||
|
||||
## `possibly-missing-import`
|
||||
|
||||
<small>
|
||||
Default level: <a href="../rules.md#rule-levels" title="This lint has a default level of 'warn'."><code>warn</code></a> ·
|
||||
Added in <a href="https://github.com/astral-sh/ty/releases/tag/0.0.1-alpha.22">0.0.1-alpha.22</a> ·
|
||||
<a href="https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20possibly-missing-import" target="_blank">Related issues</a> ·
|
||||
<a href="https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L1575" target="_blank">View source</a>
|
||||
</small>
|
||||
|
||||
|
||||
**What it does**
|
||||
|
||||
Checks for imports of symbols that may be missing.
|
||||
|
||||
**Why is this bad?**
|
||||
|
||||
Importing a missing module or name will raise a `ModuleNotFoundError`
|
||||
or `ImportError` at runtime.
|
||||
|
||||
**Examples**
|
||||
|
||||
```python
|
||||
# module.py
|
||||
import datetime
|
||||
|
||||
if datetime.date.today().weekday() != 6:
|
||||
a = 1
|
||||
|
||||
# main.py
|
||||
from module import a # ImportError: cannot import name 'a' from 'module'
|
||||
```
|
||||
|
||||
## `redundant-cast`
|
||||
|
||||
<small>
|
||||
|
|
@ -2778,6 +2746,38 @@ Dividing by zero raises a `ZeroDivisionError` at runtime.
|
|||
5 / 0
|
||||
```
|
||||
|
||||
## `possibly-missing-import`
|
||||
|
||||
<small>
|
||||
Default level: <a href="../rules.md#rule-levels" title="This lint has a default level of 'ignore'."><code>ignore</code></a> ·
|
||||
Added in <a href="https://github.com/astral-sh/ty/releases/tag/0.0.1-alpha.22">0.0.1-alpha.22</a> ·
|
||||
<a href="https://github.com/astral-sh/ty/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20possibly-missing-import" target="_blank">Related issues</a> ·
|
||||
<a href="https://github.com/astral-sh/ruff/blob/main/crates%2Fty_python_semantic%2Fsrc%2Ftypes%2Fdiagnostic.rs#L1575" target="_blank">View source</a>
|
||||
</small>
|
||||
|
||||
|
||||
**What it does**
|
||||
|
||||
Checks for imports of symbols that may be missing.
|
||||
|
||||
**Why is this bad?**
|
||||
|
||||
Importing a missing module or name will raise a `ModuleNotFoundError`
|
||||
or `ImportError` at runtime.
|
||||
|
||||
**Examples**
|
||||
|
||||
```python
|
||||
# module.py
|
||||
import datetime
|
||||
|
||||
if datetime.date.today().weekday() != 6:
|
||||
a = 1
|
||||
|
||||
# main.py
|
||||
from module import a # ImportError: cannot import name 'a' from 'module'
|
||||
```
|
||||
|
||||
## `possibly-unresolved-reference`
|
||||
|
||||
<small>
|
||||
|
|
|
|||
|
|
@ -1594,7 +1594,7 @@ declare_lint! {
|
|||
pub(crate) static POSSIBLY_MISSING_IMPORT = {
|
||||
summary: "detects possibly missing imports",
|
||||
status: LintStatus::stable("0.0.1-alpha.22"),
|
||||
default_level: Level::Warn,
|
||||
default_level: Level::Ignore,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -89,7 +89,6 @@ Settings: Settings {
|
|||
"positional-only-parameter-as-kwarg": Error (Default),
|
||||
"possibly-missing-attribute": Warning (Default),
|
||||
"possibly-missing-implicit-call": Warning (Default),
|
||||
"possibly-missing-import": Warning (Default),
|
||||
"raw-string-type-annotation": Error (Default),
|
||||
"redundant-cast": Warning (Default),
|
||||
"static-assert-error": Error (Default),
|
||||
|
|
|
|||
2
ty.schema.json
generated
2
ty.schema.json
generated
|
|
@ -926,7 +926,7 @@
|
|||
"possibly-missing-import": {
|
||||
"title": "detects possibly missing imports",
|
||||
"description": "## What it does\nChecks for imports of symbols that may be missing.\n\n## Why is this bad?\nImporting a missing module or name will raise a `ModuleNotFoundError`\nor `ImportError` at runtime.\n\n## Examples\n```python\n# module.py\nimport datetime\n\nif datetime.date.today().weekday() != 6:\n a = 1\n\n# main.py\nfrom module import a # ImportError: cannot import name 'a' from 'module'\n```",
|
||||
"default": "warn",
|
||||
"default": "ignore",
|
||||
"oneOf": [
|
||||
{
|
||||
"$ref": "#/definitions/Level"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue