Skip to content

Commit

Permalink
Merge pull request #2300 from half-duplex/type-checking-blocks
Browse files Browse the repository at this point in the history
implement flake8-type-checking
  • Loading branch information
dgw committed Jul 17, 2022
2 parents 03d2721 + df815a2 commit 55c78a4
Show file tree
Hide file tree
Showing 10 changed files with 122 additions and 70 deletions.
1 change: 1 addition & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ flake8
flake8-coding
flake8-future-import
flake8-import-order
flake8-type-checking; python_version >= '3.8'
furo==2022.4.7 # Sphinx theme
pytest~=6.2.5
pytest-vcr~=1.0.2
Expand Down
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ pytest11 =
[flake8]
max-line-length = 79
application-import-names = sopel
type-checking-exempt-modules = typing
import-order-style = google
ignore =
# Line length limit. Acceptable (for now).
Expand All @@ -53,6 +54,8 @@ ignore =
# These would require future imports that are not needed any more on Sopel's
# oldest supported Python version (3.7).
FI10,FI11,FI12,FI13,FI14,FI15,FI16,FI17,
# We use postponed annotation evaluation
TC2,
exclude =
docs/*,
env/*,
Expand Down
16 changes: 14 additions & 2 deletions sopel/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,26 @@
import threading
import time
from types import MappingProxyType
from typing import Any, Dict, Iterable, Mapping, Optional, Tuple, Union
from typing import (
Any,
Dict,
Iterable,
Mapping,
Optional,
Tuple,
TYPE_CHECKING,
Union,
)

from sopel import db, irc, logger, plugin, plugins, tools
from sopel.irc import modes
from sopel.lifecycle import deprecated
from sopel.plugins import jobs as plugin_jobs, rules as plugin_rules
from sopel.tools import jobs as tools_jobs
from sopel.trigger import PreTrigger, Trigger
from sopel.trigger import Trigger

if TYPE_CHECKING:
from sopel.trigger import PreTrigger


__all__ = ['Sopel', 'SopelWrapper']
Expand Down
18 changes: 14 additions & 4 deletions sopel/irc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,28 @@
import os
import threading
import time
from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Tuple, TYPE_CHECKING
from typing import (
Any,
Callable,
Dict,
Iterable,
List,
Optional,
Set,
Tuple,
TYPE_CHECKING,
)

from sopel import tools, trigger
from sopel.tools import identifiers
from .abstract_backends import AbstractIRCBackend
from .backends import AsyncioBackend
from .isupport import ISupport
from .utils import CapReq, MyInfo, safe

from .utils import CapReq, safe

if TYPE_CHECKING:
from sopel.config import Config
from .abstract_backends import AbstractIRCBackend
from .utils import MyInfo


__all__ = ['abstract_backends', 'backends', 'utils']
Expand Down
11 changes: 10 additions & 1 deletion sopel/irc/modes.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,16 @@

import enum
import logging
from typing import Dict, Iterator, List, NamedTuple, Optional, Set, Tuple
from typing import (
Dict,
Iterator,
List,
NamedTuple,
Optional,
Set,
Tuple,
)


ModeTuple = Tuple[str, bool]
"""Tuple of mode information: ``(mode, is_added)``.
Expand Down
5 changes: 2 additions & 3 deletions sopel/modules/url.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from ipaddress import ip_address
import logging
import re
from typing import TYPE_CHECKING
from typing import Generator, List, Optional, Tuple, TYPE_CHECKING
from urllib.parse import urlparse

import dns.resolver
Expand All @@ -25,12 +25,11 @@
from sopel.tools import web

if TYPE_CHECKING:
from typing import Generator, List, Optional, Tuple

from sopel.bot import Sopel, SopelWrapper
from sopel.config import Config
from sopel.trigger import Trigger


LOGGER = logging.getLogger(__name__)
USER_AGENT = (
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) '
Expand Down
Loading

0 comments on commit 55c78a4

Please sign in to comment.