Skip to content
2 changes: 0 additions & 2 deletions LabGym/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# suppress '__init__.py:1:0: C0103: Module name "LabGym" doesn't conform to snake_case naming style (invalid-name)'
# pylint: disable=invalid-name
'''
Copyright (C)
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
Expand Down
11 changes: 4 additions & 7 deletions LabGym/__main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# pylint: disable=line-too-long
'''
Copyright (C)
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
Expand All @@ -19,19 +18,18 @@


# noqa
# pylint: enable=line-too-long

# Standard library imports.
import logging
from pathlib import Path

# block begin
# Regarding the use of logging and mylogging functions before the
# "Related third party imports." section:
# These statements are intentionally positioned before this module's
# other imports (against the guidance of PEP 8), to log the loading of
# this module before other import statements are executed and
# potentially produce their own log messages.
# pylint: disable=wrong-import-position
from LabGym import mylogging # pylint: disable=ungrouped-imports
from LabGym import mylogging
# Collect logrecords and defer handling until logging is configured.
mylogging.defer()

Expand All @@ -43,8 +41,6 @@

# Configure logging based on configfile, then handle collected logrecords.
mylogging.configure()
# pylint: enable=wrong-import-position
# block end

# Related third party imports.
from packaging import version # Core utilities for Python packages
Expand All @@ -53,6 +49,7 @@
import wx # wxPython, Cross platform GUI toolkit for Python, "Phoenix" version

# Local application/library specific imports.
# pylint: disable=ungrouped-imports
# pylint: disable-next=unused-import
from LabGym import mypkg_resources # replace deprecated pkg_resources
from LabGym import __version__, gui_main, probes
Expand Down
4 changes: 2 additions & 2 deletions LabGym/analyzebehavior.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
# Log the load of this module (by the module loader, on first import).
# Intentionally positioning these statements before other imports, against the
# guidance of PEP-8, to log the load before other imports log messages.
logger = logging.getLogger(__name__) # pylint: disable=wrong-import-position
logger.debug('loading %s', __file__) # pylint: disable=wrong-import-position
logger = logging.getLogger(__name__)
logger.debug('loading %s', __file__)

# Related third party imports.
import cv2
Expand Down
4 changes: 2 additions & 2 deletions LabGym/gui_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
# Log the load of this module (by the module loader, on first import).
# Intentionally positioning these statements before other imports, against the
# guidance of PEP-8, to log the load before other imports log messages.
logger = logging.getLogger(__name__) # pylint: disable=wrong-import-position
logger.debug('loading %s', __file__) # pylint: disable=wrong-import-position
logger = logging.getLogger(__name__)
logger.debug('loading %s', __file__)

# Related third party imports.
import matplotlib as mpl
Expand Down
6 changes: 3 additions & 3 deletions LabGym/gui_categorizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
import json
import logging
import os
from pathlib import Path
# from pathlib import Path
import shutil

# Log the load of this module (by the module loader, on first import).
# Intentionally positioning these statements before other imports, against the
# guidance of PEP-8, to log the load before other imports log messages.
logger = logging.getLogger(__name__) # pylint: disable=wrong-import-position
logger.debug('loading %s', __file__) # pylint: disable=wrong-import-position
logger = logging.getLogger(__name__)
logger.debug('loading %s', __file__)

# Related third party imports.
import cv2
Expand Down
6 changes: 3 additions & 3 deletions LabGym/gui_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
import json
import logging
import os
from pathlib import Path
# from pathlib import Path
import shutil

# Log the load of this module (by the module loader, on first import).
# Intentionally positioning these statements before other imports, against the
# guidance of PEP-8, to log the load before other imports log messages.
logger = logging.getLogger(__name__) # pylint: disable=wrong-import-position
logger.debug('loading %s', __file__) # pylint: disable=wrong-import-position
logger = logging.getLogger(__name__)
logger.debug('loading %s', __file__)

# Related third party imports.
import wx
Expand Down
4 changes: 2 additions & 2 deletions LabGym/gui_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
# Log the load of this module (by the module loader, on first import).
# Intentionally positioning these statements before other imports, against the
# guidance of PEP-8, to log the load before other imports log messages.
logger = logging.getLogger(__name__) # pylint: disable=wrong-import-position
logger.debug('loading %s', __file__) # pylint: disable=wrong-import-position
logger = logging.getLogger(__name__)
logger.debug('loading %s', __file__)

# Related third party imports.
import wx
Expand Down
4 changes: 2 additions & 2 deletions LabGym/gui_preprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
# Log the load of this module (by the module loader, on first import).
# Intentionally positioning these statements before other imports, against the
# guidance of PEP-8, to log the load before other imports log messages.
logger = logging.getLogger(__name__) # pylint: disable=wrong-import-position
logger.debug('loading %s', __file__) # pylint: disable=wrong-import-position
logger = logging.getLogger(__name__)
logger.debug('loading %s', __file__)

# Related third party imports.
import cv2
Expand Down
4 changes: 3 additions & 1 deletion LabGym/myargparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
import os
import sys
import textwrap
from typing import List, Union, Dict, Any
# from typing import Any, Dict, List, Union
from typing import Dict, List, Union


# Related third party imports.
# (none)
Expand Down
2 changes: 0 additions & 2 deletions LabGym/mylogging.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# pylint: disable=line-too-long
"""Provide functions for configuring the logging system.

Functions
Expand Down Expand Up @@ -97,7 +96,6 @@

logger.debug'%s: %r', '(__name__, __package__', (__name__, __package__))
""" # noqa: E501
# pylint: enable=line-too-long

