Skip to content

Commit

Permalink
mypy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
andgineer committed Oct 8, 2021
1 parent 9793707 commit 9ff792b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ repos:
entry: dmypy
files: \.py$
# pre-commit send full file list so exclude in .mypy.ini is ignored
exclude: ^tests/fake_jsonplaceholder\.py
exclude: (^tests/fake_jsonplaceholder\.py|tests)
language: python
require_serial: true
args: ["run", "--", "--strict", "--implicit-reexport", "--warn-unused-ignores", "--cache-fine-grained"]
Expand Down
10 changes: 5 additions & 5 deletions bombard/campaign_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ def full_load(*args: Any, **kwargs: Any) -> Any:


class IncludesLoader(original_yaml.SafeLoader):
def __init__(self, stream):
def __init__(self, stream): # type: ignore
self._root = os.path.split(stream.name)[0]
super(IncludesLoader, self).__init__(stream)
super().__init__(stream)

@staticmethod
def wrap_in_yaml_document(msg: str) -> str:
Expand All @@ -45,12 +45,12 @@ def wrap_in_yaml_document(msg: str) -> str:
result = [" " * 4 + line for line in msg.split("\n") if SIGNATURE not in line]
return "|\n" + "\n".join(result)

def include(self, node):
filename = os.path.join(self._root, self.construct_scalar(node))
def include(self, node): # type: ignore
filename = os.path.join(self._root, str(self.construct_scalar(node)))
with open(filename, "r") 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)


IncludesLoader.add_constructor("!include", IncludesLoader.include)
IncludesLoader.add_constructor("!include", IncludesLoader.include) # type: ignore
4 changes: 2 additions & 2 deletions bombard/pretty_ns.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ def __init__(self) -> None:
pass

def __enter__(self) -> "Timer":
self.start = time_ns() # type: ignore
self.start = time_ns()
return self

def __exit__(self, *args: Any) -> None:
pass

@property
def ns(self) -> int:
return time_ns() - self.start # type: ignore
return time_ns() - self.start

@property
def pretty(self) -> str:
Expand Down

0 comments on commit 9ff792b

Please sign in to comment.