Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run linters on stubs #441

Merged
merged 3 commits into from
Oct 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ jobs:
with:
python-version: '3.6'
- run: python -m pip install -e .[dev]
- run: black --check --diff sydent/ tests/ matrix_is_test/ scripts/ setup.py
- run: flake8 sydent/ tests/ matrix_is_test/ scripts/ setup.py
- run: isort --check-only --diff sydent/ tests/ matrix_is_test/ scripts/ setup.py
- run: black --check --diff sydent/ stubs/ tests/ matrix_is_test/ scripts/ setup.py
- run: flake8 sydent/ stubs/ tests/ matrix_is_test/ scripts/ setup.py
- run: isort --check-only --diff sydent/ stubs/ tests/ matrix_is_test/ scripts/ setup.py

run-unit-tests:
needs: [check-code-style]
Expand Down
1 change: 1 addition & 0 deletions changelog.d/441.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Run linters over stub files.
6 changes: 3 additions & 3 deletions scripts-dev/lint.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#! /usr/bin/env bash
set -ex

black sydent/ tests/ matrix_is_test/ scripts/ setup.py
flake8 sydent/ tests/ matrix_is_test/ scripts/ setup.py
isort sydent/ tests/ matrix_is_test/ scripts/ setup.py
black sydent/ stubs/ tests/ matrix_is_test/ scripts/ setup.py
flake8 sydent/ stubs/ tests/ matrix_is_test/ scripts/ setup.py
isort sydent/ stubs/ tests/ matrix_is_test/ scripts/ setup.py
mypy
5 changes: 2 additions & 3 deletions stubs/twisted/internet/error.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from typing import Optional, Any

from typing import Any, Optional

class ConnectError(Exception):
def __init__(self, osError: Optional[Any] = None, string: str = ""): ...
def __init__(self, osError: Optional[Any] = None, string: str = ""): ...
4 changes: 1 addition & 3 deletions stubs/twisted/internet/ssl.pyi
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from typing import Optional, Any, List, Dict, AnyStr, TypeVar, Type
from typing import Any, AnyStr, Dict, List, Optional, Type, TypeVar

import OpenSSL.SSL

# I don't like importing from _sslverify, but IOpenSSLTrustRoot isn't re-exported
# anywhere else in twisted.
from twisted.internet._sslverify import IOpenSSLTrustRoot
from twisted.internet.interfaces import IOpenSSLClientConnectionCreator

from zope.interface import implementer

C = TypeVar("C")
Expand Down Expand Up @@ -37,7 +36,6 @@ def optionsForClientTLS(
extraCertificateOptions: Optional[Dict[Any, Any]] = None,
) -> IOpenSSLClientConnectionCreator: ...


# Type safety: I don't want to respecify the methods on the interface that we
# don't use.
@implementer(IOpenSSLTrustRoot) # type: ignore[misc]
Expand Down
7 changes: 2 additions & 5 deletions stubs/twisted/names/dns.pyi
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
from typing import ClassVar, Generic, TypeVar, Optional

from typing import ClassVar, Generic, Optional, TypeVar

class Name:
name: bytes

def __init__(self, name: bytes = b""): ...

SRV: int


class Record_SRV:
priority: int
weight: int
port: int
target: Name
ttl: int


Payload = TypeVar("Payload") # should be bound to IEncodableRecord

class RRHeader(Generic[Payload]):
fmt: ClassVar[str]
name: Name
Expand Down
12 changes: 5 additions & 7 deletions stubs/twisted/python/failure.pyi
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
from types import TracebackType
from typing import Type, Optional, Union, TypeVar, overload
from typing import Optional, Type, TypeVar, Union, overload

E = TypeVar("E")


class Failure(BaseException):

def __init__(
self,
exc_value: Optional[BaseException] = None,
exc_type: Optional[Type[BaseException]] = None,
exc_tb: Optional[TracebackType] = None,
captureVars: bool = False,
):
...

): ...
@overload
def check(self, singleErrorType: Type[E]) -> Optional[E]: ...
@overload
def check(self, *errorTypes: Union[str, Type[Exception]]) -> Optional[Exception]: ...
def check(
self, *errorTypes: Union[str, Type[Exception]]
) -> Optional[Exception]: ...
6 changes: 2 additions & 4 deletions stubs/twisted/python/log.pyi
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
from typing import Optional, Union, Any
from typing import Any, Optional, Union

from twisted.python.failure import Failure


def err(
_stuff: Union[None, Exception, Failure] = None,
_why: Optional[str] = None,
**kw: Any,
)-> None:
...
) -> None: ...
7 changes: 3 additions & 4 deletions stubs/twisted/web/client.pyi
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
from typing import BinaryIO, Any, Optional
from typing import Any, BinaryIO, Optional

import twisted.internet
from twisted.internet.defer import Deferred
from twisted.internet.interfaces import (
IOpenSSLClientConnectionCreator,
IConsumer,
IOpenSSLClientConnectionCreator,
IProtocol,
)
from twisted.internet.task import Cooperator
from twisted.web.http_headers import Headers

from twisted.web.iweb import IResponse, IAgent, IBodyProducer, IPolicyForHTTPS
from twisted.web.iweb import IAgent, IBodyProducer, IPolicyForHTTPS, IResponse
from zope.interface import implementer

@implementer(IPolicyForHTTPS)
Expand Down
7 changes: 2 additions & 5 deletions stubs/twisted/web/http.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import typing
from typing import AnyStr, Optional, Dict, List
from typing import AnyStr, Dict, List, Optional

from twisted.internet.defer import Deferred
from twisted.internet.interfaces import ITCPTransport, IAddress
from twisted.internet.interfaces import IAddress, ITCPTransport
from twisted.logger import Logger
from twisted.web.http_headers import Headers

Expand Down Expand Up @@ -39,10 +39,7 @@ class Request:
# - we use `self.transport.abortConnection`, which belongs to that interface
# - twisted does too! in its implementation of HTTPChannel.forceAbortClient
transport: Optional[ITCPTransport]


def getHeader(self, key: AnyStr) -> Optional[AnyStr]: ...

def handleContentChunk(self, data: bytes) -> None: ...

class PotentialDataLoss(Exception): ...