Skip to content

Commit

Permalink
Isort preparations (#16555)
Browse files Browse the repository at this point in the history
* Don't treat typing as an "in-between" module for import order

That was a < 3.5 era thing.

* Tighten scope of some pylint unused-import disables

To avoid isort moving a top level one around, undesirably broadening its
scope.
  • Loading branch information
scop authored and balloob committed Sep 11, 2018
1 parent a059cc8 commit ee69664
Show file tree
Hide file tree
Showing 26 changed files with 10 additions and 35 deletions.
1 change: 0 additions & 1 deletion homeassistant/__main__.py
Expand Up @@ -7,7 +7,6 @@
import subprocess
import sys
import threading

from typing import List, Dict, Any # noqa pylint: disable=unused-import


Expand Down
1 change: 0 additions & 1 deletion homeassistant/bootstrap.py
Expand Up @@ -5,7 +5,6 @@
import sys
from time import time
from collections import OrderedDict

from typing import Any, Optional, Dict

import voluptuous as vol
Expand Down
1 change: 0 additions & 1 deletion homeassistant/components/apple_tv.py
Expand Up @@ -6,7 +6,6 @@
"""
import asyncio
import logging

from typing import Sequence, TypeVar, Union

import voluptuous as vol
Expand Down
1 change: 0 additions & 1 deletion homeassistant/components/geo_location/demo.py
Expand Up @@ -8,7 +8,6 @@
import random
from datetime import timedelta
from math import pi, cos, sin, radians

from typing import Optional

from homeassistant.components.geo_location import GeoLocationEvent
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/google_assistant/__init__.py
Expand Up @@ -6,6 +6,7 @@
"""
import asyncio
import logging
from typing import Dict, Any

import aiohttp
import async_timeout
Expand All @@ -14,7 +15,6 @@

# Typing imports
from homeassistant.core import HomeAssistant
from typing import Dict, Any

from homeassistant.const import CONF_NAME
from homeassistant.helpers import config_validation as cv
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/google_assistant/auth.py
@@ -1,11 +1,11 @@
"""Google Assistant OAuth View."""

import logging
from typing import Dict, Any

# Typing imports
# if False:
from aiohttp.web import Request, Response
from typing import Dict, Any

from homeassistant.core import HomeAssistant
from homeassistant.components.http import HomeAssistantView
Expand Down
1 change: 0 additions & 1 deletion homeassistant/components/media_player/cast.py
Expand Up @@ -7,7 +7,6 @@
import asyncio
import logging
import threading

from typing import Optional, Tuple

import attr
Expand Down
4 changes: 1 addition & 3 deletions homeassistant/components/media_player/webostv.py
Expand Up @@ -8,9 +8,7 @@
from datetime import timedelta
import logging
from urllib.parse import urlparse

# pylint: disable=unused-import
from typing import Dict # noqa: F401
from typing import Dict # noqa: F401 pylint: disable=unused-import

import voluptuous as vol

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/rachio.py
Expand Up @@ -6,10 +6,10 @@
"""
import asyncio
import logging
from typing import Optional

from aiohttp import web
import voluptuous as vol
from typing import Optional
from homeassistant.auth.util import generate_secret
from homeassistant.components.http import HomeAssistantView
from homeassistant.const import CONF_API_KEY, EVENT_HOMEASSISTANT_STOP, URL_API
Expand Down
1 change: 0 additions & 1 deletion homeassistant/components/recorder/__init__.py
Expand Up @@ -15,7 +15,6 @@
import queue
import threading
import time

from typing import Any, Dict, Optional # noqa: F401

import voluptuous as vol
Expand Down
3 changes: 1 addition & 2 deletions homeassistant/config.py
Expand Up @@ -6,8 +6,7 @@
import os
import re
import shutil
# pylint: disable=unused-import
from typing import ( # noqa: F401
from typing import ( # noqa: F401 pylint: disable=unused-import
Any, Tuple, Optional, Dict, List, Union, Callable, Sequence, Set)
from types import ModuleType
import voluptuous as vol
Expand Down
3 changes: 1 addition & 2 deletions homeassistant/core.py
Expand Up @@ -18,8 +18,7 @@
import uuid

from types import MappingProxyType
# pylint: disable=unused-import
from typing import ( # NOQA
from typing import ( # noqa: F401 pylint: disable=unused-import
Optional, Any, Callable, List, TypeVar, Dict, Coroutine, Set,
TYPE_CHECKING, Awaitable, Iterator)

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/data_entry_flow.py
@@ -1,8 +1,8 @@
"""Classes to help gather user submissions."""
import logging
from typing import Dict, Any, Callable, Hashable, List, Optional # noqa pylint: disable=unused-import
import uuid
import voluptuous as vol
from typing import Dict, Any, Callable, Hashable, List, Optional # noqa pylint: disable=unused-import
from .core import callback, HomeAssistant
from .exceptions import HomeAssistantError

Expand Down
1 change: 0 additions & 1 deletion homeassistant/helpers/__init__.py
@@ -1,6 +1,5 @@
"""Helper methods for components within Home Assistant."""
import re

from typing import Any, Iterable, Tuple, Sequence, Dict

from homeassistant.const import CONF_PLATFORM
Expand Down
1 change: 0 additions & 1 deletion homeassistant/helpers/config_validation.py
Expand Up @@ -7,7 +7,6 @@
from socket import _GLOBAL_DEFAULT_TIMEOUT
import logging
import inspect

from typing import Any, Union, TypeVar, Callable, Sequence, Dict

import voluptuous as vol
Expand Down
1 change: 0 additions & 1 deletion homeassistant/helpers/entity.py
Expand Up @@ -4,7 +4,6 @@
import logging
import functools as ft
from timeit import default_timer as timer

from typing import Optional, List, Iterable

from homeassistant.const import (
Expand Down
1 change: 0 additions & 1 deletion homeassistant/helpers/json.py
Expand Up @@ -2,7 +2,6 @@
from datetime import datetime
import json
import logging

from typing import Any

_LOGGER = logging.getLogger(__name__)
Expand Down
4 changes: 1 addition & 3 deletions homeassistant/loader.py
Expand Up @@ -15,9 +15,7 @@
import logging
import sys
from types import ModuleType

# pylint: disable=unused-import
from typing import Optional, Set, TYPE_CHECKING, Callable, Any, TypeVar # NOQA
from typing import Optional, Set, TYPE_CHECKING, Callable, Any, TypeVar # noqa pylint: disable=unused-import

from homeassistant.const import PLATFORM_FORMAT
from homeassistant.util import OrderedSet
Expand Down
1 change: 0 additions & 1 deletion homeassistant/scripts/__init__.py
Expand Up @@ -5,7 +5,6 @@
import logging
import os
import sys

from typing import List

from homeassistant.bootstrap import async_mount_local_lib_path
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/scripts/check_config.py
Expand Up @@ -6,10 +6,10 @@
from collections import OrderedDict, namedtuple
from glob import glob
from platform import system
from typing import Dict, List, Sequence
from unittest.mock import patch

import attr
from typing import Dict, List, Sequence
import voluptuous as vol

from homeassistant import bootstrap, core, loader
Expand Down
1 change: 0 additions & 1 deletion homeassistant/scripts/influxdb_import.py
Expand Up @@ -3,7 +3,6 @@
import json
import os
import sys

from typing import List

import homeassistant.config as config_util
Expand Down
1 change: 0 additions & 1 deletion homeassistant/scripts/influxdb_migrator.py
Expand Up @@ -2,7 +2,6 @@

import argparse
import sys

from typing import List


Expand Down
1 change: 0 additions & 1 deletion homeassistant/util/__init__.py
Expand Up @@ -11,7 +11,6 @@
from functools import wraps
from types import MappingProxyType
from unicodedata import normalize

from typing import (Any, Optional, TypeVar, Callable, KeysView, Union, # noqa
Iterable, List, Dict, Iterator, Coroutine, MutableSet)

Expand Down
4 changes: 1 addition & 3 deletions homeassistant/util/dt.py
@@ -1,9 +1,7 @@
"""Helper methods to handle the time in Home Assistant."""
import datetime as dt
import re

# pylint: disable=unused-import
from typing import Any, Dict, Union, Optional, Tuple # NOQA
from typing import Any, Dict, Union, Optional, Tuple # noqa pylint: disable=unused-import

import pytz
import pytz.exceptions as pytzexceptions
Expand Down
1 change: 0 additions & 1 deletion homeassistant/util/package.py
Expand Up @@ -4,7 +4,6 @@
import os
from subprocess import PIPE, Popen
import sys

from typing import Optional

_LOGGER = logging.getLogger(__name__)
Expand Down
2 changes: 0 additions & 2 deletions setup.cfg
Expand Up @@ -32,6 +32,4 @@ indent = " "
not_skip = __init__.py
# will group `import x` and `from x import` of the same module.
force_sort_within_sections = true
# typing is stdlib on py35 but 3rd party on py34, let it hang in between
known_inbetweens = typing
sections = FUTURE,STDLIB,INBETWEENS,THIRDPARTY,FIRSTPARTY,LOCALFOLDER

0 comments on commit ee69664

Please sign in to comment.