nornir-automation / nornir

Pluggable multi-threaded framework with inventory management to help operate collections of devices
https://nornir.readthedocs.io/
Apache License 2.0
1.38k stars 234 forks source link

mypy v0.9XX issues #695

Closed itdependsnetworks closed 3 years ago

itdependsnetworks commented 3 years ago

Mypy 0.9XX is resulting in linter failures.

root@93107d63fc67:/github/nornir# make mypy
poetry run mypy nornir tests
nornir/core/__init__.py:61: error: Parse error before **
nornir/core/__init__.py:68: error: Parse error before **
nornir/core/__init__.py:172: error: Parse error before string literal
Makefile:33: recipe for target 'mypy' failed
make: *** [mypy] Error 1
root@93107d63fc67:/github/nornir#

Here is the relevant code that is causing the linter to fail, in case that is of use.

class Nornir(object):
    def with_processors(self, processors: List[Processor]) -> "Nornir":
        return Nornir(**{**self.__dict__, **{"processors": Processors(processors)}})

    def with_runner(self, runner: RunnerPlugin) -> "Nornir":
        return Nornir(**{**self.__dict__, **{"runner": runner}})

    @classmethod
    def validate(cls, v):
        if not isinstance(v, cls):
            raise ValueError(f"Nornir: Nornir expected not {type(v)}")
        return v

I am not that familiar with mypy, and a quick google search and review of release notes did not immediately point to any issue.

I have confirmed that running mypy with 0.812 did not result in any issues.

ktbyers commented 3 years ago

Let's pin mypy version to 0.812 in pyproject.toml.

Then we can periodical update the dev dependencies on the cadence we choose (as opposed to just having the build randomly break).

ktbyers commented 3 years ago

If you want to do that in your ruamel PR, then I can review/merge it.

dbarrosop commented 3 years ago

There was an issue with mypy 0.900 as we had to install some stubs but couldn't reproduce the issue describe here. The CI for #694 couldn't either. I suspect the error might be that an unsupported version of python was being used.

In any case, #696 fixes mypy.