Skip to content

Commit 513cec5

Browse files
committed
resolve ruff issues
1 parent 4d7b547 commit 513cec5

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

src/shecan/api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"""
66

77
import sys
8-
from typing import List, NamedTuple
8+
from typing import NamedTuple
99

1010
from shecan.db import ShecanConfig
1111
from shecan.utils import get_shecan_ips
@@ -36,7 +36,7 @@ def list_dns():
3636
return ips
3737

3838

39-
def current_dns() -> List[Resolver]:
39+
def current_dns() -> list[Resolver]:
4040
"""List current dns servers in /etc/resolv.conf."""
4141
resolv_list = []
4242
if sys.platform == "linux":

src/shecan/cli.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import sys
66
from pathlib import Path
77
from tempfile import gettempdir
8+
from typing import Optional
89

910
from tabulate import tabulate
1011

@@ -20,7 +21,7 @@ class TextStyle:
2021
NC = "\033[0m" # No Color
2122

2223

23-
def colorify(text: str, style: TextStyle):
24+
def colorify(text: str, style: TextStyle) -> str:
2425
return f"{style}{text}{TextStyle.NC}"
2526

2627

@@ -33,7 +34,7 @@ def list_dns() -> None:
3334
print(tabulate(dns_servers, headers=["ID", "IP"], stralign="center"))
3435

3536

36-
def update_resolv_file(content):
37+
def update_resolv_file(content) -> None:
3738
resolv_file = Path("/etc", "resolv.conf")
3839
tmp_resolv_file = Path(gettempdir()).joinpath("resolv.conf")
3940

@@ -59,7 +60,7 @@ def update_resolv_file(content):
5960
logger.error(f"Could not update resolv file: {e}")
6061

6162

62-
def restore_resolv_file():
63+
def restore_resolv_file() -> None:
6364
tmp_resolv_file = Path(gettempdir(), "resolv.conf")
6465
resolv_file = Path("/etc", "resolv.conf")
6566
if tmp_resolv_file.exists():
@@ -94,7 +95,7 @@ def show_current_dns() -> None:
9495
print(tabulate(resolvers, headers=["Type", "IP"], stralign="center"))
9596

9697

97-
def shecan_cli():
98+
def shecan_cli() -> Optional[int]:
9899
parser = argparse.ArgumentParser(description="CLI for shecan.ir website.")
99100
parser.add_argument(
100101
"--debug",

src/shecan/db.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ def __init__(self, config_file: str = DB_PATH) -> None:
1414
self._parser = ConfigParser()
1515
self._name = "shecan"
1616

17-
def _initialize(self):
17+
def _initialize(self) -> None:
1818
"""Initialize the shecan config file"""
1919
if not Path(self.config_file).exists():
2020
with open(self.config_file, mode="w") as fp:
2121
fp.write(f"[{self._name}]")
2222

23-
def _read_config(self):
23+
def _read_config(self) -> None:
2424
"""Read the configuration from a file."""
2525
self._initialize()
2626
self._parser.read(self.config_file)
@@ -33,7 +33,7 @@ def __exit__(self, *exceptions):
3333
with open(self.config_file, mode="w") as fp:
3434
self._parser.write(fp)
3535

36-
def update(self, ips: list):
36+
def update(self, ips: list) -> None:
3737
"""Store all Shecan's ip addresses."""
3838
self._parser[self._name]["dns-ips"] = ",".join(ips)
3939

src/shecan/utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
This module provides utility functions that are used within shecan.
55
"""
66

7-
from typing import Tuple
87
from urllib import request
98

109
from bs4 import BeautifulSoup
@@ -13,7 +12,7 @@
1312
CSS_SELECTOR = ".shecan-dns-ips"
1413

1514

16-
def get_shecan_ips(url: str = BASE_URL, selector: str = CSS_SELECTOR) -> Tuple[str]:
15+
def get_shecan_ips(url: str = BASE_URL, selector: str = CSS_SELECTOR) -> tuple[str]:
1716
"""Retrieve shecan DNS IP addresses."""
1817
data = request.urlopen(BASE_URL).read().decode("utf-8")
1918
soup = BeautifulSoup(data, "lxml")

0 commit comments

Comments
 (0)