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

ci(pre-commit.ci): ⬆ pre-commit autoupdate #423

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,28 @@ exclude: |

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v5.0.0
hooks:
- id: debug-statements
- id: detect-private-key
- id: end-of-file-fixer
- id: check-executables-have-shebangs
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "v0.0.255"
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.8.4"
hooks:
- id: ruff
args:
- --fix
- repo: https://github.com/pycqa/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 23.1.0
rev: 24.10.0
hooks:
- id: black
- repo: https://github.com/python-poetry/poetry
rev: 1.4.1
rev: 1.8.0
hooks:
- id: poetry-check
files: "^(pyproject.toml|poetry.lock)$"
Expand Down
2 changes: 1 addition & 1 deletion micropy/app/stubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def _get_desc(name: str, cfg: dict):
pyb.run_script(create_stubs, DevicePath(dev_path))
except Exception as e:
# TODO: Handle more usage cases
log.error(f"Failed to execute script: {str(e)}", exception=e)
log.error(f"Failed to execute script: {e!s}", exception=e)
raise
log.success("Done!")
log.info("Copying stubs...")
Expand Down
2 changes: 1 addition & 1 deletion micropy/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
from .config_dict import DictConfigSource
from .config_json import JSONConfigSource

__all__ = ["Config", "JSONConfigSource", "DictConfigSource"]
__all__ = ["Config", "DictConfigSource", "JSONConfigSource"]
2 changes: 1 addition & 1 deletion micropy/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from pathlib import Path

__all__ = ["ROOT", "SCHEMAS", "REPO_SOURCES", "FILES", "STUB_DIR", "LOG_FILE", "STUBBER"]
__all__ = ["FILES", "LOG_FILE", "REPO_SOURCES", "ROOT", "SCHEMAS", "STUBBER", "STUB_DIR"]

# Paths
MOD_PATH = Path(__file__).parent
Expand Down
3 changes: 2 additions & 1 deletion micropy/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Micropy Exceptions."""

from __future__ import annotations


Expand All @@ -21,7 +22,7 @@ class StubValidationError(StubError):
"""Raised when a stub fails validation."""

def __init__(self, path, errors, *args, **kwargs):
msg = f"Stub at[{str(path)}] encountered" f" the following validation errors: {str(errors)}"
msg = f"Stub at[{path!s}] encountered" f" the following validation errors: {errors!s}"
super().__init__(msg, *args, **kwargs)

def __str__(self):
Expand Down
2 changes: 1 addition & 1 deletion micropy/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def exception(self, error, **kwargs):

"""
name = type(error).__name__
msg = f"{name}: {str(error)}"
msg = f"{name}: {error!s}"
return self.echo(msg, log="exception", title_color="red", fg="red", accent="red", **kwargs)

