Skip to content

Commit 762b8b0

Browse files
committed
Extract methods for _handle_header and _handle_option. Reduces complexity by 6.
1 parent 9f6b023 commit 762b8b0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Lib/configparser.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,9 @@ def _handle_rest(self, st, line, fpname):
10931093
if not mo and st.cursect is None:
10941094
raise MissingSectionHeaderError(fpname, st.lineno, line)
10951095

1096-
if mo:
1096+
self._handle_header(st, mo, fpname) if mo else self._handle_option(st, line, fpname)
1097+
1098+
def _handle_header(self, st, mo, fpname):
10971099
st.sectname = mo.group('header')
10981100
if st.sectname in self._sections:
10991101
if self._strict and st.sectname in st.elements_added:
@@ -1110,8 +1112,9 @@ def _handle_rest(self, st, line, fpname):
11101112
st.elements_added.add(st.sectname)
11111113
# So sections can't start with a continuation line
11121114
st.optname = None
1115+
1116+
def _handle_option(self, st, line, fpname):
11131117
# an option line?
1114-
else:
11151118
st.indent_level = st.cur_indent_level
11161119
# is it a section header?
11171120
mo = self.SECTCRE.match(line.clean)

0 commit comments

Comments
 (0)