Skip to content

Commit

Permalink
ci:solved linting issue
Browse files Browse the repository at this point in the history
  • Loading branch information
hetangmodi-crest committed Aug 2, 2024
1 parent 58bbd17 commit 387fe59
Show file tree
Hide file tree
Showing 4 changed files with 176 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ __pycache__
.pytest_cache
dist
actionlint
*.log
events.pickle
10 changes: 7 additions & 3 deletions addonfactory_splunk_conf_parser_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
# limitations under the License.
#
import configparser
from io import TextIOBase
from os import SEEK_SET
from typing import Any, Dict

COMMENT_PREFIX = ";#*"
COMMENT_KEY = "__COMMENTS__"
Expand All @@ -30,6 +30,10 @@ class TABConfigParser(configparser.RawConfigParser):
3. Support multiline end with \
"""

_defaults: Dict[Any, Any]
_sections: Dict[Any, Any]
_optcre: Dict[Any, Any]

def _read(self, fp, fpname):
"""
Override the built-in _read() method to read comments
Expand Down Expand Up @@ -151,7 +155,8 @@ def _read(self, fp, fpname):
if isinstance(val, list):
options[name] = "\n".join(val)

def write(self, fp: TextIOBase):
# As the type of fp is not defined in RawConfigParser which is the parent class so we have to go with Any.
def write(self, fp: Any, *args) -> None:
"""
Override the write() method to write comments
"""
Expand All @@ -164,7 +169,6 @@ def write(self, fp: TextIOBase):
if hasattr(self, "fields_outside_stanza"):
for field in self.fields_outside_stanza:
fp.write(field)

if self._defaults:
fp.write("[%s]\n" % DEFAULTSECT)
for (key, value) in list(self._defaults.items()):
Expand Down
166 changes: 166 additions & 0 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ keywords = ["splunk"]

[tool.poetry.dependencies]
python = "^3.7"
configparser = "5.3.0"

[tool.poetry.dev-dependencies]
pytest = ">=7"
Expand Down

0 comments on commit 387fe59

Please sign in to comment.