From fe2b0859b0d2774c8f3d7218dab62a5035042d0d Mon Sep 17 00:00:00 2001 From: Alec Delaney <89490472+tekktrik@users.noreply.github.com> Date: Wed, 30 Nov 2022 22:54:40 -0500 Subject: [PATCH 1/2] Update pylint to v2.15.5 --- .pre-commit-config.yaml | 2 +- .pylintrc | 43 +++-------------------------------------- 2 files changed, 4 insertions(+), 41 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3343606..0e5fccc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,7 +18,7 @@ repos: - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/pycqa/pylint - rev: v2.11.1 + rev: v2.15.5 hooks: - id: pylint name: pylint (library code) diff --git a/.pylintrc b/.pylintrc index d4efa3e..40208c3 100644 --- a/.pylintrc +++ b/.pylintrc @@ -26,7 +26,7 @@ jobs=1 # List of plugins (as comma separated values of python modules names) to load, # usually to register additional checkers. -load-plugins= +load-plugins=pylint.extensions.no_self_use # Pickle collected data for later comparisons. persistent=yes @@ -54,8 +54,8 @@ confidence= # --enable=similarities". If you want to run only the classes checker, but have # no Warning level messages displayed, use"--disable=all --enable=classes # --disable=W" -# disable=import-error,print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call -disable=print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call,import-error,bad-continuation,pointless-string-statement,unused-argument,no-self-use +# disable=import-error,raw-checker-failed,bad-inline-option,locally-disabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,deprecated-str-translate-call +disable=raw-checker-failed,bad-inline-option,locally-disabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,import-error,pointless-string-statement,unspecified-encoding # Enable the message, report, category or checker with the given id(s). You can # either give multiple identifier separated by comma (,) or put this option @@ -225,12 +225,6 @@ max-line-length=100 # Maximum number of lines in a module max-module-lines=1000 -# List of optional constructs for which whitespace checking is disabled. `dict- -# separator` is used to allow tabulation in dicts, etc.: {1 : 1,\n222: 2}. -# `trailing-comma` allows a space between comma and closing bracket: (a, ). -# `empty-line` allows space-only lines. -no-space-check=trailing-comma,dict-separator - # Allow the body of a class to be on the same line as the declaration if body # contains single statement. single-line-class-stmt=no @@ -257,38 +251,22 @@ min-similarity-lines=12 [BASIC] -# Naming hint for argument names -argument-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - # Regular expression matching correct argument names argument-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ -# Naming hint for attribute names -attr-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - # Regular expression matching correct attribute names attr-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ # Bad variable names which should always be refused, separated by a comma bad-names=foo,bar,baz,toto,tutu,tata -# Naming hint for class attribute names -class-attribute-name-hint=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ - # Regular expression matching correct class attribute names class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ -# Naming hint for class names -# class-name-hint=[A-Z_][a-zA-Z0-9]+$ -class-name-hint=[A-Z_][a-zA-Z0-9_]+$ - # Regular expression matching correct class names # class-rgx=[A-Z_][a-zA-Z0-9]+$ class-rgx=[A-Z_][a-zA-Z0-9_]+$ -# Naming hint for constant names -const-name-hint=(([A-Z_][A-Z0-9_]*)|(__.*__))$ - # Regular expression matching correct constant names const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$ @@ -296,9 +274,6 @@ const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$ # ones are exempt. docstring-min-length=-1 -# Naming hint for function names -function-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - # Regular expression matching correct function names function-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ @@ -309,21 +284,12 @@ good-names=r,g,b,w,i,j,k,n,x,y,z,ex,ok,Run,_ # Include a hint for the correct naming format with invalid-name include-naming-hint=no -# Naming hint for inline iteration names -inlinevar-name-hint=[A-Za-z_][A-Za-z0-9_]*$ - # Regular expression matching correct inline iteration names inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ -# Naming hint for method names -method-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - # Regular expression matching correct method names method-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ -# Naming hint for module names -module-name-hint=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ - # Regular expression matching correct module names module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ @@ -339,9 +305,6 @@ no-docstring-rgx=^_ # to this list to register other decorators that produce valid properties. property-classes=abc.abstractproperty -# Naming hint for variable names -variable-name-hint=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ - # Regular expression matching correct variable names variable-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$ From f315b1d0bff3b3c1adf445e6be31f3a8b0fe0c74 Mon Sep 17 00:00:00 2001 From: Alec Delaney <89490472+tekktrik@users.noreply.github.com> Date: Wed, 30 Nov 2022 23:06:21 -0500 Subject: [PATCH 2/2] Fix pylint errors --- circuitpython_typing/__init__.py | 2 -- circuitpython_typing/http.py | 5 ----- circuitpython_typing/io.py | 1 + circuitpython_typing/led.py | 2 -- circuitpython_typing/pil.py | 4 ---- circuitpython_typing/pwmio.py | 2 +- circuitpython_typing/socket.py | 11 ----------- 7 files changed, 2 insertions(+), 25 deletions(-) diff --git a/circuitpython_typing/__init__.py b/circuitpython_typing/__init__.py index ffa0a5a..5a56cec 100644 --- a/circuitpython_typing/__init__.py +++ b/circuitpython_typing/__init__.py @@ -66,12 +66,10 @@ def read(self, count: Optional[int] = None) -> Optional[bytes]: or if the parameter is not specified in the call, the outcome is implementation-dependent. """ - ... # Should be `, /)`, but not available in Python 3.7. def write(self, buf: ReadableBuffer) -> Optional[int]: """Write the bytes in ``buf`` to the stream.""" - ... # These types may not be in adafruit-blinka, so use the string form instead of a resolved name. diff --git a/circuitpython_typing/http.py b/circuitpython_typing/http.py index 03cfdf9..3b83fcb 100644 --- a/circuitpython_typing/http.py +++ b/circuitpython_typing/http.py @@ -21,20 +21,15 @@ class HTTPProtocol(Protocol): def get(self, url: str, **kw) -> Response: """Send HTTP GET request""" - ... def put(self, url: str, **kw) -> Response: """Send HTTP PUT request""" - ... def post(self, url: str, **kw) -> Response: """Send HTTP POST request""" - ... def patch(self, url: str, **kw) -> Response: """Send HTTP PATCH request""" - ... def delete(self, url: str, **kw) -> Response: """Send HTTP DELETE request""" - ... diff --git a/circuitpython_typing/io.py b/circuitpython_typing/io.py index b09ba45..20cd5c5 100644 --- a/circuitpython_typing/io.py +++ b/circuitpython_typing/io.py @@ -38,6 +38,7 @@ def value(self) -> float: on the specifics of the class. """ + # pylint: disable=no-self-use,unused-argument @value.setter def value(self, input_value: float, /): ... diff --git a/circuitpython_typing/led.py b/circuitpython_typing/led.py index 9dcbcad..200a5e0 100644 --- a/circuitpython_typing/led.py +++ b/circuitpython_typing/led.py @@ -24,7 +24,6 @@ class ColorBasedLED(Protocol): def color(self, value: ColorBasedColorUnion) -> None: """Sets the color of the LED""" - ... class FillBasedLED(Protocol): @@ -32,4 +31,3 @@ class FillBasedLED(Protocol): def fill(self, color: FillBasedColorUnion) -> None: """Sets the color of the LED""" - ... diff --git a/circuitpython_typing/pil.py b/circuitpython_typing/pil.py index eea6880..7a70aea 100644 --- a/circuitpython_typing/pil.py +++ b/circuitpython_typing/pil.py @@ -21,7 +21,6 @@ class PixelAccess(Protocol): # pylint: disable=invalid-name def __getitem__(self, xy: Tuple[int, int]) -> int: """Get pixels by x, y coordinate""" - ... class Image(Protocol): @@ -30,13 +29,10 @@ class Image(Protocol): @property def mode(self) -> str: """The mode of the image""" - ... @property def size(self) -> Tuple[int, int]: """The size of the image""" - ... def load(self) -> PixelAccess: """Load the image for quick pixel access""" - ... diff --git a/circuitpython_typing/pwmio.py b/circuitpython_typing/pwmio.py index be676d3..e918872 100644 --- a/circuitpython_typing/pwmio.py +++ b/circuitpython_typing/pwmio.py @@ -21,8 +21,8 @@ class PWMOut(Protocol): @property def duty_cycle(self) -> int: """The duty cycle as a ratio using 16-bits""" - ... + # pylint: disable=no-self-use,unused-argument @duty_cycle.setter def duty_cycle(self, duty_cycle: int) -> None: ... diff --git a/circuitpython_typing/socket.py b/circuitpython_typing/socket.py index d5f8d73..7f5e73f 100644 --- a/circuitpython_typing/socket.py +++ b/circuitpython_typing/socket.py @@ -41,15 +41,12 @@ class CommonSocketType(Protocol): def send(self, data: bytes, flags: int = ...) -> None: """Send data to the socket. The meaning of the optional flags kwarg is implementation-specific.""" - ... def settimeout(self, value: Optional[float]) -> None: """Set a timeout on blocking socket operations.""" - ... def close(self) -> None: """Close the socket.""" - ... class CommonCircuitPythonSocketType(CommonSocketType, Protocol): @@ -62,7 +59,6 @@ def connect( ) -> None: """Connect to a remote socket at the provided (host, port) address. The conntype kwarg optionally may indicate SSL or not, depending on the underlying interface.""" - ... class LegacyCircuitPythonSocketType(CommonCircuitPythonSocketType, Protocol): @@ -72,7 +68,6 @@ def recv(self, bufsize: int = ...) -> bytes: """Receive data from the socket. The return value is a bytes object representing the data received. The maximum amount of data to be received at once is specified by bufsize.""" - ... class SupportsRecvWithFlags(Protocol): @@ -82,7 +77,6 @@ def recv(self, bufsize: int = ..., flags: int = ...) -> bytes: """Receive data from the socket. The return value is a bytes object representing the data received. The maximum amount of data to be received at once is specified by bufsize. The meaning of the optional flags kwarg is implementation-specific.""" - ... class SupportsRecvInto(Protocol): @@ -93,7 +87,6 @@ def recv_into(self, buffer: bytearray, nbytes: int = ..., flags: int = ...) -> i buffer. If nbytes is not specified (or 0), receive up to the size available in the given buffer. The meaning of the optional flags kwarg is implementation-specific. Returns the number of bytes received.""" - ... class CircuitPythonSocketType( @@ -104,8 +97,6 @@ class CircuitPythonSocketType( ): # pylint: disable=too-many-ancestors """Describes the structure every modern CircuitPython socket type must have.""" - ... - class StandardPythonSocketType( CommonSocketType, SupportsRecvInto, SupportsRecvWithFlags, Protocol @@ -114,7 +105,6 @@ class StandardPythonSocketType( def connect(self, address: Union[Tuple[Any, ...], str, bytes]) -> None: """Connect to a remote socket at the provided address.""" - ... SocketType: TypeAlias = Union[ @@ -132,7 +122,6 @@ class InterfaceType(Protocol): @property def TLS_MODE(self) -> int: # pylint: disable=invalid-name """Constant representing that a socket's connection mode is TLS.""" - ... SSLContextType: TypeAlias = Union[SSLContext, "_FakeSSLContext"]