slightly modified test_core.py so that mypy doesn't generate errors.

This commit is contained in:
Tim Rid 2021-01-01 22:56:53 +01:00
parent fb38301189
commit 0a51f86183
6 changed files with 687 additions and 557 deletions

22
.vscode/launch.json vendored Normal file
View file

@ -0,0 +1,22 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Aktuelle Datei",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
},
{
"name": "Debug Tests",
"type": "python",
"request": "test",
"console": "integratedTerminal",
"justMyCode": false
}
]
}

View file

@ -7,5 +7,9 @@
"python.formatting.provider": "black",
"python.analysis.typeCheckingMode": "strict",
"python.analysis.autoImportCompletions": false,
"python.analysis.diagnosticSeverityOverrides": {
"reportPrivateUsage": "information",
"reportUntypedNamedTuple": "information",
},
"python.pythonPath": "python"
}
}

View file

@ -18,6 +18,9 @@ setup(
author="Tim Riddermann",
python_requires=">=3.6",
install_requires=["construct==2.10.56"],
extras_require={
"test": ["pytest>=6.2.0"],
},
keywords=[
"construct",
"kaitai",
@ -41,7 +44,7 @@ setup(
"typing",
"typed",
"bitstruct",
"PEP 561"
"PEP 561",
],
classifiers=[
"Development Status :: 3 - Alpha",
@ -56,6 +59,6 @@ setup(
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Typing :: Typed"
"Typing :: Typed",
],
)

View file

@ -35,7 +35,6 @@ def raises(func, *args, **kw):
def common(format, datasample, objsample, sizesample=SizeofError, **kw):
obj = format.parse(datasample, **kw)
assert obj == objsample
assert isinstance(obj, type(objsample))
data = format.build(objsample, **kw)
assert data == datasample
# following are implied by above (re-parse and re-build)

View file

@ -26,6 +26,70 @@ def common(
**kw: t.Any
) -> None: ...
@t.overload
def common(
format: Construct[ListContainer[ParsedType], t.Any],
datasample: Buffer,
objsample: t.List[ParsedType],
sizesample: t.Union[int, t.Type[Exception]] = ...,
**kw: t.Any
) -> None: ...
@t.overload
def common(
format: Construct[Container[t.Any], t.Any],
datasample: Buffer,
objsample: t.Dict[str, t.Any],
sizesample: t.Union[int, t.Type[Exception]] = ...,
**kw: t.Any
) -> None: ...
@t.overload
def common(
format: Construct[t.Union[EnumInteger, EnumIntegerString], t.Any],
datasample: Buffer,
objsample: t.Union[int, str],
sizesample: t.Union[int, t.Type[Exception]] = ...,
**kw: t.Any
) -> None: ...
@t.overload
def common(
format: Construct[HexDisplayedInteger, t.Any],
datasample: Buffer,
objsample: t.Union[HexDisplayedInteger, int],
sizesample: t.Union[int, t.Type[Exception]] = ...,
**kw: t.Any
) -> None: ...
@t.overload
def common(
format: Construct[HexDisplayedBytes, t.Any],
datasample: Buffer,
objsample: t.Union[HexDisplayedBytes, bytes],
sizesample: t.Union[int, t.Type[Exception]] = ...,
**kw: t.Any
) -> None: ...
@t.overload
def common(
format: Construct[HexDisplayedDict[str, t.Any], t.Any],
datasample: Buffer,
objsample: t.Dict[str, t.Any],
sizesample: t.Union[int, t.Type[Exception]] = ...,
**kw: t.Any
) -> None: ...
@t.overload
def common(
format: Construct[HexDumpDisplayedBytes, t.Any],
datasample: Buffer,
objsample: t.Union[HexDumpDisplayedBytes, bytes],
sizesample: t.Union[int, t.Type[Exception]] = ...,
**kw: t.Any
) -> None: ...
@t.overload
def common(
format: Construct[HexDumpDisplayedDict[str, t.Any], t.Any],
datasample: Buffer,
objsample: t.Dict[str, t.Any],
sizesample: t.Union[int, t.Type[Exception]] = ...,
**kw: t.Any
) -> None: ...
@t.overload
def common(
format: Construct[ParsedType, BuildTypes],
datasample: Buffer,

File diff suppressed because it is too large Load diff