Skip to content

Commit

Permalink
pylint: create a global configuration file
Browse files Browse the repository at this point in the history
Move all too-few / too-many arbitrary warnings into this config file.

Signed-off-by: Emmanuel Blot <emmanuel.blot@free.fr>
  • Loading branch information
eblot committed Apr 5, 2024
1 parent 9834c46 commit 5ca35f4
Show file tree
Hide file tree
Showing 37 changed files with 134 additions and 176 deletions.
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[flake8]
max-line-length = 80
12 changes: 12 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[MESSAGES CONTROL]

disable=
too-few-public-methods,
too-many-arguments,
too-many-branches,
too-many-instance-attributes,
too-many-lines,
too-many-locals,
too-many-nested-blocks,
too-many-public-methods,
too-many-statements
2 changes: 1 addition & 1 deletion pyftdi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# SPDX-License-Identifier: BSD-3-Clause

#pylint: disable-msg=missing-docstring
# pylint: disable=missing-docstring

__version__ = '0.55.1'
__title__ = 'PyFtdi'
Expand Down
8 changes: 4 additions & 4 deletions pyftdi/bin/ftconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
from pyftdi.ftdi import Ftdi
from pyftdi.misc import add_custom_devices, hexdump

#pylint: disable-msg=too-many-locals
#pylint: disable-msg=too-many-branches
#pylint: disable-msg=too-many-statements
# pylint: disable=too-many-locals
# pylint: disable=too-many-branches
# pylint: disable=too-many-statements


def main():
Expand Down Expand Up @@ -107,7 +107,7 @@ def main():
FtdiLogger.log.addHandler(StreamHandler(stderr))

if args.virtual:
#pylint: disable-msg=import-outside-toplevel
# pylint: disable=import-outside-toplevel
from pyftdi.usbtools import UsbTools
# Force PyUSB to use PyFtdi test framework for USB backends
UsbTools.BACKENDS = ('pyftdi.tests.backend.usbvirt', )
Expand Down
2 changes: 1 addition & 1 deletion pyftdi/bin/ftdi_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def main():
FtdiLogger.log.addHandler(StreamHandler(stderr))

if args.virtual:
#pylint: disable-msg=import-outside-toplevel
# pylint: disable=import-outside-toplevel
from pyftdi.usbtools import UsbTools
# Force PyUSB to use PyFtdi test framework for USB backends
UsbTools.BACKENDS = ('pyftdi.tests.backend.usbvirt', )
Expand Down
7 changes: 3 additions & 4 deletions pyftdi/bin/i2cscan.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# Copyright (c) 2018-2022, Emmanuel Blot <emmanuel.blot@free.fr>
# Copyright (c) 2018-2024, Emmanuel Blot <emmanuel.blot@free.fr>
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause

"""Tiny I2C bus scanner."""

#pylint: disable-msg=broad-except
#pylint: disable-msg=too-few-public-methods
# pylint: disable=broad-except

from argparse import ArgumentParser, FileType
from logging import Formatter, StreamHandler, getLogger, DEBUG, ERROR
Expand Down Expand Up @@ -124,7 +123,7 @@ def main():
FtdiLogger.set_level(loglevel)

if args.virtual:
#pylint: disable-msg=import-outside-toplevel
# pylint: disable=import-outside-toplevel
from pyftdi.usbtools import UsbTools
# Force PyUSB to use PyFtdi test framework for USB backends
UsbTools.BACKENDS = ('pyftdi.tests.backend.usbvirt', )
Expand Down
16 changes: 5 additions & 11 deletions pyftdi/bin/pyterm.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,14 @@
"""Simple Python serial terminal
"""

# Copyright (c) 2010-2022, Emmanuel Blot <emmanuel.blot@free.fr>
# Copyright (c) 2010-2024, Emmanuel Blot <emmanuel.blot@free.fr>
# Copyright (c) 2016, Emmanuel Bouaziz <ebouaziz@free.fr>
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause

#pylint: disable-msg=too-many-instance-attributes
#pylint: disable-msg=too-many-arguments
#pylint: disable-msg=too-many-nested-blocks
#pylint: disable-msg=too-many-branches
#pylint: disable-msg=too-many-statements
#pylint: disable-msg=too-few-public-methods
#pylint: disable-msg=broad-except
#pylint: disable-msg=wrong-import-position
# pylint: disable=broad-except
# pylint: disable=wrong-import-position

from argparse import ArgumentParser, FileType
from atexit import register
Expand All @@ -30,8 +24,8 @@
from traceback import format_exc
from _thread import interrupt_main

#pylint: disable-msg=import-error
#pylint: disable-msg=import-outside-toplevel
# pylint: disable=import-error
# pylint: disable=import-outside-toplevel

from pyftdi import FtdiLogger
from pyftdi.ftdi import Ftdi
Expand Down
11 changes: 5 additions & 6 deletions pyftdi/bits.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2010-2019 Emmanuel Blot <emmanuel.blot@free.fr>
# Copyright (c) 2010-2024 Emmanuel Blot <emmanuel.blot@free.fr>
# Copyright (c) 2008-2016, Neotion
# All rights reserved.
#
Expand All @@ -9,11 +9,10 @@
from typing import Iterable, List, Optional, Tuple, Union
from .misc import is_iterable, xor

