Description
Pylint 2.4 introduced a new check: import-outside-toplevel
.
This check warns when modules are imported from places other than a module top-level, e.g., inside a function or a class.
With the upcoming upgrade of Pylint in our codebase, we are going to disable this check. However, it would have been nice to be able to enable it, so we can prevent imports outside of the top-level in our builds.
Since we started using our manifests for integration requirements, these function-level imports are no longer required or needed, and thus, can now be removed or moved to the top-level.
This issue is a placeholder to keep track of the status of this migration. If you resolve this issue for one of the integrations listed below, please refer to this issue in the PR you are creating (so we can keep track).
What has to be done?
While this is a pretty small and simple change, it takes a bit of time to do right and neat.
- Move the imports to the top.
- Combine duplicates and multiple imports from the same module.
- Make sure imports are ordered correctly, including the ones already there. (e.g., using
isort
). - Remove undeeded empty lines caused by moving the import from the old location.
- Pay attention to comments placed around the old import locations. You might need to move those with the import or adjust if needed.
- Make sure,
pylint
,black
andmypy
are happy. - Make sure tests still pass.
More information can be found in the developer documentation:
https://developers.home-assistant.io
Integrations to adjust
I've generated a list of all integrations that still use import outside of the top-level imports using the following command:
pylint homeassistant/components | grep import-outside-toplevel | cut -d'/' -f 3 | sort | uniq
Migrated integrations
- abode
- acer_projector
- ads
- amazon_polly
- anthemav
- apple_tv
- aprs
- aquostv
- arduino
- aruba
- auth
- automatic
- aws
- axis
- bbox
- bh1750
- bluesound
- bluetooth_le_tracker
- bme280
- bme680
- broadlink
- brottsplatskartan
- browser
- bt_home_hub_5
- bt_smarthub
- caldav
- cisco_ios
- co2signal
- config
- crimereports
- darksky
- decora
- denonavr
- deutsche_bahn
- device_tracker
- dht
- digital_ocean
- digitalloggers
- discogs
- discord
- dlib_face_detect
- dlib_face_identify
- dnsip
- dovado
- dsmr
- dte_energy_bridge
- dweet
- ebusd
- eliqonline
- elkm1
- epson
- eufy
- everlights
- feedreader
- fitbit
- flic
- flux_led
- fritz
- fritzbox_callmonitor
- fritzbox_netmonitor
- frontend
- frontier_silicon
- futurenow
- gc100
- geo_rss_events
- github
- gitlab_ci
- gntp
- goalfeed
- google_travel_time
- gpsd
- greenwave
- gtfs
- harman_kardon_avr
- harmony
- hikvisioncam
- hp_ilo
- html5
- http
- htu21d
- hue
- ifttt
- imap
- imap_email_content
- insteon
- iperf3
- iss
- isy994
- itach
- juicenet
- keyboard
- kira
- knx
- kodi
- konnected
- lastfm
- lg_soundbar
- lifx
- lifx_legacy
- linode
- linux_battery
- lirc
- liveboxplaytv
- logbook
- loopenergy
- lupusec
- lw12wifi
- magicseaweed
- mcp23017
- melissa
- message_bird
- metoffice
- miflora
- mitemp_bt
- mobile_app
- mopar
- mpd
- mqtt
- mvglive
- mychevy
- mythicbeastsdns
- namecheapdns
- nest
- netatmo
- netgear
- netgear_lte
- neurio_energy
- niko_home_control
- nilu
- nissan_leaf
- norway_air
- nuheat
- oasa_telematics
- ohmconnect
- onkyo
- onvif
- opencv
- openevse
- openweathermap
- orangepi_gpio
- osramlightify
- otp
- owntracks
- panasonic_bluray
- panasonic_viera
- pandora
- piglow
- pocketcasts
- proliphix
- prometheus
- proxy
- ptvsd
- pushbullet
- pushover
- qrcode
- raspihats
- recollect_waste
- recorder
- rejseplanen
- remember_the_milk
- repetier
- rflink
- rfxtrx
- route53
- rpi_pfio
- samsungtv
- season
- serial
- sesame
- seven_segments
- shiftr
- shodan
- skybeacon
- slack
- sma
- smappee
- smarthab
- snapcast
- snmp
- socialblade
- sonos
- sony_projector
- speedtestdotnet
- spotcrime
- spotify
- sql
- squeezebox
- startca
- statsd
- steam_online
- stream
- switchmate
- synology_srm
- syslog
- systemmonitor
- ted5000
- telegram_bot
- tellstick
- tensorflow
- thermoworks_smoke
- thingspeak
- tibber
- tikteck
- tplink_lte
- transport_nsw
- trend
- tts
- upcloud
- updater
- uscis
- vasttrafik
- venstar
- vera
- verisure
- vizio
- vlc
- w800rf32
- wake_on_lan
- waqi
- waterfurnace
- watson_iot
- waze_travel_time
- wemo
- wink
- workday
- wunderlist
- xmpp
- yamaha
- yamaha_musiccast
- yeelight
- yeelightsunflower
- yr
- zengge
- zestimate
- zha
- zigbee
Round 2!
- aftership Move import to top for aftership #28860
- alarmdecoder Move imports to top for alarmdecoder #28862
- ambient_station
- asuswrt
- canary
- clementine
- daikin
- danfoss_air
- datadog
- deconz
- decora_wifi
- deluge
- directv
- discovery
- dlink
- dlna_dmr
- dominos
- doorbird
- duke_energy
- dunehd
- dyson
- ebox
- ecoal_boiler
- econet
- ecovacs
- eddystone_temperature
- edimax
- ee_brightbox
- egardia
- eight_sleep
- emby
- emulated_roku
- enigma2
- enocean
- enphase_envoy
- entur_public_transport
- environment_canada
- envisalink
- epsonworkforce
- eq3btsmart
- esphome
- etherscan
- familyhub
- fastdotcom
- ffmpeg_motion
- ffmpeg_noise
- fibaro
- fido
- fints
- fixer
- fleetgo
- flexit
- flunearyou
- folder_watcher
- foobot
- fortigate
- free_mobile
- freebox
- frontend
- gearbest
- geizhals
- geo_json_events
- gitter
- gogogate2
- google_assistant
- google_pubsub
- google_translate
- gpmdp
- greeneye_monitor
- group
- gstreamer
- habitica
- hangouts
- hdmi_cec
- heatmiser
- hikvision
- history
- hlk_sw16
- homekit
- homekit_controller
- homematic
- homeworks
- horizon
- http
- hue
- hunterdouglas_powerview
- hydrawise
- ialarm
- icloud
- idteck_prox
- iglo
- ign_sismologia
- ihc
- influxdb
- iota
- ipma
- irish_rail_transport
- islamic_prayer_times
- izone
- joaoapps_join
- keenetic_ndms2
- kiwi
- kwb
- lacrosse
- lametric
- launch_library
- lg_netcast
- lightwave
- limitlessled
- litejet
- logi_circle
- london_underground
- luci
- lutron
- lutron_caseta
- lyft
- mailgun
- matrix
- maxcube
- media_extractor
- mediaroom
- meteo_france
- meteoalarm
- mfi
- mhz19
- microsoft
- mobile_app
- mochad
- modbus
- modem_callerid
- monoprice
- moon
- mycroft
- mysensors
- mystrom
- n26
- nad
- nanoleaf
- nederlandse_spoorwegen
- nello
- ness_alarm
- netdata
- netio
- nextbus
- nmap_tracker
- nmbs
- noaa_tides
- notion
- nsw_fuel_station
- nsw_rural_fire_service_feed
- nuimo_controller
- nut
- nx584
- onboarding
- openhome
- opensensemap
- openuv
- opple
- orvibo
- owlet
- pencom
- philips_js
- pilight
- pjlink
- plant
- plum_lightpad
- point
- postnl
- prezzibenzina
- ps4
- pushetta
- python_script
- qbittorrent
- qnap
- quantum_gateway
- qwikswitch
- rachio
- radarr
- raincloud
- rainmachine
- random
- raspyrfm
- recswitch
- remote_rpi_gpio
- ring
- ripple
- rocketchat
- roku
- roomba
- route53
- rova
- rpi_gpio_pwm
- rpi_rf
- russound_rio
- russound_rnet
- sabnzbd
- satel_integra
- scsgate
- sense
- sensehat
- serial_pm Move imports to top for serial_pm #28861
- seventeentrack
- sht31
- simplepush
- simplisafe
- sisyphus
- skybell
- sleepiq
- smarty
- smhi
- sochain
- solaredge
- somfy_mylink
- sonarr
- soundtouch
- spc
- spider
- starlingbank
- statistics
- stiebel_eltron
- stream
- streamlabswater
- supla
- swiss_hydrological_data
- swiss_public_transport
- switchbot
- switcher_kis
- syncthru
- synology
- synologydsm
- system_log
- tado
- tahoma
- tank_utility
- tapsaff
- tautulli
- tellduslive
- temper
- tensorflow
- thinkingcleaner
- todoist
- tof
- toon
- touchline
- traccar
- trackr
- tradfri
- trafikverket_weatherstation
- travisci
- tuya
- twilio_call
- ubee
- unifi_direct
- upnp
- uptimerobot
- usgs_earthquakes_feed
- uvc
- velux
- version
- vizio
- volkszaehler
- volvooncall
- vultr
- watson_tts
- webostv
- websocket_api
- wirelesstag
- xeoma
- xfinity
- xiaomi
- xiaomi_aqara
- xiaomi_tv
- yale_smart_alarm
- yi
- zabbix
- zha
- zhong_hong
- ziggo_mediabox_xl
- zoneminder
- zwave