Ver código fonte

Run linters on stubs (#441)

David Robertson 2 anos atrás
pai
commit
4d24e1acae

+ 3 - 3
.github/workflows/pipeline.yml

@@ -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]

+ 1 - 0
changelog.d/441.misc

@@ -0,0 +1 @@
+Run linters over stub files.

+ 3 - 3
scripts-dev/lint.sh

@@ -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

+ 2 - 3
stubs/twisted/internet/error.pyi

@@ -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 = ""): ...

+ 1 - 3
stubs/twisted/internet/ssl.pyi

@@ -1,4 +1,4 @@
-from typing import Optional, Any, List, Dict, AnyStr, TypeVar, Type
+from typing import Any, AnyStr, Dict, List, Optional, Type, TypeVar
 
 import OpenSSL.SSL
 
@@ -6,7 +6,6 @@ import OpenSSL.SSL
 # anywhere else in twisted.
 from twisted.internet._sslverify import IOpenSSLTrustRoot
 from twisted.internet.interfaces import IOpenSSLClientConnectionCreator
-
 from zope.interface import implementer
 
 C = TypeVar("C")
@@ -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]

+ 2 - 5
stubs/twisted/names/dns.pyi

@@ -1,14 +1,11 @@
-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
@@ -16,8 +13,8 @@ class Record_SRV:
     target: Name
     ttl: int
 
-
 Payload = TypeVar("Payload")  # should be bound to IEncodableRecord
+
 class RRHeader(Generic[Payload]):
     fmt: ClassVar[str]
     name: Name

+ 5 - 7
stubs/twisted/python/failure.pyi

@@ -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]: ...

+ 2 - 4
stubs/twisted/python/log.pyi

@@ -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: ...

+ 3 - 4
stubs/twisted/web/client.pyi

@@ -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)

+ 2 - 5
stubs/twisted/web/http.pyi

@@ -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
 
@@ -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): ...