Skip to content
Closed
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
10 changes: 2 additions & 8 deletions mergify_cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,5 @@

from __future__ import annotations

import importlib.metadata

import rich.console


console = rich.console.Console(log_path=False, log_time=False)

VERSION = importlib.metadata.version("mergify-cli")
from mergify_cli._globals import VERSION as VERSION
from mergify_cli._globals import console as console
25 changes: 25 additions & 0 deletions mergify_cli/_globals.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#
# Copyright © 2021-2024 Mergify SAS
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

from __future__ import annotations

import importlib.metadata

import rich.console


console = rich.console.Console(log_path=False, log_time=False)

VERSION = importlib.metadata.version("mergify-cli")
14 changes: 7 additions & 7 deletions mergify_cli/ci/scopes/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,16 @@ class DetectedScope(pydantic.BaseModel):
scopes: set[str]

def save_to_file(self, file: str) -> None:
with pathlib.Path(file).open("w", encoding="utf-8") as f:
f.write(self.model_dump_json())
pathlib.Path(file).write_text(self.model_dump_json(), encoding="utf-8")

@classmethod
def load_from_file(cls, filename: str) -> DetectedScope:
with pathlib.Path(filename).open("r", encoding="utf-8") as f:
try:
return cls.model_validate_json(f.read())
except pydantic.ValidationError as e:
raise InvalidDetectedScopeError(str(e))
try:
return cls.model_validate_json(
pathlib.Path(filename).read_text(encoding="utf-8"),
)
except pydantic.ValidationError as e:
raise InvalidDetectedScopeError(str(e)) from e


def detect(
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ mergify = "mergify_cli.cli:main"
dev = [
"mypy==1.19.1",
"mypy-extensions==1.1.0",
"ruff==0.14.9",
"ruff==0.14.11",
"pytest==9.0.2",
"poethepoet==0.40.0",
"pytest-asyncio==1.3.0",
Expand Down
46 changes: 23 additions & 23 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.