Skip to content

Commit

Permalink
new pylint version code fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
andgineer committed Feb 9, 2022
1 parent 29a18a6 commit 576c6de
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion bombard/campaign_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def wrap_in_yaml_document(msg: str) -> str:

def include(self, node): # type: ignore
filename = os.path.join(self._root, str(self.construct_scalar(node)))
with open(filename, "r") as f:
with open(filename, "r", encoding="utf8") as f:
wrapped = io.StringIO(self.wrap_in_yaml_document(f.read()))
wrapped.name = f.name # to please owe own __init__
return original_yaml.load(wrapped, IncludesLoader)
Expand Down
2 changes: 1 addition & 1 deletion bombard/expand_file_name.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ def show_folder(folder_path: str) -> None:
print(name)
else:
print(f"\n{folder_path}:\n")
with open(file_name, "r") as desc:
with open(file_name, "r", encoding="utf8") as desc:
print(markdown_for_terminal(desc.read()))
6 changes: 4 additions & 2 deletions bombard/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ def start_campaign(args: Any, campaign_book: Dict[str, Any]) -> None:
def campaign(args: Any) -> None:
if args.version:
print(bombard.__name__, bombard.version())
with open(os.path.join(os.path.dirname(bombard.__file__), "LICENSE.txt"), "r") as license:
with open(
os.path.join(os.path.dirname(bombard.__file__), "LICENSE.txt"), "r", encoding="utf8"
) as license:
print(license.readline())
return

Expand All @@ -142,7 +144,7 @@ def campaign(args: Any) -> None:
elif not (os.path.isfile(campaign_file_name) or args.init):
print(red(f'\nCannot find campaign file "{args.file_name}"\n'))
else:
start_campaign(args, yaml.load(open(campaign_file_name, "r")))
start_campaign(args, yaml.load(open(campaign_file_name, "r", encoding="utf8")))


def main() -> None:
Expand Down
4 changes: 3 additions & 1 deletion bombard/mock_globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ def master(yaml_file_name: str):
That makes code autocomplete work in bombard script.
"""
try:
campaign_book = yaml.load(open(expand_relative_file_name(yaml_file_name), "r"))
campaign_book = yaml.load(
open(expand_relative_file_name(yaml_file_name), "r", encoding="utf8")
)
for name in campaign_book["ammo"]:
setattr(ammo, name, None)
for name in campaign_book["supply"]:
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import setuptools

with open("README.rst", "r") as fh:
with open("README.rst", "r", encoding="utf8") as fh:
long_description = fh.read()

with open("requirements.txt") as f:
with open("requirements.txt", encoding="utf8") as f:
requirements = f.read().splitlines()

import sys
Expand Down
8 changes: 4 additions & 4 deletions tests/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ def testInitDefault(self) -> None:
campaign(FakeArgs(init=True))

self.maxDiff = 1024
with open(f"bombard/examples/{INIT_EXAMPLE}") as ex, open(
f"{CAMPAIGN_FILE_NAME}", "r"
with open(f"bombard/examples/{INIT_EXAMPLE}", encoding="utf8") as ex, open(
f"{CAMPAIGN_FILE_NAME}", "r", encoding="utf8"
) as init:
self.assertEqual(ex.read(), init.read())

Expand All @@ -35,7 +35,7 @@ def testInitSimpleton(self) -> None:
campaign(FakeArgs(example="simpleton", init=True))

self.maxDiff = 1024
with open("bombard/examples/simpleton.yaml") as desc, open(
f"{CAMPAIGN_FILE_NAME}", "r"
with open("bombard/examples/simpleton.yaml", encoding="utf8") as desc, open(
f"{CAMPAIGN_FILE_NAME}", "r", encoding="utf8"
) as init:
self.assertIn(desc.read(), init.read())
2 changes: 1 addition & 1 deletion tests/test_show_folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def testShowFolder(self) -> None:
campaign(FakeArgs(examples=True))

self.maxDiff = 1024
with open(f"bombard/examples/{DIR_DESC_FILE_NAME}") as desc:
with open(f"bombard/examples/{DIR_DESC_FILE_NAME}", encoding="utf8") as desc:
self.assertIn( # do not check 1st line of output with the folder name
markdown_for_terminal(desc.read()), captured.output
)
2 changes: 1 addition & 1 deletion tests/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ def testVersion(self) -> None:
with CaptureOutput() as captured:
campaign(FakeArgs(version=True))

with open("bombard/LICENSE.txt") as license:
with open("bombard/LICENSE.txt", encoding="utf8") as license:
self.assertIn(license.readline(), captured.output)
self.assertIn(bombard.version(), captured.output)

0 comments on commit 576c6de

Please sign in to comment.