Skip to content

Commit

Permalink
Merge branch 'main' into 145-support-pydantic-2
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon committed Oct 18, 2023
2 parents 4e2737e + 1d405aa commit b317cbe
Show file tree
Hide file tree
Showing 9 changed files with 204 additions and 218 deletions.
5 changes: 1 addition & 4 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
[flake8]
ignore = W503, C901, ANN101
max-line-length = 88
select = DAR
exclude = copier_template
max-complexity = 10
docstring-convention = google
allow-star-arg-any = true
26 changes: 5 additions & 21 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,17 @@ repos:
exclude: (copier_template/.*|docs/.*|samples/.*\.json)
- id: trailing-whitespace

- repo: https://github.com/psf/black
rev: 23.9.1
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.0
hooks:
- id: black
exclude: |
(?x)^(
copier_template/.*
)$
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
exclude: (copier_template/.*)
- id: ruff
args: [--fix, --exit-non-zero-on-fix, --show-fixes]
- id: ruff-format

- repo: https://github.com/pycqa/flake8
rev: 6.1.0
hooks:
- id: flake8
additional_dependencies:
- darglint==1.8.1
- flake8-annotations==2.9.0
- flake8-docstrings==1.6.0
files: 'meltano/edk/.*'

- repo: https://github.com/asottile/pyupgrade
rev: v3.14.0
hooks:
- id: pyupgrade
args: [--py37-plus, --keep-mock]
1 change: 0 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
"sphinx.ext.autodoc",
"sphinx.ext.napoleon",
"sphinx.ext.autosummary",
"sphinx_rtd_theme",
"sphinx_copybutton",
"myst_parser",
]
Expand Down
10 changes: 7 additions & 3 deletions meltano/edk/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ class DescribeFormat(str, Enum):
class ExtensionBase(metaclass=ABCMeta):
"""Basic extension interface that must be implemented by all extensions."""

def pre_invoke(self, invoke_name: str | None, *invoke_args: ExecArg) -> None:
def pre_invoke( # noqa: B027
self,
invoke_name: str | None,
*invoke_args: ExecArg,
) -> None:
"""Called before the extension is invoked.
Args:
Expand All @@ -33,7 +37,7 @@ def pre_invoke(self, invoke_name: str | None, *invoke_args: ExecArg) -> None:
"""
pass

def initialize(self, force: bool = False) -> None:
def initialize(self, force: bool = False) -> None: # noqa: B027
"""Initialize the extension.
This method is called on-demand by the user to initialize the extension.
Expand All @@ -56,7 +60,7 @@ def invoke(self, command_name: str | None, *command_args: ExecArg) -> None:
"""
pass

def post_invoke(self, invoked_name: str | None, *invoked_args: ExecArg) -> None:
def post_invoke(self, invoked_name: str | None, *invoked_args: ExecArg) -> None: # noqa: B027
"""Called after the extension is invoked.
Args:
Expand Down
10 changes: 5 additions & 5 deletions meltano/edk/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import asyncio
import os
import subprocess
from typing import IO, Any
import typing as t

import structlog

Expand Down Expand Up @@ -40,7 +40,7 @@ def __init__(
self,
bin: str,
cwd: str | None = None,
env: dict[str, Any] | None = None,
env: dict[str, t.Any] | None = None,
) -> None:
"""Minimal invoker for running subprocesses.
Expand All @@ -56,10 +56,10 @@ def __init__(
def run(
self,
*args: ExecArg,
stdout: None | int | IO = subprocess.PIPE,
stderr: None | int | IO = subprocess.PIPE,
stdout: None | int | t.IO = subprocess.PIPE,
stderr: None | int | t.IO = subprocess.PIPE,
text: bool = True,
**kwargs: Any,
**kwargs: t.Any,
) -> subprocess.CompletedProcess:
"""Run a subprocess. Simple wrapper around subprocess.run.
Expand Down
315 changes: 148 additions & 167 deletions poetry.lock

Large diffs are not rendered by default.

42 changes: 31 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ furo = {version = ">=2022.12.7,<2024.0.0", optional = true}
sphinx-copybutton = {version = ">=0.3.1,<0.6.0", optional = true}
myst-parser = {version = ">=0.17.2,<1.1.0", optional = true}
sphinx-autobuild = {version = "^2021.3.14", optional = true}
sphinx-rtd-theme = {version = ">=1.3.0,<2", optional = true}

[tool.poetry.extras]
docs = [
Expand All @@ -61,9 +60,10 @@ docs = [
"sphinx-autobuild",
]

[tool.poetry.dev-dependencies]
mock = "^5.1.0"
[tool.poetry.group.dev.dependencies]
copier = ">=8.1.0,<9.0"
pytest = "^7.4.2"
types-pyyaml = "^6.0.12.4"
# Cookiecutter tests
mypy = "^1.4"
black = "^23.3"
Expand All @@ -72,15 +72,35 @@ flake8 = "^3.9.0"
flake8-annotations = "^2.9.1"
flake8-docstrings = "^1.7.0"

[tool.poetry.group.dev.dependencies]
copier = ">=8.1.0,<9.0"
types-pyyaml = "^6.0.12.4"
[tool.ruff]
ignore = [
"ANN101",
]
select = [
"E",
"F",
"B",
"I",
"ANN",
"D",
"UP",
]
target-version = "py38"

[tool.ruff.flake8-annotations]
allow-star-arg-any = true

[tool.ruff.per-file-ignores]
"docs/**" = [
"D",
]
"tests/**" = [
"ANN201",
"D",
]

[tool.isort]
profile = "black"
multi_line_output = 3 # Vertical Hanging Indent
src_paths = "meltano/edk"
known_first_party = ["meltano"]
[tool.ruff.pydocstyle]
convention = "google"

[build-system]
requires = [
Expand Down
2 changes: 1 addition & 1 deletion tests/copier_template/test_generated.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_copier_output(outdir: str):
data={
"admin_name": "John Doe",
"cli_prefix": "testflow",
"extension_description": "A meltano utility extension for testflow that wraps the /bin/notreal command.",
"extension_description": "A meltano utility extension for testflow that wraps the /bin/notreal command.", # noqa: E501
"extension_id": "testflow-ext",
"extension_name": "Testflow",
"extension_name_lower": "testflow",
Expand Down
11 changes: 6 additions & 5 deletions tests/test_process.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import asyncio
import typing as t
from unittest.mock import AsyncMock, Mock, patch

import pytest
from mock import AsyncMock, Mock, patch

from meltano.edk.process import Invoker


@pytest.fixture()
def process_mock_factory():
def _factory(name):
def _factory(name: str) -> Mock:
process_mock = Mock()
process_mock.name = name
process_mock.wait = AsyncMock(return_value=0)
Expand All @@ -20,7 +21,7 @@ def _factory(name):


@pytest.fixture()
def process_mock(process_mock_factory):
def process_mock(process_mock_factory: t.Callable[[str], Mock]) -> Mock:
process = process_mock_factory("echo")
process.stdout.at_eof.side_effect = (False, False, False, True)
process.stdout.readline = AsyncMock(
Expand All @@ -34,10 +35,10 @@ def process_mock(process_mock_factory):
return process


def test_exec(process_mock):
def test_exec(process_mock: Mock):
"""Verify that the Invoker._exec method works as expected."""

async def _test_exec():
async def _test_exec() -> None:
inv = Invoker("echo", cwd="/tmp", env={"FOO": "BAR"})
with patch("asyncio.create_subprocess_exec") as mock:
mock.return_value = process_mock
Expand Down

0 comments on commit b317cbe

Please sign in to comment.