diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 980e07f9e..826c371e9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,22 +1,21 @@ repos: - repo: https://github.com/asottile/pyupgrade - rev: v3.2.0 + rev: v3.15.0 hooks: - id: pyupgrade args: ['--py36-plus','--exit-zero-even-if-changed'] - repo: https://github.com/pycqa/isort - rev: 5.10.1 + rev: 5.13.2 hooks: - id: isort - files: '.*' - args: ['--profile=black'] + args: ["--profile", "black", "--filter-files"] - repo: https://github.com/psf/black - rev: 22.10.0 + rev: 24.1.1 hooks: - id: black language_version: python - repo: https://github.com/PyCQA/flake8 - rev: 3.9.2 + rev: 7.0.0 hooks: - id: flake8 # TODO: remove F40x, E772 and fix errors @@ -26,17 +25,17 @@ repos: # - flake8-print - flake8-2020 - repo: https://github.com/mgedmin/check-manifest - rev: "0.48" + rev: "0.49" hooks: - id: check-manifest - repo: https://github.com/pre-commit/mirrors-mypy - rev: 'v0.982' + rev: 'v1.8.0' hooks: - id: mypy files: '^src/' additional_dependencies: - types-attrs - repo: https://github.com/pre-commit/pygrep-hooks - rev: v1.9.0 + rev: v1.10.0 hooks: - id: rst-backticks diff --git a/mypy.ini b/mypy.ini new file mode 100644 index 000000000..8ca8d08ea --- /dev/null +++ b/mypy.ini @@ -0,0 +1,5 @@ +[mypy] +strict = True + +[mypy-tests.*] +disable_error_code = ["empty-body"] \ No newline at end of file diff --git a/src/visions/backends/numpy/test_utils.py b/src/visions/backends/numpy/test_utils.py index 139869862..fcfbd2c6d 100644 --- a/src/visions/backends/numpy/test_utils.py +++ b/src/visions/backends/numpy/test_utils.py @@ -1,6 +1,7 @@ """ A selection of testing utilities for visions. """ + import functools from typing import Callable, Dict, List, Optional, Type, Union diff --git a/src/visions/backends/pandas/test_utils.py b/src/visions/backends/pandas/test_utils.py index 09ea42f23..2d7034f55 100644 --- a/src/visions/backends/pandas/test_utils.py +++ b/src/visions/backends/pandas/test_utils.py @@ -1,6 +1,7 @@ """ A selection of testing utilities for visions. """ + import functools from typing import Callable, Dict, List, Optional, Type, Union diff --git a/src/visions/relations/__init__.py b/src/visions/relations/__init__.py index a28248f94..b48c2456d 100644 --- a/src/visions/relations/__init__.py +++ b/src/visions/relations/__init__.py @@ -1,4 +1,5 @@ """This module contains (predefined) relations.""" + from visions.relations.relations import ( IdentityRelation, InferenceRelation, diff --git a/src/visions/types/type.py b/src/visions/types/type.py index b4e6218f9..702dcf3b5 100644 --- a/src/visions/types/type.py +++ b/src/visions/types/type.py @@ -58,21 +58,27 @@ def relations(cls) -> RelationsIterManager: if cls._relations is None: cls._relations = RelationsIterManager( [ - attr.evolve( - r, - type=cls, - relationship=cls.contains_op - if r.relationship is None - else r.relationship, - ) - if isinstance(r, IdentityRelation) - else attr.evolve( - r, - type=cls, - relationship=multimethod(r.relationship) - if r.relationship is not None - else None, - transformer=multimethod(r.transformer), + ( + attr.evolve( + r, + type=cls, + relationship=( + cls.contains_op + if r.relationship is None + else r.relationship + ), + ) + if isinstance(r, IdentityRelation) + else attr.evolve( + r, + type=cls, + relationship=( + multimethod(r.relationship) + if r.relationship is not None + else None + ), + transformer=multimethod(r.transformer), + ) ) for r in cls.get_relations() ] diff --git a/src/visions/typesets/typeset.py b/src/visions/typesets/typeset.py index f42fa3021..2789ba8b3 100644 --- a/src/visions/typesets/typeset.py +++ b/src/visions/typesets/typeset.py @@ -299,7 +299,6 @@ def infer(self, data: Sequence) -> Tuple[Sequence, Any, dict]: return traverse_graph(data, self.root_node, self.relation_graph) def infer_type(self, data: Sequence) -> Union[T, Dict[str, T]]: - """The inferred type found using all type relations. Args: diff --git a/tests/test_typeset_external_type.py b/tests/test_typeset_external_type.py index 726210b47..d8513d17c 100644 --- a/tests/test_typeset_external_type.py +++ b/tests/test_typeset_external_type.py @@ -2,6 +2,7 @@ Test for issue 85 https://github.com/dylan-profiler/visions/issues/85 """ + import pytest from visions import VisionsTypeset