def success(self, msg, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion micropy/packages/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def create_dependency_source(


__all__ = [
"LocalDependencySource",
"Package",
"PackageDependencySource",
"LocalDependencySource",
"create_dependency_source",
]
9 changes: 4 additions & 5 deletions micropy/project/modules/__init__.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
"""Project Modules."""


from .modules import HookProxy, ProjectModule
from .packages import DevPackagesModule, PackagesModule
from .stubs import StubsModule
from .templates import TemplatesModule

__all__ = [
"TemplatesModule",
"PackagesModule",
"StubsModule",
"ProjectModule",
"DevPackagesModule",
"HookProxy",
"PackagesModule",
"ProjectModule",
"StubsModule",
"TemplatesModule",
]
1 change: 0 additions & 1 deletion micropy/project/modules/templates.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Project Templates Module."""


from micropy.project.modules import ProjectModule
from micropy.project.template import TemplateProvider

Expand Down
8 changes: 4 additions & 4 deletions micropy/project/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ def render_to(self, name, parent_dir, *args, **kwargs):

"""
template = self.get(name, **kwargs)
self.log.debug(f"Loaded: {str(template)}")
self.log.debug(f"Loaded: {template!s}")
if self.run_checks:
self.log.debug(f"Verifying {template} requirements...")
template.run_checks()
Expand All @@ -305,7 +305,7 @@ def render_to(self, name, parent_dir, *args, **kwargs):
self.log.debug(f"Create: {out_dir}")
parent_dir.mkdir(exist_ok=True)
out_dir.parent.mkdir(exist_ok=True, parents=True)
self.log.debug(f"Rendered: {name} to {str(out_dir)}")
self.log.debug(f"Rendered: {name} to {out_dir!s}")
self.log.info(f"$[{name.capitalize()}] File Generated!")
stream = template.render_stream()
return stream.dump(str(out_dir))
Expand All @@ -326,13 +326,13 @@ def update(self, name, root_dir, **kwargs):

"""
template = self.get(name, **kwargs)
self.log.debug(f"Loaded: {str(template)}")
self.log.debug(f"Loaded: {template!s}")
try:
template.update(root_dir)
except FileNotFoundError:
self.log.debug("Template does not exist!")
return self.render_to(name, root_dir, **kwargs)
self.log.debug(f"Updated: {str(template)}")
self.log.debug(f"Updated: {template!s}")
return template

@property
Expand Down
16 changes: 8 additions & 8 deletions micropy/pyd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
from .pydevice import PyDevice

__all__ = [
"PyDevice",
"ConsumerDelegate",
"ProgressStreamConsumer",
"StreamHandlers",
"MessageHandlers",
"PyDeviceConsumer",
"DevicePath",
"HostPath",
"MessageConsumer",
"StreamConsumer",
"MessageHandlers",
"MetaPyDevice",
"MetaPyDeviceBackend",
"DevicePath",
"HostPath",
"ProgressStreamConsumer",
"PyDevice",
"PyDeviceConsumer",
"StreamConsumer",
"StreamHandlers",
]
84 changes: 28 additions & 56 deletions micropy/pyd/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,80 +10,65 @@


class StartHandler(Protocol):
def __call__(self, *, name: str = None, size: int | None = None) -> Any:
...
def __call__(self, *, name: str = None, size: int | None = None) -> Any: ...


class UpdateHandler(Protocol):
def __call__(self, *, size: int | None = None) -> Any:
...
def __call__(self, *, size: int | None = None) -> Any: ...


class EndHandler(Protocol):
def __call__(self) -> Any:
...
def __call__(self) -> Any: ...


class MessageHandler(Protocol):
def __call__(self, data: AnyStr) -> Any:
...
def __call__(self, data: AnyStr) -> Any: ...


class StreamConsumer(Protocol):
@property
@abc.abstractmethod
def on_start(self) -> StartHandler:
...
def on_start(self) -> StartHandler: ...

@property
@abc.abstractmethod
def on_update(self) -> UpdateHandler:
...
def on_update(self) -> UpdateHandler: ...

@property
@abc.abstractmethod
def on_end(self) -> EndHandler:
...
def on_end(self) -> EndHandler: ...


class MessageConsumer(Protocol):
@property
@abc.abstractmethod
def on_message(self) -> MessageHandler:
...
def on_message(self) -> MessageHandler: ...


class PyDeviceConsumer(MessageConsumer, StreamConsumer, Protocol):
...
class PyDeviceConsumer(MessageConsumer, StreamConsumer, Protocol): ...


class MetaPyDeviceBackend(abc.ABC):
location: str

@abc.abstractmethod
def establish(self, target: str) -> MetaPyDeviceBackend:
...
def establish(self, target: str) -> MetaPyDeviceBackend: ...

@abc.abstractmethod
def connect(self) -> None:
...
def connect(self) -> None: ...

@abc.abstractmethod
def disconnect(self) -> None:
...
def disconnect(self) -> None: ...

@abc.abstractmethod
def reset(self) -> None:
...
def reset(self) -> None: ...

@abc.abstractmethod
def resolve_path(self, target_path: DevicePath | str | Path) -> DevicePath:
...
def resolve_path(self, target_path: DevicePath | str | Path) -> DevicePath: ...

@property
@abc.abstractmethod
def connected(self) -> bool:
...
def connected(self) -> bool: ...

@abc.abstractmethod
def push_file(
Expand All @@ -93,8 +78,7 @@ def push_file(
*,
consumer: PyDeviceConsumer | None,
**kwargs,
) -> None:
...
) -> None: ...

@abc.abstractmethod
def pull_file(
Expand All @@ -104,16 +88,13 @@ def pull_file(
*,
consumer: PyDeviceConsumer | None,
**kwargs,
) -> None:
...
) -> None: ...

@abc.abstractmethod
def list_dir(self, path: DevicePath) -> list[DevicePath]:
...
def list_dir(self, path: DevicePath) -> list[DevicePath]: ...

@abc.abstractmethod
def remove(self, path: DevicePath) -> None:
...
def remove(self, path: DevicePath) -> None: ...

@abc.abstractmethod
def copy_dir(
Expand All @@ -123,12 +104,10 @@ def copy_dir(
*,
consumer: PyDeviceConsumer | None,
**kwargs,
):
...
): ...

@abc.abstractmethod
def eval(self, command: str, *, consumer: MessageConsumer | None = None):
...
def eval(self, command: str, *, consumer: MessageConsumer | None = None): ...

@abc.abstractmethod
def eval_script(
Expand All @@ -137,8 +116,7 @@ def eval_script(
target_path: DevicePath | None = None,
*,
consumer: PyDeviceConsumer | None = None,
):
...
): ...


AnyBackend = TypeVar("AnyBackend", bound=MetaPyDeviceBackend)
Expand All @@ -150,29 +128,23 @@ class MetaPyDevice(abc.ABC, Generic[AnyBackend]):
message_consumer: MessageConsumer | None

@abc.abstractmethod
def connect(self) -> None:
...
def connect(self) -> None: ...

@abc.abstractmethod
def disconnect(self) -> None:
...
def disconnect(self) -> None: ...

@abc.abstractmethod
def copy_to(self, source_path: HostPath, target_path: DevicePath) -> None:
...
def copy_to(self, source_path: HostPath, target_path: DevicePath) -> None: ...

@abc.abstractmethod
def copy_from(
self, source_path: DevicePath, target_path: HostPath, *, verify_integrity: bool = True
) -> None:
...
) -> None: ...

@abc.abstractmethod
def remove(self, target_path: DevicePath) -> None:
...
def remove(self, target_path: DevicePath) -> None: ...

@abc.abstractmethod
def run_script(
self, content: AnyStr | StringIO | BytesIO, target_path: DevicePath | None = None
):
...
): ...
3 changes: 1 addition & 2 deletions micropy/pyd/backend_rshell.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ class RShell:
ASCII_XFER: bool
QUIET: bool

def connect(self, port: str):
...
def connect(self, port: str): ...


try:
Expand Down
4 changes: 2 additions & 2 deletions micropy/pyd/backend_upydevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def write_file(
target_path = self.resolve_path(target_path)
self._pydevice.cmd("import gc")
self._pydevice.cmd("import ubinascii")
self._pydevice.cmd(f"f = open('{str(target_path)}', 'wb')")
self._pydevice.cmd(f"f = open('{target_path!s}', 'wb')")

content_iter = (
iterutils.chunked_iter(contents, self.BUFFER_SIZE)
Expand All @@ -212,7 +212,7 @@ def write_file(
)

content_size = len(contents)
consumer.on_start(name=f"Writing {str(target_path)}", size=content_size)
consumer.on_start(name=f"Writing {target_path!s}", size=content_size)

for chunk in content_iter:
cmd = (
Expand Down
Loading
Loading