Skip to content

Commit f0f4761

Browse files
committed
refactor: avoid RawConfigParser, and use super()
1 parent b34bd14 commit f0f4761

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

coverage/config.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
os = isolate_module(os)
1919

2020

21-
class HandyConfigParser(configparser.RawConfigParser):
21+
class HandyConfigParser(configparser.ConfigParser):
2222
"""Our specialization of ConfigParser."""
2323

2424
def __init__(self, our_file):
@@ -29,36 +29,36 @@ def __init__(self, our_file):
2929
for possible settings.
3030
"""
3131

32-
configparser.RawConfigParser.__init__(self)
32+
super().__init__(interpolation=None)
3333
self.section_prefixes = ["coverage:"]
3434
if our_file:
3535
self.section_prefixes.append("")
3636

3737
def read(self, filenames, encoding_unused=None):
3838
"""Read a file name as UTF-8 configuration data."""
39-
return configparser.RawConfigParser.read(self, filenames, encoding="utf-8")
39+
return super().read(filenames, encoding="utf-8")
4040

4141
def has_option(self, section, option):
4242
for section_prefix in self.section_prefixes:
4343
real_section = section_prefix + section
44-
has = configparser.RawConfigParser.has_option(self, real_section, option)
44+
has = super().has_option(real_section, option)
4545
if has:
4646
return has
4747
return False
4848

4949
def has_section(self, section):
5050
for section_prefix in self.section_prefixes:
5151
real_section = section_prefix + section
52-
has = configparser.RawConfigParser.has_section(self, real_section)
52+
has = super().has_section(real_section)
5353
if has:
5454
return real_section
5555
return False
5656

5757
def options(self, section):
5858
for section_prefix in self.section_prefixes:
5959
real_section = section_prefix + section
60-
if configparser.RawConfigParser.has_section(self, real_section):
61-
return configparser.RawConfigParser.options(self, real_section)
60+
if super().has_section(real_section):
61+
return super().options(real_section)
6262
raise ConfigError(f"No section: {section!r}")
6363

6464
def get_section(self, section):
@@ -71,7 +71,7 @@ def get_section(self, section):
7171
def get(self, section, option, *args, **kwargs):
7272
"""Get a value, replacing environment variables also.
7373
74-
The arguments are the same as `RawConfigParser.get`, but in the found
74+
The arguments are the same as `ConfigParser.get`, but in the found
7575
value, ``$WORD`` or ``${WORD}`` are replaced by the value of the
7676
environment variable ``WORD``.
7777
@@ -80,12 +80,12 @@ def get(self, section, option, *args, **kwargs):
8080
"""
8181
for section_prefix in self.section_prefixes:
8282
real_section = section_prefix + section
83-
if configparser.RawConfigParser.has_option(self, real_section, option):
83+
if super().has_option(real_section, option):
8484
break
8585
else:
8686
raise ConfigError(f"No option {option!r} in section: {section!r}")
8787

88-
v = configparser.RawConfigParser.get(self, real_section, option, *args, **kwargs)
88+
v = super().get(real_section, option, *args, **kwargs)
8989
v = substitute_variables(v, os.environ)
9090
return v
9191

0 commit comments

Comments
 (0)