Skip to content

Commit cc665da

Browse files
authored
Merge pull request #74 from JedMeister/finish-typing
Finish typing
2 parents c814701 + 1b55e24 commit cc665da

File tree

12 files changed

+766
-264
lines changed

12 files changed

+766
-264
lines changed

conf.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,30 @@
33

44
import re
55
import os
6+
from typing import Optional
67

78

89
class Error(Exception):
910
pass
1011

1112

12-
def path(filename):
13+
def path(filename: str) -> str:
1314
for dir in ("conf", "/etc/confconsole"):
1415
path = os.path.join(dir, filename)
1516
if os.path.exists(path):
1617
return path
1718

18-
raise Error('could not find configuration file: %s' % path)
19+
raise Error(f'could not find configuration file: {filename}')
1920

2021

2122
class Conf:
22-
def _load_conf(self):
23+
default_nic: Optional[str]
24+
publicip_cmd: Optional[str]
25+
networking: bool
26+
copy_paste: bool
27+
conf_file: str
28+
29+
def _load_conf(self) -> None:
2330
if not self.conf_file or not os.path.exists(self.conf_file):
2431
return
2532

@@ -44,16 +51,16 @@ def _load_conf(self):
4451
else:
4552
raise Error("illegal configuration line: " + line)
4653

47-
def __init__(self):
54+
def __init__(self) -> None:
4855
self.default_nic = None
4956
self.publicip_cmd = None
5057
self.networking = True
5158
self.copy_paste = True
5259
self.conf_file = path("confconsole.conf")
5360
self._load_conf()
5461

55-
def set_default_nic(self, ifname):
62+
def set_default_nic(self, ifname: str) -> None:
5663
self.default_nic = ifname
5764

5865
with open(self.conf_file, 'w') as fob:
59-
fob.write("default_nic %s\n" % ifname)
66+
fob.write(f"default_nic {ifname}\n")

0 commit comments

Comments
 (0)