Skip to content

Commit

Permalink
Ignore line number differs in stubtest
Browse files Browse the repository at this point in the history
  • Loading branch information
vemel committed Jul 31, 2022
1 parent 338ee6d commit f601b75
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 10 deletions.
21 changes: 18 additions & 3 deletions istub.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
packages:
- name: botocore
- name: s3transfer
checks:
stubtest: true
snapshots:
stubtest: |-
error: not checking stubs due to mypy build errors:
./botocore-stubs/crt/auth.pyi:4: error: Skipping analyzing "awscrt.auth": module is installed, but missing library stubs or py.typed marker
error: s3transfer.compat.BaseManager.shutdown is not present at runtime
Stub: at line 152
def (self: multiprocessing.managers.BaseManager)
Runtime:
MISSING
error: s3transfer.processpool.BaseManager.shutdown is not present at runtime
Stub: at line 152
def (self: multiprocessing.managers.BaseManager)
Runtime:
MISSING
error: s3transfer.processpool.TransferMonitorManager.TransferMonitor is not present in stub
Stub:
MISSING
Runtime: at line 722 in file ./multiprocessing/managers.py
<function BaseManager.register.<locals>.temp at HASH>
10 changes: 9 additions & 1 deletion istub/checks/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def get_diff(self, data: List[str]) -> List[str]:

differ = difflib.Differ()
diff = differ.compare(old_data, data)
return [i for i in diff if i.startswith("-") or i.startswith("+")]
return [i for i in diff if not self.is_ignored_line_diff(i)]

def get_call_output(
self,
Expand All @@ -77,3 +77,11 @@ def set_snapshot(self, data: Iterable[str]) -> None:
Set snapshot data.
"""
self.package.set_snapshot(self.NAME, data)

def is_ignored_line_diff(self, line: str) -> bool:
"""
Whether line is ignored in diff.
"""
if line.startswith("+") or line.startswith("-"):
return False
return True
12 changes: 12 additions & 0 deletions istub/checks/stubtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,15 @@ def run(self) -> str:
capture_stderr=False,
)
return "\n".join(output.splitlines()[:-1])

def is_ignored_line_diff(self, line: str) -> bool:
"""
Whether line is ignored in diff.
"""
if super().is_ignored_line_diff(line):
return True

if "at line" in line:
return True

return False
38 changes: 34 additions & 4 deletions poetry.lock

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

5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,17 @@ pip = "*"
pyyaml = "*"

[tool.poetry.dev-dependencies]
awscrt = "*"
isort = "*"
mypy = "*"
black = "*"
flake8 = "*"
vulture = "*"
twine = "*"
types-pyyaml = "*"
botocore = "*"
s3transfer = "*"
awscrt = "*"
botocore-stubs = "*"
types-s3transfer = "*"
types-requests = "*"

[build-system]
Expand Down

0 comments on commit f601b75

Please sign in to comment.