Skip to content

Commit

Permalink
mypy: update to 0.782 and enable it with Python 3.8 and 3.9 (onnx#3966)
Browse files Browse the repository at this point in the history
* Upgrade to 0.782 and fix failures for Python 3.8 and 3.9

Signed-off-by: Chun-Wei Chen <[email protected]>
  • Loading branch information
jcwchen authored Jan 31, 2022
1 parent 83fa57c commit b5de586
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
8 changes: 8 additions & 0 deletions .azure-pipelines/Windows-CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ jobs:
vmImage: 'windows-2019'
strategy:
matrix:
py39:
python.version: '3.9'
onnx_ml: 0
onnx_verify_proto: 0
py38:
python.version: '3.8'
onnx_ml: 0
onnx_verify_proto: 0
py37:
python.version: '3.7'
onnx_ml: 0
Expand Down
1 change: 1 addition & 0 deletions onnx/backend/test/report/coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ def report_csv(self, all_ops: List[Text], passed: List[Optional[Text]], experime
if os.path.isfile(nodes_path):
with open(nodes_path, 'r') as nodes_file:
reader = csv.DictReader(nodes_file)
assert reader.fieldnames
frameworks = list(reader.fieldnames)
for row in reader:
op = row[str('Op')]
Expand Down
16 changes: 8 additions & 8 deletions onnx/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -826,10 +826,10 @@ def printable_node(node: NodeProto, prefix: Text = '', subgraphs: bool = False)
printed_attrs = []
for attr in node.attribute:
if subgraphs:
printed_attr, gs = printable_attribute(attr, subgraphs)
assert isinstance(gs, list)
graphs.extend(gs)
printed_attrs.append(printed_attr)
printed_attr_subgraphs = printable_attribute(attr, subgraphs)
assert isinstance(printed_attr_subgraphs[1], list)
graphs.extend(printed_attr_subgraphs[1])
printed_attrs.append(printed_attr_subgraphs[0])
else:
printed = printable_attribute(attr)
assert isinstance(printed, Text)
Expand Down Expand Up @@ -894,10 +894,10 @@ def printable_graph(graph: GraphProto, prefix: Text = '') -> Text:
graphs: List[GraphProto] = []
# body
for node in graph.node:
pn, gs = printable_node(node, indent, subgraphs=True)
assert isinstance(gs, list)
content.append(pn)
graphs.extend(gs)
contents_subgraphs = printable_node(node, indent, subgraphs=True)
assert isinstance(contents_subgraphs[1], list)
content.append(contents_subgraphs[0])
graphs.extend(contents_subgraphs[1])
# tail
tail = ['return']
if len(graph.output):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def run(self):
tests_require.append('nbval')
tests_require.append('tabulate')

extras_require['mypy'] = ['mypy==0.760', 'types-protobuf==3.18.4']
extras_require['mypy'] = ['mypy==0.782', 'types-protobuf==3.18.4']

################################################################################
# Final
Expand Down

0 comments on commit b5de586

Please sign in to comment.