Use __future__ imports in scripts (#5301)

This commit is contained in:
Charlie Marsh 2023-06-22 11:40:16 -04:00 committed by GitHub
parent eaa10ad2d9
commit f9f0cf7524
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 25 additions and 4 deletions

View file

@ -1,3 +1,5 @@
from __future__ import annotations
import re
from pathlib import Path

View file

@ -8,6 +8,7 @@ Example usage:
--url https://pypi.org/project/flake8-pie/
--prefix PIE
"""
from __future__ import annotations
import argparse

View file

@ -9,6 +9,7 @@ Example usage:
--code 807 \
--linter flake8-pie
"""
from __future__ import annotations
import argparse
import subprocess

View file

@ -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)"

View file

@ -3,13 +3,14 @@ panics, autofix errors and similar problems.
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
@ -19,7 +20,7 @@ class Repository(NamedTuple):
org: str
repo: str
ref: Optional[str]
ref: str | None
def main() -> None:

View file

@ -5,6 +5,7 @@ Source:
Only the generation of the file has been modified for use in this project.
"""
from __future__ import annotations
from pathlib import Path

View file

@ -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

View file

@ -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
@ -21,5 +21,8 @@ ignore = [
"FBT", # flake8-boolean-trap
]
[tool.ruff.isort]
required-imports = ["from __future__ import annotations"]
[tool.ruff.pydocstyle]
convention = "pep257"

View file

@ -4,6 +4,8 @@ By default, we assume that our README.md will be rendered on GitHub. However, di
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

View file

@ -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

View file

@ -4,6 +4,7 @@ This script will clone astral-sh/schemastore, update the schema and push the cha
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