Skip to content

Commit f9f0cf7

Browse files
Use __future__ imports in scripts (#5301)
1 parent eaa10ad commit f9f0cf7

11 files changed

+25
-4
lines changed

Diff for: scripts/_utils.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
import re
24
from pathlib import Path
35

Diff for: scripts/add_plugin.py

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
--url https://pypi.org/project/flake8-pie/
99
--prefix PIE
1010
"""
11+
from __future__ import annotations
1112

1213
import argparse
1314

Diff for: scripts/add_rule.py

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
--code 807 \
1010
--linter flake8-pie
1111
"""
12+
from __future__ import annotations
1213

1314
import argparse
1415
import subprocess

Diff for: scripts/check_docs_formatted.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
#!/usr/bin/env python3
22
"""Check code snippets in docs are formatted by black."""
3+
from __future__ import annotations
4+
35
import argparse
46
import os
57
import re
68
import textwrap
7-
from collections.abc import Sequence
89
from pathlib import Path
910
from re import Match
11+
from typing import TYPE_CHECKING
1012

1113
import black
1214
from black.mode import Mode, TargetVersion
1315
from black.parsing import InvalidInput
1416

17+
if TYPE_CHECKING:
18+
from collections.abc import Sequence
19+
1520
TARGET_VERSIONS = ["py37", "py38", "py39", "py310", "py311"]
1621
SNIPPED_RE = re.compile(
1722
r"(?P<before>^(?P<indent> *)```\s*python\n)"

Diff for: scripts/ecosystem_all_check.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
44
It's a less elaborate, more hacky version of check_ecosystem.py
55
"""
6+
from __future__ import annotations
67

78
import json
89
import subprocess
910
import sys
1011
from pathlib import Path
1112
from subprocess import CalledProcessError
12-
from typing import NamedTuple, Optional
13+
from typing import NamedTuple
1314

1415
from tqdm import tqdm
1516

@@ -19,7 +20,7 @@ class Repository(NamedTuple):
1920

2021
org: str
2122
repo: str
22-
ref: Optional[str]
23+
ref: str | None
2324

2425

2526
def main() -> None:

Diff for: scripts/generate_known_standard_library.py

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
66
Only the generation of the file has been modified for use in this project.
77
"""
8+
from __future__ import annotations
89

910
from pathlib import Path
1011

Diff for: scripts/generate_mkdocs.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
"""Generate an MkDocs-compatible `docs` and `mkdocs.yml` from the README.md."""
2+
from __future__ import annotations
3+
24
import argparse
35
import re
46
import shutil

Diff for: scripts/pyproject.toml

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "scripts"
33
version = "0.0.1"
44
dependencies = ["sphinx"]
5-
requires-python = ">=3.9"
5+
requires-python = ">=3.8"
66

77
[tool.black]
88
line-length = 88
@@ -21,5 +21,8 @@ ignore = [
2121
"FBT", # flake8-boolean-trap
2222
]
2323

24+
[tool.ruff.isort]
25+
required-imports = ["from __future__ import annotations"]
26+
2427
[tool.ruff.pydocstyle]
2528
convention = "pep257"

Diff for: scripts/transform_readme.py

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
targets have different strategies for rendering light- and dark-mode images. This script
55
adjusts the images in the README.md to support the given target.
66
"""
7+
from __future__ import annotations
8+
79
import argparse
810
from pathlib import Path
911

Diff for: scripts/update_ambiguous_characters.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
"""Generate the confusables.rs file from the VS Code ambiguous.json file."""
2+
from __future__ import annotations
3+
24
import json
35
import subprocess
46
from pathlib import Path

Diff for: scripts/update_schemastore.py

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
to a new branch tagged with the ruff git hash. You should see a URL to create the PR
55
to schemastore in the CLI.
66
"""
7+
from __future__ import annotations
78

89
import json
910
from pathlib import Path

0 commit comments

Comments
 (0)