Skip to content

Commit

Permalink
style: isort and use early return
Browse files Browse the repository at this point in the history
Signed-off-by: Hiroshi Miura <[email protected]>
  • Loading branch information
miurahr committed Dec 24, 2024
1 parent 497a12c commit dd721f5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
4 changes: 2 additions & 2 deletions aqt/archives.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from dataclasses import dataclass, field
from itertools import islice, zip_longest
from logging import getLogger
from typing import Dict, Iterable, List, Optional, Set, Tuple
from typing import Any, Dict, Iterable, List, Optional, Set, Tuple
from xml.etree.ElementTree import Element # noqa

from defusedxml import ElementTree
Expand Down Expand Up @@ -703,7 +703,7 @@ def handle_missing_updates_xml(self, e: ArchiveDownloadError):
def _get_archives(self):
self._get_archives_base(self.tool_name, None)

def _parse_update_xml(self, os_target_folder: str, update_xml_text: str, *ignored) -> None:
def _parse_update_xml(self, os_target_folder: str, update_xml_text: str, *ignored: Any) -> None:
update_xml = Updates.fromstring(self.base, update_xml_text)
self._append_tool_update(os_target_folder, update_xml, self.arch, self.tool_version_str)

Expand Down
4 changes: 2 additions & 2 deletions aqt/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 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 typing import List, Optional
from typing import List, Optional, Any

DOCS_CONFIG = "https://aqtinstall.readthedocs.io/en/stable/configuration.html#configuration"


class AqtException(Exception):
def __init__(
self, *args, suggested_action: Optional[List[str]] = None, should_show_help: bool = False, **kwargs
self, *args, suggested_action: Optional[List[str]] = None, should_show_help: bool = False, **kwargs: Any
) -> None:
self.suggested_action: List[str] = suggested_action or []
self.should_show_help: bool = should_show_help or False
Expand Down
29 changes: 15 additions & 14 deletions aqt/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,21 +358,22 @@ def __init__(self) -> None:
self.loggingconf = os.path.join(os.path.dirname(__file__), "logging.ini")

def load_settings(self, file: Optional[Union[str, TextIO]] = None) -> None:
if self.config is not None:
if file is not None:
if isinstance(file, str):
result = self.config.read(file)
if len(result) == 0:
raise IOError("Fails to load specified config file {}".format(file))
self.configfile = file
else:
# passed through command line argparse.FileType("r")
self.config.read_file(file)
self.configfile = file.name
file.close()
if self.config is None:
return
if file is not None:
if isinstance(file, str):
result = self.config.read(file)
if len(result) == 0:
raise IOError("Fails to load specified config file {}".format(file))
self.configfile = file
else:
with open(self.configfile, "r") as f:
self.config.read_file(f)
# passed through command line argparse.FileType("r")
self.config.read_file(file)
self.configfile = file.name
file.close()
else:
with open(self.configfile, "r") as f:
self.config.read_file(f)

@property
def archive_download_location(self):
Expand Down

0 comments on commit dd721f5

Please sign in to comment.