Skip to content

Commit

Permalink
Use __future__ imports in scripts (#5301)
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh authored Jun 22, 2023
1 parent eaa10ad commit f9f0cf7
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 4 deletions.
2 changes: 2 additions & 0 deletions scripts/_utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import re
from pathlib import Path

Expand Down
1 change: 1 addition & 0 deletions scripts/add_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
--url https://pypi.org/project/flake8-pie/
--prefix PIE
"""
from __future__ import annotations

import argparse

Expand Down
1 change: 1 addition & 0 deletions scripts/add_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
--code 807 \
--linter flake8-pie
"""
from __future__ import annotations

import argparse
import subprocess
Expand Down
7 changes: 6 additions & 1 deletion scripts/check_docs_formatted.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
#!/usr/bin/env python3
"""Check code snippets in docs are formatted by black."""
from __future__ import annotations

import argparse
import os
import re
import textwrap
from collections.abc import Sequence
from pathlib import Path
from re import Match
from typing import TYPE_CHECKING

import black
from black.mode import Mode, TargetVersion
from black.parsing import InvalidInput

if TYPE_CHECKING:
from collections.abc import Sequence

TARGET_VERSIONS = ["py37", "py38", "py39", "py310", "py311"]
SNIPPED_RE = re.compile(
r"(?P<before>^(?P<indent> *)```\s*python\n)"
Expand Down
5 changes: 3 additions & 2 deletions scripts/ecosystem_all_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
It's a less elaborate, more hacky version of check_ecosystem.py
"""
from __future__ import annotations

import json
import subprocess
import sys
from pathlib import Path
from subprocess import CalledProcessError
from typing import NamedTuple, Optional
from typing import NamedTuple

from tqdm import tqdm

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

org: str
repo: str
ref: Optional[str]
ref: str | None


def main() -> None:
Expand Down
1 change: 1 addition & 0 deletions scripts/generate_known_standard_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Only the generation of the file has been modified for use in this project.
"""
from __future__ import annotations

from pathlib import Path

Expand Down
2 changes: 2 additions & 0 deletions scripts/generate_mkdocs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""Generate an MkDocs-compatible `docs` and `mkdocs.yml` from the README.md."""
from __future__ import annotations

import argparse
import re
import shutil
Expand Down
5 changes: 4 additions & 1 deletion scripts/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "scripts"
version = "0.0.1"
dependencies = ["sphinx"]
requires-python = ">=3.9"
requires-python = ">=3.8"

[tool.black]
line-length = 88
Expand All @@ -21,5 +21,8 @@ ignore = [
"FBT", # flake8-boolean-trap
]

[tool.ruff.isort]
required-imports = ["from __future__ import annotations"]

[tool.ruff.pydocstyle]
convention = "pep257"
2 changes: 2 additions & 0 deletions scripts/transform_readme.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
targets have different strategies for rendering light- and dark-mode images. This script
adjusts the images in the README.md to support the given target.
"""
from __future__ import annotations

import argparse
from pathlib import Path

Expand Down
2 changes: 2 additions & 0 deletions scripts/update_ambiguous_characters.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""Generate the confusables.rs file from the VS Code ambiguous.json file."""
from __future__ import annotations

import json
import subprocess
from pathlib import Path
Expand Down
1 change: 1 addition & 0 deletions scripts/update_schemastore.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
to a new branch tagged with the ruff git hash. You should see a URL to create the PR
to schemastore in the CLI.
"""
from __future__ import annotations

import json
from pathlib import Path
Expand Down

0 comments on commit f9f0cf7

Please sign in to comment.