Skip to content

Add Semantic Error Test for LateFutureImport#17612

Merged
ntBre merged 1 commit intoastral-sh:mainfrom
maxmynter:extend-semantic-test-coverage
Apr 25, 2025
Merged

Add Semantic Error Test for LateFutureImport#17612
ntBre merged 1 commit intoastral-sh:mainfrom
maxmynter:extend-semantic-test-coverage

Conversation

@maxmynter
Copy link
Contributor

Adresses a question in #17526.

Summary

Adds a syntax error test for __future__ import not at top of file.

Question:

Is this a redundant with

"""Docstring"""
from __future__ import absolute_import
from collections import namedtuple
from __future__ import print_function
import __future__
and
"""Docstring"""
"""Non-docstring"""
from __future__ import absolute_import

which test pyflake F404?

Test Plan

This is a test

@github-actions
Copy link
Contributor

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@ntBre ntBre self-assigned this Apr 24, 2025
@ntBre
Copy link
Contributor

ntBre commented Apr 24, 2025

Yeah I probably could have left the existing ruff rules out of the issue because they should be covered well by existing tests. I think I added a couple of new tests previously just for convenience or for especially tricky cases not covered by the existing tests.

But it doesn't really hurt to have more tests, so I'll approve and merge this if you want, or we can just mark it covered in the table. Up to you!

This is exactly the kind of PR I had in mind otherwise though, thank you!

@ntBre ntBre added the internal An internal refactor or improvement label Apr 24, 2025
@maxmynter
Copy link
Contributor Author

Nice, let's merge this then!

I can take care of some additional test cases next week. But will make a new PR for these :)

@maxmynter maxmynter marked this pull request as ready for review April 25, 2025 12:08
@ntBre ntBre merged commit 3f84e75 into astral-sh:main Apr 25, 2025
33 checks passed
dcreager added a commit that referenced this pull request Apr 25, 2025
* main: (24 commits)
  [`airflow`] Extend `AIR301` rule (#17598)
  [`airflow`] update existing `AIR302` rules with better suggestions (#17542)
  red_knot_project: sort diagnostics from checking files
  [red-knot] fix detecting a metaclass on a not-explicitly-specialized generic base (#17621)
  [red-knot] fix inheritance-cycle detection for generic classes (#17620)
  [`pylint`] Detect `global` declarations in module scope (`PLE0118`) (#17411)
  Add Semantic Error Test for LateFutureImport (#17612)
  [red-knot] change TypeVarInstance to be interned, not tracked (#17616)
  [red-knot] Special case `@final`, `@override` (#17608)
  [red-knot] add TODO comment in specialization code (#17615)
  [`semantic-syntax-errors`] test for `LoadBeforeGlobalDeclaration` - ruff linter (#17592)
  [syntax-errors] `nonlocal` declaration at module level (#17559)
  [`airflow`] Apply auto fix to cases where name has been changed in Airflow 3 (`AIR311`) (#17571)
  [syntax-errors] Make `async-comprehension-in-sync-comprehension` more specific (#17460)
  Bump 0.11.7 (#17613)
  [red-knot] Use iterative approach to collect overloads (#17607)
  red_knot_python_semantic: avoid Rust's screaming snake case convention in mdtest
  red_knot_python_semantic: improve diagnostics for unsupported boolean conversions
  red_knot_python_semantic: add "return type span" helper method
  red_knot_python_semantic: move parameter span helper method
  ...
dcreager added a commit that referenced this pull request Apr 26, 2025
* main: (27 commits)
  [red-knot] Add new property tests for subtyping with "bottom" callable (#17635)
  [red-knot] Create generic context for generic classes lazily (#17617)
  ruff_db: add tests for annotations with no ranges
  [`airflow`] Extend `AIR301` rule (#17598)
  [`airflow`] update existing `AIR302` rules with better suggestions (#17542)
  red_knot_project: sort diagnostics from checking files
  [red-knot] fix detecting a metaclass on a not-explicitly-specialized generic base (#17621)
  [red-knot] fix inheritance-cycle detection for generic classes (#17620)
  [`pylint`] Detect `global` declarations in module scope (`PLE0118`) (#17411)
  Add Semantic Error Test for LateFutureImport (#17612)
  [red-knot] change TypeVarInstance to be interned, not tracked (#17616)
  [red-knot] Special case `@final`, `@override` (#17608)
  [red-knot] add TODO comment in specialization code (#17615)
  [`semantic-syntax-errors`] test for `LoadBeforeGlobalDeclaration` - ruff linter (#17592)
  [syntax-errors] `nonlocal` declaration at module level (#17559)
  [`airflow`] Apply auto fix to cases where name has been changed in Airflow 3 (`AIR311`) (#17571)
  [syntax-errors] Make `async-comprehension-in-sync-comprehension` more specific (#17460)
  Bump 0.11.7 (#17613)
  [red-knot] Use iterative approach to collect overloads (#17607)
  red_knot_python_semantic: avoid Rust's screaming snake case convention in mdtest
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal An internal refactor or improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants