Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (#3971)
Browse files Browse the repository at this point in the history
<!--pre-commit.ci start-->
updates:
- [github.com/pre-commit/mirrors-prettier: v3.0.0-alpha.9-for-vscode →
v3.0.0](pre-commit/mirrors-prettier@v3.0.0-alpha.9-for-vscode...v3.0.0)
- [github.com/psf/black: 23.3.0 →
23.7.0](psf/black@23.3.0...23.7.0)
- https://github.com/charliermarsh/ruff-pre-commithttps://github.com/astral-sh/ruff-pre-commit
- [github.com/astral-sh/ruff-pre-commit: v0.0.275 →
v0.0.278](astral-sh/ruff-pre-commit@v0.0.275...v0.0.278)
- [github.com/jazzband/pip-tools: 6.14.0 →
7.0.0](jazzband/pip-tools@6.14.0...7.0.0)
<!--pre-commit.ci end-->

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Jack <[email protected]>
Co-authored-by: Ajinkya Udgirkar <[email protected]>
  • Loading branch information
3 people authored Aug 1, 2023
1 parent 3c75d0c commit 258e54c
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 33 deletions.
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ default_language_version:
repos:
- repo: https://github.com/pre-commit/mirrors-prettier
# keep it before yamllint
rev: "v3.0.0-alpha.9-for-vscode"
rev: "v3.0.0"
hooks:
- id: prettier
# Temporary excludes so we can gradually normalize the formatting
Expand All @@ -20,7 +20,7 @@ repos:
hooks:
- id: codespell
- repo: https://github.com/psf/black
rev: 23.3.0
rev: 23.7.0
hooks:
- id: black
language_version: python3
Expand All @@ -43,8 +43,8 @@ repos:
files: \.(yaml|yml)$
types: [file, yaml]
entry: yamllint --strict
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.0.275"
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.0.281"
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ ignore = [
"EM",
"INP",
"N",
"PERF203",
"PGH",
"PLR",
"PLW",
Expand Down
30 changes: 15 additions & 15 deletions src/molecule/model/schema_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,21 @@ def validate(c):
schema = json.load(f)
schemas.append(schema)

for schema in schemas:
try:
try:
for schema in schemas:
jsonschema_validate(c, schema)
except ValidationError as exc:
# handle validation error for driver name
if exc.json_path == "$.driver.name" and exc.message.endswith(
(
"is not of type 'string'",
"is not valid under any of the given schemas",
),
):
wrong_driver_name = str(exc.message.split()[0])
driver_name_err_msg = exc.schema["messages"]["anyOf"]
result.append(f"{wrong_driver_name} {driver_name_err_msg}")
else:
result.append(exc.message)
except ValidationError as exc:
# handle validation error for driver name
if exc.json_path == "$.driver.name" and exc.message.endswith(
(
"is not of type 'string'",
"is not valid under any of the given schemas",
),
):
wrong_driver_name = str(exc.message.split()[0])
driver_name_err_msg = exc.schema["messages"]["anyOf"]
result.append(f"{wrong_driver_name} {driver_name_err_msg}")
else:
result.append(exc.message)

return result
4 changes: 2 additions & 2 deletions src/molecule/scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
"""Molecule Scenario Module."""
from __future__ import annotations

import errno
import fcntl
Expand All @@ -27,7 +28,6 @@
import shutil
from pathlib import Path
from time import sleep
from typing import Optional

from molecule import scenarios, util
from molecule.constants import RC_TIMEOUT
Expand Down Expand Up @@ -211,7 +211,7 @@ def _setup(self):
os.makedirs(self.inventory_directory, exist_ok=True)


def ephemeral_directory(path: Optional[str] = None) -> str:
def ephemeral_directory(path: str | None = None) -> str:
"""Return temporary directory to be used by molecule.
Molecule users should not make any assumptions about its location,
Expand Down
4 changes: 2 additions & 2 deletions src/molecule/test/b_functional/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
from __future__ import annotations

import os
import shutil
import subprocess
from subprocess import PIPE
from typing import Optional

import pexpect
import pytest
Expand Down Expand Up @@ -209,7 +209,7 @@ def verify(scenario_name="default"):
assert run_command(cmd).returncode == 0


def get_docker_executable() -> Optional[str]:
def get_docker_executable() -> str | None:
return shutil.which("docker")


Expand Down
4 changes: 2 additions & 2 deletions src/molecule/test/b_functional/test_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
from __future__ import annotations

import os
from typing import Optional

import pytest
from pytest import FixtureRequest
Expand Down Expand Up @@ -48,7 +48,7 @@ def scenario_name(request):


@pytest.fixture()
def driver_name(request: FixtureRequest) -> Optional[str]:
def driver_name(request: FixtureRequest) -> str | None:
try:
# https://stackoverflow.com/q/65334215/99834
return request.param # type: ignore
Expand Down
19 changes: 11 additions & 8 deletions src/molecule/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,16 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
"""Molecule Utils Module."""

from __future__ import annotations

import copy
import fnmatch
import logging
import os
import re
import sys
from collections.abc import Iterable, MutableMapping
from subprocess import CalledProcessError, CompletedProcess
from typing import Any, NoReturn, Optional
from warnings import WarningMessage
from typing import TYPE_CHECKING, Any, NoReturn

import jinja2
import yaml
Expand All @@ -39,6 +38,10 @@
from molecule.console import console
from molecule.constants import MOLECULE_HEADER

if TYPE_CHECKING:
from collections.abc import Iterable, MutableMapping
from warnings import WarningMessage

LOG = logging.getLogger(__name__)


Expand All @@ -54,7 +57,7 @@ def print_debug(title: str, data: str) -> None:
console.print(f"DEBUG: {title}:\n{data}")


def print_environment_vars(env: Optional[dict[str, Optional[str]]]) -> None:
def print_environment_vars(env: dict[str, str | None] | None) -> None:
"""Print ``Ansible`` and ``Molecule`` environment variables and returns None.
:param env: A dict containing the shell's environment as collected by
Expand Down Expand Up @@ -97,7 +100,7 @@ def sysexit(code: int = 1) -> NoReturn:
def sysexit_with_message(
msg: str,
code: int = 1,
detail: Optional[MutableMapping] = None,
detail: MutableMapping | None = None,
warns: Iterable[WarningMessage] = (),
) -> None:
"""Exit with an error message."""
Expand Down Expand Up @@ -173,7 +176,7 @@ def render_template(template, **kwargs):
return t.render(kwargs)


def write_file(filename: str, content: str, header: Optional[str] = None) -> None:
def write_file(filename: str, content: str, header: str | None = None) -> None:
"""Write a file with the given filename and content and returns None.
:param filename: A string containing the target filename.
Expand Down Expand Up @@ -269,7 +272,7 @@ def filter_verbose_permutation(options):
return {k: options[k] for k in options if not re.match("^[v]+$", k)}


def abs_path(path: str) -> Optional[str]:
def abs_path(path: str) -> str | None:
"""Return absolute path."""
if path:
return os.path.abspath(path)
Expand Down Expand Up @@ -332,7 +335,7 @@ def find_vcs_root(location="", dirs=(".git", ".hg", ".svn"), default=None) -> st
return default


def lookup_config_file(filename: str) -> Optional[str]:
def lookup_config_file(filename: str) -> str | None:
"""Return config file PATH."""
for path in [find_vcs_root(default="~"), "~"]:
f = os.path.expanduser(f"{path}/{filename}")
Expand Down

0 comments on commit 258e54c

Please sign in to comment.