Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Use Ruff linting#277

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
AA-Turner merged 1 commit intomainfromruff-check
Apr 12, 2025
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions.pre-commit-config.yaml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,6 +16,7 @@ repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.11.5
hooks:
- id: ruff
- id: ruff-format

- repo: https://github.com/python-jsonschema/check-jsonschema
Expand Down
22 changes: 22 additions & 0 deletions.ruff.toml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,3 +5,25 @@ output-format = "full"
[format]
preview = true
docstring-code-format = true

[lint]
preview = true
select = [
"C4", # flake8-comprehensions
"B", # flake8-bugbear
"E", # pycodestyle
"F", # pyflakes
"FA", # flake8-future-annotations
"FLY", # flynt
"I", # isort
"N", # pep8-naming
"PERF", # perflint
"PGH", # pygrep-hooks
"PT", # flake8-pytest-style
"TC", # flake8-type-checking
"UP", # pyupgrade
"W", # pycodestyle
]
ignore = [
"E501", # Ignore line length errors (we use auto-formatting)
]
42 changes: 22 additions & 20 deletionsbuild_docs.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -65,18 +65,19 @@
from urllib.parse import urljoin

import jinja2
import platformdirs
import tomlkit
import urllib3
import zc.lockfile
from platformdirs import user_config_path, site_config_path

TYPE_CHECKING = False
if TYPE_CHECKING:
from collections.abc import Collection, Iterator, Sequence, Set
from typing import Literal

try:
from os import EX_OK, EX_SOFTWARE as EX_FAILURE
from os import EX_OK
from os import EX_SOFTWARE as EX_FAILURE
except ImportError:
EX_OK, EX_FAILURE = 0, 1

Expand DownExpand Up@@ -279,7 +280,7 @@
"""Filter a sequence of languages according to --languages."""
if language_tags:
language_tags = frozenset(language_tags)
return [l for l in self if l.tag in language_tags]
return [l for l in self if l.tag in language_tags] # NoQA: E741

Check warning on line 283 in build_docs.py

View check run for this annotation

Codecov/ codecov/patch

build_docs.py#L283

Added line #L283 was not covered by tests
return list(self)


Expand DownExpand Up@@ -480,7 +481,7 @@
- Cross-link various languages in a language switcher
- Cross-link various versions in a version switcher
"""
language_pairs = sorted((l.tag, l.switcher_label) for l in languages if l.in_prod)
language_pairs = sorted((l.tag, l.switcher_label) for l in languages if l.in_prod) # NoQA: E741

Check warning on line 484 in build_docs.py

View check run for this annotation

Codecov/ codecov/patch

build_docs.py#L484

Added line #L484 was not covered by tests
version_pairs = [(v.name, v.picker_label) for v in reversed(versions)]

switchers_template_file = HERE / "templates" / "switchers.js"
Expand DownExpand Up@@ -1057,28 +1058,29 @@


def load_environment_variables() -> None:
_user_config_path = user_config_path("docsbuild-scripts")
_site_config_path = site_config_path("docsbuild-scripts")
if_user_config_path.is_file():
ENV_CONF_FILE =_user_config_path
elif_site_config_path.is_file():
ENV_CONF_FILE =_site_config_path
dbs_user_config =platformdirs.user_config_path("docsbuild-scripts")
dbs_site_config =platformdirs.site_config_path("docsbuild-scripts")
ifdbs_user_config.is_file():
env_conf_file =dbs_user_config
elifdbs_site_config.is_file():
env_conf_file =dbs_site_config

Check warning on line 1066 in build_docs.py

View check run for this annotation

Codecov/ codecov/patch

build_docs.py#L1061-L1066

Added lines #L1061 - L1066 were not covered by tests
else:
logging.info(
"No environment variables configured. "
f"Configure in {_site_config_path} or {_user_config_path}."
f"Configure in {dbs_site_config} or {dbs_user_config}."
)
return

logging.info(f"Reading environment variables from {ENV_CONF_FILE}.")
if ENV_CONF_FILE == _site_config_path:
logging.info(f"You can override settings in {_user_config_path}.")
elif _site_config_path.is_file():
logging.info(f"Overriding {_site_config_path}.")
with open(ENV_CONF_FILE, "r") as f:
for key, value in tomlkit.parse(f.read()).get("env", {}).items():
logging.debug(f"Setting {key} in environment.")
os.environ[key] = value
logging.info(f"Reading environment variables from {env_conf_file}.")
if env_conf_file == dbs_site_config:
logging.info(f"You can override settings in {dbs_user_config}.")
elif dbs_site_config.is_file():
logging.info(f"Overriding {dbs_site_config}.")

Check warning on line 1078 in build_docs.py

View check run for this annotation

Codecov/ codecov/patch

build_docs.py#L1074-L1078

Added lines #L1074 - L1078 were not covered by tests

env_config = env_conf_file.read_text(encoding="utf-8")
for key, value in tomlkit.parse(env_config).get("env", {}).items():
logging.debug(f"Setting {key} in environment.")
os.environ[key] = value

Check warning on line 1083 in build_docs.py

View check run for this annotation

Codecov/ codecov/patch

build_docs.py#L1080-L1083

Added lines #L1080 - L1083 were not covered by tests


def build_docs_with_lock(args: argparse.Namespace, lockfile_name: str) -> int:
Expand Down
2 changes: 1 addition & 1 deletiontests/test_build_docs.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,7 @@


@pytest.mark.parametrize(
"seconds,expected",
("seconds", "expected"),
[
(0.4, "0s"),
(0.5, "0s"),
Expand Down
2 changes: 1 addition & 1 deletiontests/test_build_docs_versions.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
from build_docs importVersions, Version
from build_docs importVersion, Versions


def test_filter_default() -> None:
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp