Skip to content

Commit

Permalink
Reduces the number of ignored mypy errors (onnx#4495)
Browse files Browse the repository at this point in the history
* Remove unnecessary import (onnx#4484)

* remove unnecessary import

Signed-off-by: xadupre <[email protected]>

* lint

Signed-off-by: xadupre <[email protected]>

* black

Signed-off-by: xadupre <[email protected]>

* black

Signed-off-by: xadupre <[email protected]>

* lint

Signed-off-by: xadupre <[email protected]>

* restore old import

Signed-off-by: xadupre <[email protected]>

Signed-off-by: xadupre <[email protected]>

* fix mypy issues

Signed-off-by: sdpython <[email protected]>
Signed-off-by: xadupre <[email protected]>

* fix mypy issues

Signed-off-by: sdpython <[email protected]>
Signed-off-by: xadupre <[email protected]>

* update mypy

Signed-off-by: sdpython <[email protected]>
Signed-off-by: xadupre <[email protected]>

* primary ops to function milestone 1 (onnx#4458)

* primary ops to function milestone 1

Signed-off-by: Liqun Fu <[email protected]>

* float type

Signed-off-by: Liqun Fu <[email protected]>

* formatting

Signed-off-by: Liqun Fu <[email protected]>

* pass backend test

Signed-off-by: Liqun Fu <[email protected]>

* formatting

Signed-off-by: Liqun Fu <[email protected]>

* commit

Signed-off-by: Liqun Fu <[email protected]>

* format

Signed-off-by: Liqun Fu <[email protected]>

* format

Signed-off-by: Liqun Fu <[email protected]>

* layernorm

Signed-off-by: Liqun Fu <[email protected]>

* pass runtime check

Signed-off-by: Liqun Fu <[email protected]>

* format

Signed-off-by: Liqun Fu <[email protected]>

* pure function

Signed-off-by: Liqun Fu <[email protected]>

* format

Signed-off-by: Liqun Fu <[email protected]>

* reviewer's comments, clean up some

Signed-off-by: Liqun Fu <[email protected]>

* keep op original version

Signed-off-by: Liqun Fu <[email protected]>

* fix gtest.function_verify_test

Signed-off-by: Liqun Fu <[email protected]>

* formatting

Signed-off-by: Liqun Fu <[email protected]>

* update according to reviewer's comment

Signed-off-by: Liqun Fu <[email protected]>

Signed-off-by: Liqun Fu <[email protected]>
Co-authored-by: G. Ramalingam <[email protected]>
Signed-off-by: xadupre <[email protected]>

* lint

Signed-off-by: sdpython <[email protected]>
Signed-off-by: xadupre <[email protected]>

* remove # type: ignore for imports

Signed-off-by: xadupre <[email protected]>

* lint

Signed-off-by: sdpython <[email protected]>
Signed-off-by: xadupre <[email protected]>

* Use filesystem to load filename to prevent encoding issues on Windows (onnx#4470)

* apply filesystem from C+17 to handle encoding on Windows

Signed-off-by: Chun-Wei Chen <[email protected]>

* add comment in CMakeLists

Signed-off-by: Chun-Wei Chen <[email protected]>

* precise msg if missing support

Signed-off-by: Chun-Wei Chen <[email protected]>

* void normalize_sep for two types

Signed-off-by: Chun-Wei Chen <[email protected]>

* remove typo const

Signed-off-by: Chun-Wei Chen <[email protected]>

* remove template functions to header

Signed-off-by: Chun-Wei Chen <[email protected]>

* apply clang-format

Signed-off-by: Chun-Wei Chen <[email protected]>

* use _wstat

Signed-off-by: Chun-Wei Chen <[email protected]>

* use define function to refactor code

Signed-off-by: Chun-Wei Chen <[email protected]>

* add required C++ version in readme

Signed-off-by: Chun-Wei Chen <[email protected]>

* void char* for std::string in test

Signed-off-by: Chun-Wei Chen <[email protected]>

* fix clang-format

Signed-off-by: Chun-Wei Chen <[email protected]>

* move wchar_t and wstring only for Windows

Signed-off-by: Chun-Wei Chen <[email protected]>

* refactor template

Signed-off-by: Chun-Wei Chen <[email protected]>

* typo

Signed-off-by: Chun-Wei Chen <[email protected]>

* use char tempalte in template

Signed-off-by: Chun-Wei Chen <[email protected]>

* add comments

Signed-off-by: Chun-Wei Chen <[email protected]>

* add tests for wstring

Signed-off-by: Chun-Wei Chen <[email protected]>

* typo

Signed-off-by: Chun-Wei Chen <[email protected]>

* nit comments

Signed-off-by: Chun-Wei Chen <[email protected]>

* use existing functions from std::filesystem::path

Signed-off-by: Chun-Wei Chen <[email protected]>

* honor !=

Signed-off-by: Chun-Wei Chen <[email protected]>

* constexpr const char

Signed-off-by: Chun-Wei Chen <[email protected]>

* checker disallow absolute path in external tensors; remove related tests

Signed-off-by: Chun-Wei Chen <[email protected]>

* fix format

Signed-off-by: Chun-Wei Chen <[email protected]>

* add more checker tests

Signed-off-by: Chun-Wei Chen <[email protected]>

* black

Signed-off-by: Chun-Wei Chen <[email protected]>

* improve comments

Signed-off-by: Chun-Wei Chen <[email protected]>

Signed-off-by: Chun-Wei Chen <[email protected]>
Signed-off-by: xadupre <[email protected]>

* remove unnecessary ignore-missing-type

Signed-off-by: sdpython <[email protected]>
Signed-off-by: xadupre <[email protected]>

* remove two type ignore

Signed-off-by: xadupre <[email protected]>

* lint

Signed-off-by: xadupre <[email protected]>

* type

Signed-off-by: xadupre <[email protected]>

Signed-off-by: xadupre <[email protected]>
Signed-off-by: sdpython <[email protected]>
Signed-off-by: Liqun Fu <[email protected]>
Signed-off-by: Chun-Wei Chen <[email protected]>
Co-authored-by: sdpython <[email protected]>
Co-authored-by: liqun Fu <[email protected]>
Co-authored-by: G. Ramalingam <[email protected]>
Co-authored-by: Chun-Wei Chen <[email protected]>
  • Loading branch information
5 people authored and Bjarke Roune committed May 6, 2023
1 parent 68e7e43 commit 2e91d06
Show file tree
Hide file tree
Showing 212 changed files with 235 additions and 225 deletions.
2 changes: 1 addition & 1 deletion docs/Operators.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ expect(node, inputs=[x], outputs=[y], name="test_abs")
```python
# SPDX-License-Identifier: Apache-2.0

import numpy as np # type: ignore
import numpy as np


def abs(input: np.ndarray) -> np.ndarray:
Expand Down
2 changes: 1 addition & 1 deletion onnx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def _serialize(proto: Union[bytes, google.protobuf.message.Message]) -> bytes:
"Please use save_as_external_data to save tensors separately from the model file."
) from e
raise
return result
return result # type: ignore
raise TypeError(
f"No SerializeToString method is detected. Neither proto is a str.\ntype is {type(proto)}"
)
Expand Down
2 changes: 1 addition & 1 deletion onnx/backend/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from collections import namedtuple
from typing import Any, Dict, NewType, Optional, Sequence, Tuple, Type

import numpy # type: ignore
import numpy

import onnx.checker
import onnx.onnx_cpp2py_export.checker as c_checker
Expand Down
2 changes: 1 addition & 1 deletion onnx/backend/sample/ops/abs.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0

import numpy as np # type: ignore
import numpy as np


def abs(input: np.ndarray) -> np.ndarray:
Expand Down
2 changes: 1 addition & 1 deletion onnx/backend/test/case/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from textwrap import dedent
from typing import Any, Dict, List, Tuple, Type

import numpy as np # type: ignore
import numpy as np


def process_snippet(op_name: str, name: str, export: Any) -> Tuple[str, str]:
Expand Down
2 changes: 1 addition & 1 deletion onnx/backend/test/case/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys
from typing import List, Optional, Sequence

import numpy as np # type: ignore
import numpy as np

from onnx import ModelProto

Expand Down
2 changes: 1 addition & 1 deletion onnx/backend/test/case/model/expand.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from typing import Sequence

import numpy as np # type: ignore
import numpy as np

import onnx

Expand Down
2 changes: 1 addition & 1 deletion onnx/backend/test/case/model/gradient.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0

import numpy as np # type: ignore
import numpy as np

import onnx
from onnx.defs import AI_ONNX_PREVIEW_TRAINING_DOMAIN, ONNX_DOMAIN
Expand Down
2 changes: 1 addition & 1 deletion onnx/backend/test/case/model/sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import typing
from typing import List, Optional, Union

import numpy as np # type: ignore
import numpy as np

import onnx
from onnx import TensorProto
Expand Down
2 changes: 1 addition & 1 deletion onnx/backend/test/case/model/shrink.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0

import numpy as np # type: ignore
import numpy as np

import onnx

Expand Down
2 changes: 1 addition & 1 deletion onnx/backend/test/case/model/sign.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0

import numpy as np # type: ignore
import numpy as np

import onnx

Expand Down
2 changes: 1 addition & 1 deletion onnx/backend/test/case/model/single-relu.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0

import numpy as np # type: ignore
import numpy as np

import onnx

Expand Down
2 changes: 1 addition & 1 deletion onnx/backend/test/case/model/stringnormalizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from typing import Sequence

import numpy as np # type: ignore
import numpy as np

import onnx

Expand Down
2 changes: 1 addition & 1 deletion onnx/backend/test/case/node/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from copy import deepcopy
from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union

import numpy as np # type: ignore
import numpy as np

import onnx
import onnx.mapping
Expand Down
2 changes: 1 addition & 1 deletion onnx/backend/test/case/node/abs.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0

import numpy as np # type: ignore
import numpy as np

import onnx
from onnx.backend.sample.ops.abs import abs
Expand Down
2 changes: 1 addition & 1 deletion onnx/backend/test/case/node/acos.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0

import numpy as np # type: ignore
import numpy as np

import onnx

Expand Down
2 changes: 1 addition & 1 deletion onnx/backend/test/case/node/acosh.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0

import numpy as np # type: ignore
import numpy as np

import onnx

Expand Down
2 changes: 1 addition & 1 deletion onnx/backend/test/case/node/adagrad.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0

import numpy as np # type: ignore
import numpy as np

import onnx
from onnx.defs import AI_ONNX_PREVIEW_TRAINING_DOMAIN
Expand Down
2 changes: 1 addition & 1 deletion onnx/backend/test/case/node/adam.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0

import numpy as np # type: ignore
import numpy as np

import onnx
from onnx.defs import AI_ONNX_PREVIEW_TRAINING_DOMAIN
Expand Down
2 changes: 1 addition & 1 deletion onnx/backend/test/case/node/add.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0

import numpy as np # type: ignore
import numpy as np

import onnx

Expand Down
2 changes: 1 addition & 1 deletion onnx/backend/test/case/node/and.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0

import numpy as np # type: ignore
import numpy as np

import onnx

Expand Down
2 changes: 1 addition & 1 deletion onnx/backend/test/case/node/argmax.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0

import numpy as np # type: ignore
import numpy as np

import onnx

Expand Down
2 changes: 1 addition & 1 deletion onnx/backend/test/case/node/argmin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0

import numpy as np # type: ignore
import numpy as np

import onnx

Expand Down
2 changes: 1 addition & 1 deletion onnx/backend/test/case/node/asin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0

import numpy as np # type: ignore
import numpy as np

import onnx

Expand Down
2 changes: 1 addition & 1 deletion onnx/backend/test/case/node/asinh.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0

import numpy as np # type: ignore
import numpy as np

import onnx

Expand Down
2 changes: 1 addition & 1 deletion onnx/backend/test/case/node/atan.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0

import numpy as np # type: ignore
import numpy as np

import onnx

Expand Down
2 changes: 1 addition & 1 deletion onnx/backend/test/case/node/atanh.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0

import numpy as np # type: ignore
import numpy as np

import onnx

Expand Down
2 changes: 1 addition & 1 deletion onnx/backend/test/case/node/averagepool.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0

import numpy as np # type: ignore
import numpy as np

import onnx

Expand Down
2 changes: 1 addition & 1 deletion onnx/backend/test/case/node/batchnorm.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0

import numpy as np # type: ignore
import numpy as np

import onnx

Expand Down
2 changes: 1 addition & 1 deletion onnx/backend/test/case/node/bernoulli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0

import numpy as np # type: ignore
import numpy as np

import onnx

Expand Down
2 changes: 1 addition & 1 deletion onnx/backend/test/case/node/bitshift.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0

import numpy as np # type: ignore
import numpy as np

import onnx

Expand Down
2 changes: 1 addition & 1 deletion onnx/backend/test/case/node/blackmanwindow.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: Apache-2.0


import numpy as np # type: ignore
import numpy as np

import onnx

Expand Down
2 changes: 1 addition & 1 deletion onnx/backend/test/case/node/cast.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import sys

import numpy as np # type: ignore
import numpy as np

import onnx
from onnx import TensorProto
Expand Down
2 changes: 1 addition & 1 deletion onnx/backend/test/case/node/castlike.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import sys

import numpy as np # type: ignore
import numpy as np

import onnx
from onnx import TensorProto
Expand Down
2 changes: 1 addition & 1 deletion onnx/backend/test/case/node/ceil.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0

import numpy as np # type: ignore
import numpy as np

import onnx

Expand Down
2 changes: 1 addition & 1 deletion onnx/backend/test/case/node/celu.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0

import numpy as np # type: ignore
import numpy as np

import onnx

Expand Down
2 changes: 1 addition & 1 deletion onnx/backend/test/case/node/center_crop_pad.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0

import numpy as np # type: ignore
import numpy as np

import onnx

Expand Down
2 changes: 1 addition & 1 deletion onnx/backend/test/case/node/clip.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0

import numpy as np # type: ignore
import numpy as np

import onnx

Expand Down
2 changes: 1 addition & 1 deletion onnx/backend/test/case/node/col2im.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import absolute_import, division, print_function, unicode_literals

import numpy as np # type: ignore
import numpy as np

import onnx

Expand Down
2 changes: 1 addition & 1 deletion onnx/backend/test/case/node/compress.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0

import numpy as np # type: ignore
import numpy as np

import onnx

Expand Down
2 changes: 1 addition & 1 deletion onnx/backend/test/case/node/concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from typing import Any, Dict, Sequence

import numpy as np # type: ignore
import numpy as np

import onnx

Expand Down
2 changes: 1 addition & 1 deletion onnx/backend/test/case/node/constant.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0

import numpy as np # type: ignore
import numpy as np

import onnx

Expand Down
2 changes: 1 addition & 1 deletion onnx/backend/test/case/node/constantofshape.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0

import numpy as np # type: ignore
import numpy as np

import onnx

Expand Down
2 changes: 1 addition & 1 deletion onnx/backend/test/case/node/conv.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0

import numpy as np # type: ignore
import numpy as np

import onnx

Expand Down
2 changes: 1 addition & 1 deletion onnx/backend/test/case/node/convinteger.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0

import numpy as np # type: ignore
import numpy as np

import onnx

Expand Down
2 changes: 1 addition & 1 deletion onnx/backend/test/case/node/convtranspose.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0

import numpy as np # type: ignore
import numpy as np

import onnx

Expand Down
2 changes: 1 addition & 1 deletion onnx/backend/test/case/node/cos.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0

import numpy as np # type: ignore
import numpy as np

import onnx

Expand Down
2 changes: 1 addition & 1 deletion onnx/backend/test/case/node/cosh.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: Apache-2.0

import numpy as np # type: ignore
import numpy as np

import onnx

Expand Down
Loading

0 comments on commit 2e91d06

Please sign in to comment.