Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use __future__ imports in scripts #5301

Merged
merged 1 commit into from Jun 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions scripts/_utils.py
@@ -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
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
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
@@ -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
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
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
@@ -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
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
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
@@ -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
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