#pylint: disable-msg=invalid-name
#pylint: disable-msg=unneeded-not
#pylint: disable-msg=too-many-branches
#pylint: disable-msg=too-many-arguments
#pylint: disable-msg=duplicate-key
# pylint: disable=invalid-name
# pylint: disable=unneeded-not
# pylint: disable=duplicate-key


class BitSequenceError(Exception):
"""Bit sequence error"""
Expand Down
9 changes: 2 additions & 7 deletions pyftdi/eeprom.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,8 @@

"""EEPROM management for PyFdti"""

#pylint: disable-msg=too-many-arguments
#pylint: disable-msg=too-many-branches
#pylint: disable-msg=too-many-instance-attributes
#pylint: disable-msg=too-many-locals
#pylint: disable-msg=too-many-public-methods
#pylint: disable-msg=wrong-import-position
#pylint: disable-msg=import-error
# pylint: disable=wrong-import-position
# pylint: disable=import-error

import sys
from binascii import hexlify, unhexlify
Expand Down
22 changes: 6 additions & 16 deletions pyftdi/ftdi.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2010-2023 Emmanuel Blot <emmanuel.blot@free.fr>
# Copyright (c) 2010-2024 Emmanuel Blot <emmanuel.blot@free.fr>
# Copyright (c) 2016 Emmanuel Bouaziz <ebouaziz@free.fr>
# All rights reserved.
#
Expand All @@ -21,17 +21,7 @@
from .misc import to_bool
from .usbtools import UsbDeviceDescriptor, UsbTools

#pylint: disable-msg=invalid-name
#pylint: disable-msg=too-many-arguments
#pylint: disable=too-many-arguments
#pylint: disable=too-many-branches
#pylint: disable=too-many-statements
#pylint: disable=too-many-nested-blocks
#pylint: disable=too-many-instance-attributes
#pylint: disable=too-many-nested-blocks
#pylint: disable=too-many-public-methods
#pylint: disable=too-many-locals
#pylint: disable=too-many-lines
# pylint: disable=invalid-name


