File tree Expand file tree Collapse file tree 5 files changed +58
-39
lines changed
Expand file tree Collapse file tree 5 files changed +58
-39
lines changed Original file line number Diff line number Diff line change 1515
1616from __future__ import annotations
1717
18- import importlib .metadata
19-
20- import rich .console
21-
22-
23- console = rich .console .Console (log_path = False , log_time = False )
24-
25- VERSION = importlib .metadata .version ("mergify-cli" )
18+ from mergify_cli ._globals import VERSION as VERSION
19+ from mergify_cli ._globals import console as console
Original file line number Diff line number Diff line change 1+ #
2+ # Copyright © 2021-2024 Mergify SAS
3+ #
4+ # Licensed under the Apache License, Version 2.0 (the "License"); you may
5+ # not use this file except in compliance with the License. You may obtain
6+ # a copy of the License at
7+ #
8+ # http://www.apache.org/licenses/LICENSE-2.0
9+ #
10+ # Unless required by applicable law or agreed to in writing, software
11+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+ # License for the specific language governing permissions and limitations
14+ # under the License.
15+
16+ from __future__ import annotations
17+
18+ import importlib .metadata
19+
20+ import rich .console
21+
22+
23+ console = rich .console .Console (log_path = False , log_time = False )
24+
25+ VERSION = importlib .metadata .version ("mergify-cli" )
Original file line number Diff line number Diff line change @@ -124,16 +124,16 @@ class DetectedScope(pydantic.BaseModel):
124124 scopes : set [str ]
125125
126126 def save_to_file (self , file : str ) -> None :
127- with pathlib .Path (file ).open ("w" , encoding = "utf-8" ) as f :
128- f .write (self .model_dump_json ())
127+ pathlib .Path (file ).write_text (self .model_dump_json (), encoding = "utf-8" )
129128
130129 @classmethod
131130 def load_from_file (cls , filename : str ) -> DetectedScope :
132- with pathlib .Path (filename ).open ("r" , encoding = "utf-8" ) as f :
133- try :
134- return cls .model_validate_json (f .read ())
135- except pydantic .ValidationError as e :
136- raise InvalidDetectedScopeError (str (e ))
131+ try :
132+ return cls .model_validate_json (
133+ pathlib .Path (filename ).read_text (encoding = "utf-8" ),
134+ )
135+ except pydantic .ValidationError as e :
136+ raise InvalidDetectedScopeError (str (e )) from e
137137
138138
139139def detect (
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ mergify = "mergify_cli.cli:main"
2626dev = [
2727 " mypy==1.19.1" ,
2828 " mypy-extensions==1.1.0" ,
29- " ruff==0.14.9 " ,
29+ " ruff==0.14.11 " ,
3030 " pytest==9.0.2" ,
3131 " poethepoet==0.40.0" ,
3232 " pytest-asyncio==1.3.0" ,
You can’t perform that action at this time.
0 commit comments