# Allow use of newer syntax Python 3.10 type hints in Python 3.9.
from __future__ import annotations
Expand Down
2 changes: 2 additions & 0 deletions LabGym/mywx/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ def add_buttons(self, panel, button_sizer):
self.Bind(wx.EVT_BUTTON, self.on_ok, id=wx.ID_OK)

def on_ok(self, event):
"""End the modal state of this dialog object."""
self.EndModal(wx.ID_OK)


Expand All @@ -136,4 +137,5 @@ def add_buttons(self, panel, button_sizer):
self.Bind(wx.EVT_BUTTON, self.on_cancel, id=wx.ID_CANCEL)

def on_cancel(self, event):
"""End the modal state of this dialog object."""
self.EndModal(wx.ID_CANCEL)
2 changes: 0 additions & 2 deletions LabGym/probes.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@
# other imports (against the guidance of PEP 8), to log the load of this
# module before other import statements are executed and potentially
# produce their own log messages.
# pylint: disable=wrong-import-position
logger = logging.getLogger(__name__)
logger.debug('%s', f'loading {__file__}')
logger.debug('%s: %r', '(__name__, __package__)', (__name__, __package__))
# pylint: enable=wrong-import-position

# Related third party imports.
import certifi # Python package for providing Mozilla's CA Bundle.
Expand Down
2 changes: 2 additions & 0 deletions LabGym/tests/INIT.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ ERROR () { printf "ERROR\t%s\n" "$(printf "$@")" >& 2; }
DEBUG () { printf "DEBUG\t%s\n" "$(printf "$@")" >& 2; }

IS_VENV () { [ -n "$VIRTUAL_ENV+1" ]; } # works in sh, bash, and zsh

AWK () { awk "$@"; }

PYFILES=$(cd .. && echo *.py)
# printf "%s: %s\n" "\$PYFILES" "$PYFILES"
Expand Down
70 changes: 48 additions & 22 deletions LabGym/tests/pylint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# Examples
# # Run pylint with custom options on ../*.py.
# sh pylint.sh
#
# # Run pylint with custom options on two files.
# sh pylint.sh ../categorizer.py ../detector.py
#
# # Don't run pylint... just summarize existing results in tmp.pylint.
# sh pylint.sh --summarize

source INIT.sh

PYFILES=$(echo ../*.py)
PYFILES=$(echo ../*.py ../mywx/*.py)

OP=pylint # default OP
while [ $# -gt 0 ]; do
Expand All @@ -13,7 +23,7 @@ while [ $# -gt 0 ]; do
done

case $OP in
pylint)
pylint)
#-----------------------------------------------------------------------
if [ $# -gt 0 ]; then
PYFILES=$*
Expand All @@ -25,32 +35,48 @@ IS_VENV || { ERROR "Expected a venv..."; exit 1; }

OUTDIR=tmp.pylint

OPTS="--rcfile pylintrc"

# # Disable invalid-name.
# OPTS="$OPTS${OPTS:+ }--disable=invalid-name"
# --disable=invalid-name is now represented in pylintrc, so removed here.

setopt SH_WORD_SPLIT 2> /dev/null
(
for F in $PYFILES; do
OUTFILE=$OUTDIR/pylint.$(echo $F | tr / . | sed "s/^\.\.\.//").out
OPTS="--rcfile pylintrc"

# C0301: Line too long (232/100) (line-too-long)
# W0311: Bad indentation. Found 2 spaces, expected 8 (bad-indentation)
OPTS="$OPTS${OPTS:+ }--disable=C0301,W0311"

(set -x; pylint $OPTS $F > $OUTFILE)
grep -n "^Your code has been rated " $OUTFILE
done
)

for F in $PYFILES; do
OUTFILE=$OUTDIR/pylint.$(echo $F | tr / . | sed "s/^\.\.\.//").out

# (set -x; pylint $OPTS $F > $OUTFILE)
printf "%s\n" "+ pylint $OPTS $F > $OUTFILE"
pylint $OPTS $F > $OUTFILE

grep -n "^Your code has been rated " $OUTFILE
done
#-----------------------------------------------------------------------
;;
;;

summarize)
summarize)
# Don't run pylint... just summarize existing results in tmp.pylint.
#-----------------------------------------------------------------------
(cd tmp.pylint && grep -n "Your code has been rated at" *.out) |
sed "s/ (previous.*//" |
sed "s/^pylint\.\(.*.py\).out:\([0-9]*\):Your code has been rated at \(.*\)/\3\t\2\t\1/" |
[ $# -eq 0 ] || { ERROR "Bad usage. \$#: $#"; exit 1; }

(cd tmp.pylint && grep -n "Your code has been rated at" *.out) |

sed \
-e "s/^pylint\.//" \
-e "s/ (previous run: .*//" \
-e "s/\(.*.py\).out:\([0-9]*\):/\1\t\2\t/" \
-e "s/Your code has been rated at //" |

# print rating, number of messages (assuming N-3), filename
AWK -F"\t" 'BEGIN {OFS = "\t"}; {print $3, $2-3, $1}' |

expand -10,16 |
cat -n
#-----------------------------------------------------------------------
;;
;;

*) { ERROR "Impossible. \$OP: $OP"; exit 1; };;
esac

exit $?
Expand Down Expand Up @@ -98,7 +124,7 @@ Main:
specific errors.
--verbose , -v In verbose mode, extra non-checker-related info will
be displayed.
--enable-all-extensions
--enable-all-extensions
Load and enable all available extensions. Use --list-
extensions to see a list all available extensions.
--ignore <file>[,<file>...]
Expand Down
Loading