class FtdiError(IOError):
Expand Down Expand Up @@ -730,13 +720,13 @@ def open_mpsse_from_device(self, device: UsbDevice,
:param bool debug: add more debug traces
:return: actual bus frequency in Hz
"""
# pylint: disable-msg=unused-argument
# pylint: disable=unused-argument
self.open_from_device(device, interface)
if not self.is_mpsse_interface(interface):
self.close()
raise FtdiMpsseError('This interface does not support MPSSE')
if to_bool(tracer): # accept strings as boolean
#pylint: disable-msg=import-outside-toplevel
# pylint: disable=import-outside-toplevel
from .tracer import FtdiMpsseTracer
self._tracer = FtdiMpsseTracer(self.device_version)
self.log.debug('Using MPSSE tracer')
Expand Down Expand Up @@ -2044,7 +2034,7 @@ def _set_interface(self, config: UsbConfiguration, ifnum: int):
except (NotImplementedError, USBError):
pass

#pylint: disable-msg=protected-access
# pylint: disable=protected-access
# need to access private member _ctx of PyUSB device (resource manager)
# until PyUSB #302 is addressed

Expand All @@ -2057,7 +2047,7 @@ def _is_pyusb_handle_active(self) -> bool:
# and there is no public API for this.
return bool(self._usb_dev._ctx.handle)

#pylint: enable-msg=protected-access
# pylint: enable-msg=protected-access

def _reset_device(self):
"""Reset the FTDI device (FTDI vendor command)"""
Expand Down
3 changes: 1 addition & 2 deletions pyftdi/gpio.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# Copyright (c) 2014-2020, Emmanuel Blot <emmanuel.blot@free.fr>
# Copyright (c) 2014-2024, Emmanuel Blot <emmanuel.blot@free.fr>
# Copyright (c) 2016, Emmanuel Bouaziz <ebouaziz@free.fr>
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause

"""GPIO/BitBang support for PyFdti"""

#pylint: disable-msg=too-few-public-methods

from struct import calcsize as scalc, unpack as sunpack
from typing import Iterable, Optional, Tuple, Union
Expand Down
11 changes: 1 addition & 10 deletions pyftdi/i2c.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
# Copyright (c) 2017-2021, Emmanuel Blot <emmanuel.blot@free.fr>
# Copyright (c) 2017-2024, Emmanuel Blot <emmanuel.blot@free.fr>
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause

"""I2C support for PyFdti"""

#pylint: disable-msg=too-many-lines
#pylint: disable-msg=too-many-locals
#pylint: disable-msg=too-many-instance-attributes
#pylint: disable-msg=too-many-public-methods
#pylint: disable-msg=too-many-arguments
#pylint: disable-msg=too-many-branches
#pylint: disable-msg=too-many-statements


from binascii import hexlify
from collections import namedtuple
from logging import getLogger
Expand Down
4 changes: 2 additions & 2 deletions pyftdi/jtag.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

"""JTAG support for PyFdti"""

#pylint: disable-msg=invalid-name
#pylint: disable-msg=missing-function-docstring
# pylint: disable=invalid-name
# pylint: disable=missing-function-docstring

from time import sleep
from typing import List, Tuple, Union
Expand Down
12 changes: 5 additions & 7 deletions pyftdi/misc.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
# Copyright (c) 2010-2021 Emmanuel Blot <emmanuel.blot@free.fr>
# Copyright (c) 2010-2024 Emmanuel Blot <emmanuel.blot@free.fr>
# Copyright (c) 2008-2016, Neotion
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause

"""Miscellaneous helpers"""

#pylint: disable-msg=invalid-name
#pylint: disable-msg=import-outside-toplevel
#pylint: disable-msg=too-many-locals
#pylint: disable-msg=too-many-arguments
# pylint: disable=invalid-name
# pylint: disable=import-outside-toplevel

from array import array
from copy import deepcopy
Expand Down Expand Up @@ -198,7 +196,7 @@ def xor(_a_: bool, _b_: bool) -> bool:
:param _b_: second argument
:return: xor-ed value
"""
#pylint: disable-msg=superfluous-parens
# pylint: disable=superfluous-parens
return bool((not(_a_) and _b_) or (_a_ and not(_b_)))


Expand Down Expand Up @@ -311,7 +309,7 @@ def show_call_stack():

class classproperty(property):
"""Getter property decorator for a class"""
#pylint: disable=invalid-name
# pylint: disable=invalid-name
def __get__(self, obj: Any, objtype=None) -> Any:
return super().__get__(objtype)

Expand Down
12 changes: 6 additions & 6 deletions pyftdi/serialext/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
#
# SPDX-License-Identifier: BSD-3-Clause

#pylint: disable-msg=no-member
#pylint: disable-msg=broad-except
#pylint: disable-msg=invalid-name
#pylint: disable-msg=super-with-arguments
#pylint: disable-msg=missing-function-docstring
#pylint: disable-msg=missing-module-docstring
# pylint: disable=no-member
# pylint: disable=broad-except
# pylint: disable=invalid-name
# pylint: disable=super-with-arguments
# pylint: disable=missing-function-docstring
# pylint: disable=missing-module-docstring

from sys import stderr
from time import time
Expand Down
8 changes: 4 additions & 4 deletions pyftdi/serialext/protocol_ftdi.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
# SPDX-License-Identifier: BSD-3-Clause

# this file has not been updated for a while, so coding style needs some love
#pylint: disable-msg=attribute-defined-outside-init
#pylint: disable-msg=invalid-name
#pylint: disable-msg=missing-class-docstring
#pylint: disable-msg=missing-module-docstring
# pylint: disable=attribute-defined-outside-init
# pylint: disable=invalid-name
# pylint: disable=missing-class-docstring
# pylint: disable=missing-module-docstring

from io import RawIOBase
from time import sleep, time as now
Expand Down
21 changes: 10 additions & 11 deletions pyftdi/serialext/protocol_unix.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
# Copyright (c) 2008-2016, Emmanuel Blot <emmanuel.blot@free.fr>
# Copyright (c) 2008-2024, Emmanuel Blot <emmanuel.blot@free.fr>
# Copyright (c) 2016, Emmanuel Bouaziz <ebouaziz@free.fr>
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause

# this file has not been updated for a while, so coding style needs some love
#pylint: disable-msg=broad-except
#pylint: disable-msg=attribute-defined-outside-init
#pylint: disable-msg=redefined-outer-name
#pylint: disable-msg=invalid-name
#pylint: disable-msg=too-few-public-methods
#pylint: disable-msg=missing-function-docstring
#pylint: disable-msg=missing-class-docstring
#pylint: disable-msg=missing-module-docstring
# pylint: disable=broad-except
# pylint: disable=attribute-defined-outside-init
# pylint: disable=redefined-outer-name
# pylint: disable=invalid-name
# pylint: disable=missing-function-docstring
# pylint: disable=missing-class-docstring
# pylint: disable=missing-module-docstring

import errno
import os
Expand Down Expand Up @@ -70,7 +69,7 @@ def open(self):
self.close()
msg = "Could not open port: %s" % (str(e),)
if isinstance(e, socket.error):
# pylint: disable-msg=no-member
# pylint: disable=no-member
raise SerialExceptionWithErrno(msg, e.errno) from e
raise SerialException(msg) from e
self._set_open_state(True)
Expand All @@ -91,7 +90,7 @@ def close(self):

def in_waiting(self):
"""Return the number of characters currently in the input buffer."""
#pylint: disable-msg=no-self-use
# pylint: disable=no-self-use
return 0

def read(self, size=1):
Expand Down
2 changes: 1 addition & 1 deletion pyftdi/serialext/tests/rl.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

path.append(dirname(dirname(dirname(dirname(__file__)))))

#pylint: disable-msg=wrong-import-position
# pylint: disable=wrong-import-position
from pyftdi import serialext


Expand Down

0 comments on commit 5ca35f4

Please sign in to comment.