Having trouble setting up a development environment

Hi,
Iḿ trying to create a pull request for a new cover-template, to combine multiple cover switches into one. It works for my setup now, so I thought I’d contribute my code.
I’m running into problems when I try to run tests… my own tests fail (obviously since I haven’t gotten round to filling them out :wink: ) but when I just checkout the development branch, without my code ‘tox’ also fails, with typing errors: “ERROR: typing: commands failed”

What am I missing here ? Where are the logs ?

When I run the last command shown on my screen
/home/timt/HomeAssistanttest/home-assistant/.tox/typing/bin/mypy --silent-imports homeassistant
I get the folllowing message
homeassistant/util/unit_system.py:108: error: misplaced type annotation

Currently on a Centos 7 system, a clone of the main github repo, on develop branch

Suggestions welcome.

Did you run script/setup?

Just run tests using py.test tests/

Yes, followed the instructions I found here: https://home-assistant.io/developers/development_environment/

Took me a couple of tries before that went smoothly, then, once I’d figured out the correct procedure (which involved setting locale correctly, the setup script went smoothly.

That also fails, complaints about a missing pydispatch, which pip3 claims is installed
That error seems to originate somewhere in the pytest configuration.

Thing is, when using tox, the tests run fine; tox fails at the typing phase.

I’m currently not on a very usable connection, I’ll capture the output tomorrow

Running tox also fails for me on the same error. All the other tests work without issues, so my dev environment is otherwise working as expected

Ok… that took a bit longer than expected… This is edited output of the current (641ba014f2f4310833f866ddbc5b1012aa135407) dev branch

typing runtests: PYTHONHASHSEED=‘438580598’
typing runtests: commands[0] | mypy --silent-imports homeassistant
Warning: --silent-imports has been replaced by --ignore-missing-imports --follow-imports=skip
homeassistant/util/unit_system.py:108: error: misplaced type annotation
ERROR: InvocationError: ‘/home/timt/HomeAssistant/home-assistant/.tox/typing/bin/mypy --silent-imports homeassistant’
___________________________________ summary ____________________________________
SKIPPED: py34: InterpreterNotFound: python3.4
py35: commands succeeded
SKIPPED: py36: InterpreterNotFound: python3.6
lint: commands succeeded
requirements: commands succeeded
ERROR: typing: commands failed

This is the offending method in homeassistant/util/unit_system.py

    def length(self: object, length: float, from_unit: str) -> float:
        """Convert the given length to this unit system."""
        if not isinstance(length, Number):
            raise TypeError('{} is not a numeric value.'.format(str(length)))

        return distance_util.convert(length, from_unit,
                                     self.length_unit)  # type: float   

The last line is line 108…
Removing the # type: float annotation brings to light a lot of other missing type errors, in other code.

I’m not familiar with tox; can anybody give me a hint on how to disable these type tests ?

I have exactly the same issue. Did you finally solve it or should we just ignore it?

I decided to ignore it, and concentrate on getting my own code working, running only the tests for my code.
(And then I got seriously sidetracked… Still have to finish this project.)

Did you ever manage to resolve this?
I’m having that same issue… tox fails on typing tests, log extracts below.

I followed the instructions on https://developers.home-assistant.io/docs/en/development_environment.html

What I’ve tried:

  • running my tests towards the intact dev branch, as is, without doing any changes
  • running as a user
  • running as user with sudo
  • running as root
  • tried on Ubuntu 18.04 WSL, AND Ubuntu Server 18.04 x86

Results

SKIPPED:  py35: InterpreterNotFound: python3.5
  py36: commands succeeded
SKIPPED:  py37: InterpreterNotFound: python3.7
SKIPPED:  py38: InterpreterNotFound: python3.8
  lint: commands succeeded
  pylint: commands succeeded
ERROR:   typing: commands failed
  cov: commands succeeded

Logs:

typing inst-nodeps: /home/karim/test2/home-assistant/.tox/.tmp/package/1/homeassistant-0.89.0.dev0.zip
typing installed: aiohttp==3.5.4,asn1crypto==0.24.0,astral==1.9.2,astroid==2.1.0,async-timeout==3.0.1,asynctest==0.12.2,atomicwrites==1.3.0,attrs==18.2.0,bcrypt==3.1.5,certifi==2018.11.29,cffi==1.12.1,chardet==3.0.4,coverage==4.5.2,coveralls==1.2.0,cryptography==2.5,docopt==0.6.2,entrypoints==0.3,flake8==3.7.5,flake8-docstrings==1.3.0,flake8-polyfill==1.0.2,homeassistant==0.89.0.dev0,idna==2.8,idna-ssl==1.1.0,isort==4.3.4,Jinja2==2.10,lazy-object-proxy==1.3.1,MarkupSafe==1.1.0,mccabe==0.6.1,mock-open==1.3.1,more-itertools==6.0.0,multidict==4.5.2,mypy==0.660,mypy-extensions==0.4.1,packaging==19.0,pluggy==0.8.1,py==1.8.0,pycodestyle==2.5.0,pycparser==2.19,pydocstyle==3.0.0,pyflakes==2.1.0,PyJWT==1.6.4,pylint==2.2.2,pyparsing==2.3.1,pytest==4.2.1,pytest-aiohttp==0.3.0,pytest-cov==2.6.1,pytest-sugar==0.9.2,pytest-timeout==1.3.3,python-slugify==1.2.6,pytz==2018.9,PyYAML==3.13,requests==2.21.0,requests-mock==1.5.2,ruamel.yaml==0.15.88,six==1.12.0,snowballstemmer==1.2.1,termcolor==1.1.0,typed-ast==1.2.0,typing-extensions==3.7.2,Unidecode==1.0.23,urllib3==1.24.1,voluptuous==0.11.5,voluptuous-serialize==2.1.0,wrapt==1.11.1,yarl==1.3.0
typing run-test-pre: PYTHONHASHSEED='1987861804'
typing runtests: commands[0] | /bin/bash -c 'mypy homeassistant/*.py homeassistant/{auth,util}/ homeassistant/helpers/{__init__,aiohttp_client,area_registry,condition,deprecation,dispatcher,entity_values,entityfilter,icon,intent,json,location,signal,state,sun,temperature,translation,typing}.py'
homeassistant/monkey_patch.py:66: note: unused 'type: ignore' comment
homeassistant/__main__.py:375: warning: Returning Any from function declared to return "int"
ERROR: InvocationError for command '/bin/bash -c mypy homeassistant/*.py homeassistant/{auth,util}/ homeassistant/helpers/{__init__,aiohttp_client,area_registry,condition,deprecation,dispatcher,entity_values,entityfilter,icon,intent,json,location,signal,state,sun,temperature,translation,typing}.py' (exited with code 1)

Nope, never resolved this or finished the project. Discovered that I could group covers through an existing template, which works fine for me, so I lost interest…

Sorry I can’t help