Add a basic pre-commit config

Also fix some things it cleaned up in default config.
This commit is contained in:
Dan Smith 2023-10-02 17:02:17 -07:00 committed by Dan Smith
parent ffd2e63e23
commit 68f6a46f5c
10 changed files with 64 additions and 46 deletions

23
.pre-commit-config.yaml Normal file
View File

@ -0,0 +1,23 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: trailing-whitespace
exclude_types:
- binary
exclude: \.img$
- id: end-of-file-fixer
exclude_types:
- binary
exclude: \.img$
- id: check-yaml
- repo: local
hooks:
- id: pep8
verbose: true
name: pep8
entry: env PATH=.tox/style/bin python tools/cpep8.py
files: \.py$
language: python

View File

@ -1,11 +1,11 @@
# lint Python modules using external checkers. # lint Python modules using external checkers.
# #
# This is the main checker controling the other ones and the reports # This is the main checker controling the other ones and the reports
# generation. It is itself both a raw checker and an astng checker in order # generation. It is itself both a raw checker and an astng checker in order
# to: # to:
# * handle message activation / deactivation at the module level # * handle message activation / deactivation at the module level
# * handle some basic but necessary stats'data (number of classes, methods...) # * handle some basic but necessary stats'data (number of classes, methods...)
# #
[MASTER] [MASTER]
# Specify a configuration file. # Specify a configuration file.
@ -102,7 +102,7 @@ comment=no
# * dangerous default values as arguments # * dangerous default values as arguments
# * redefinition of function / method / class # * redefinition of function / method / class
# * uses of the global statement # * uses of the global statement
# #
[BASIC] [BASIC]
# Required attributes for module, separated by a comma # Required attributes for module, separated by a comma
@ -152,7 +152,7 @@ bad-functions=map,filter,apply,input
# try to find bugs in the code using type inference # try to find bugs in the code using type inference
# #
[TYPECHECK] [TYPECHECK]
# Tells wether missing members accessed in mixin class should be ignored. A # Tells wether missing members accessed in mixin class should be ignored. A
@ -173,7 +173,7 @@ acquired-members=REQUEST,acl_users,aq_parent
# * undefined variables # * undefined variables
# * redefinition of variable from builtins or from an outer scope # * redefinition of variable from builtins or from an outer scope
# * use of variable before assigment # * use of variable before assigment
# #
[VARIABLES] [VARIABLES]
# Tells wether we should check for unused import in __init__ files. # Tells wether we should check for unused import in __init__ files.
@ -190,7 +190,7 @@ additional-builtins=
# checks for sign of poor/misdesign: # checks for sign of poor/misdesign:
# * number of methods, attributes, local variables... # * number of methods, attributes, local variables...
# * size, complexity of functions, methods # * size, complexity of functions, methods
# #
[DESIGN] [DESIGN]
# Maximum number of arguments for function / method # Maximum number of arguments for function / method
@ -228,7 +228,7 @@ max-public-methods=20
# * attributes not defined in the __init__ method # * attributes not defined in the __init__ method
# * supported interfaces implementation # * supported interfaces implementation
# * unreachable code # * unreachable code
# #
[CLASSES] [CLASSES]
# List of interface methods to ignore, separated by a comma. This is used for # List of interface methods to ignore, separated by a comma. This is used for
@ -244,7 +244,7 @@ defining-attr-methods=__init__,__new__,setUp
# * relative / wildcard imports # * relative / wildcard imports
# * cyclic imports # * cyclic imports
# * uses of deprecated modules # * uses of deprecated modules
# #
[IMPORTS] [IMPORTS]
# Deprecated modules which should not be used, separated by a comma # Deprecated modules which should not be used, separated by a comma
@ -266,7 +266,7 @@ int-import-graph=
# checks for: # checks for:
# * warning notes in the code like FIXME, XXX # * warning notes in the code like FIXME, XXX
# * PEP 263: source code with non ascii character but no encoding declaration # * PEP 263: source code with non ascii character but no encoding declaration
# #
[MISCELLANEOUS] [MISCELLANEOUS]
# List of note tags to take in consideration, separated by a comma. # List of note tags to take in consideration, separated by a comma.
@ -278,7 +278,7 @@ notes=FIXME,XXX,TODO
# * strict indentation # * strict indentation
# * line length # * line length
# * use of <> instead of != # * use of <> instead of !=
# #
[FORMAT] [FORMAT]
# Maximum number of characters on a single line. # Maximum number of characters on a single line.
@ -295,7 +295,7 @@ indent-string=' '
# checks for similarities and duplicated code. This computation may be # checks for similarities and duplicated code. This computation may be
# memory / CPU intensive, so you should disable it if you experiments some # memory / CPU intensive, so you should disable it if you experiments some
# problems. # problems.
# #
[SIMILARITIES] [SIMILARITIES]
# Minimum lines number of a similarity. # Minimum lines number of a similarity.

31
INSTALL
View File

@ -1,7 +1,7 @@
This file describes the installation of Chirp without package management This file describes the installation of Chirp without package management
on Linux and other Unix-like operating systems. This sort of thing may on Linux and other Unix-like operating systems. This sort of thing may
be your only choice because 1) a package has not yet been made for your be your only choice because 1) a package has not yet been made for your
OS or distribution, 2) the packaged version is obsolete, or 3) you want OS or distribution, 2) the packaged version is obsolete, or 3) you want
to try a daily build. to try a daily build.
@ -14,7 +14,7 @@ python-serial
python-suds (optional) python-suds (optional)
python-support python-support
For Redhat, Fedora, CentOS and related systems, the following packages For Redhat, Fedora, CentOS and related systems, the following packages
are required: (This list is incomplete. Please submit corrections.) are required: (This list is incomplete. Please submit corrections.)
python python
pygtk2 pygtk2
@ -29,24 +29,23 @@ python-libxml2
libxslt-python libxslt-python
python-suds-jurko python-suds-jurko
Once these packages are installed, you can run Chirp directly from the Once these packages are installed, you can run Chirp directly from the
distribution directory by typing "./chirpw". If you want to install it distribution directory by typing "./chirpw". If you want to install it
properly, type this: properly, type this:
sudo python setup.py install --record files.txt sudo python setup.py install --record files.txt
This will install the package and create a list of files that were This will install the package and create a list of files that were
added to your system. If you want to deinstall Chirp, type this: added to your system. If you want to deinstall Chirp, type this:
sudo xargs -0 rm -rf < files.txt sudo xargs -0 rm -rf < files.txt
This will cause rm(1) to take its list of arguments from the file named This will cause rm(1) to take its list of arguments from the file named
"files.txt" and remove those files from the system. If you forgot to "files.txt" and remove those files from the system. If you forgot to
create "files.txt", you can simply reinstall the way it is shown here create "files.txt", you can simply reinstall the way it is shown here
and continue on your way. and continue on your way.
Note: This will not uninstall directories created by the installation of Note: This will not uninstall directories created by the installation of
Chirp. Presence of these empty directories shouldn't be a problem, but Chirp. Presence of these empty directories shouldn't be a problem, but
if they are, it's easy to go through the files.txt file, identify them, if they are, it's easy to go through the files.txt file, identify them,
and remove them. and remove them.

View File

@ -28,7 +28,7 @@ the "Browser" tab in the left sidebar, which is visible when the Developer
tools are enabled. tools are enabled.
The default size is 10. Values less than 4, greater than 144, or not The default size is 10. Values less than 4, greater than 144, or not
recognized as an integer will result in a log message and the default recognized as an integer will result in a log message and the default
size will be used. size will be used.
======== ========
@ -37,7 +37,7 @@ This specifies the fontsize used in the hex dump/diff display which is
invoked by selecting View -> Developer -> Diff tabs. invoked by selecting View -> Developer -> Diff tabs.
The default size is 11. Values less than 4, greater than 144, or not The default size is 11. Values less than 4, greater than 144, or not
recognized as an integer will result in a log message and the default recognized as an integer will result in a log message and the default
size will be used. size will be used.
======== ========
@ -60,5 +60,3 @@ Exceptions that have been observed in testing formats which are
invalid in this context are caught, and the default format is used. invalid in this context are caught, and the default format is used.
======== ========

View File

@ -1,8 +1,8 @@
name: chirp-snap name: chirp-snap
summary: A free, open-source tool for programming your amateur radio summary: A free, open-source tool for programming your amateur radio
description: | description: |
CHIRP is a free, open-source tool for programming your amateur radio. CHIRP is a free, open-source tool for programming your amateur radio.
It supports a large number of manufacturers and models, as well as It supports a large number of manufacturers and models, as well as
provides a way to interface with multiple data sources and formats. provides a way to interface with multiple data sources and formats.
adopt-info: chirp adopt-info: chirp
@ -24,7 +24,7 @@ apps:
command: bin/chirp command: bin/chirp
desktop: lib/python3.10/site-packages/chirp/share/chirp.desktop desktop: lib/python3.10/site-packages/chirp/share/chirp.desktop
extensions: extensions:
# WARNING: gnome extension is incompatible with python apps. # WARNING: gnome extension is incompatible with python apps.
- gnome - gnome
plugs: plugs:
- home - home

View File

@ -465,21 +465,22 @@ For the purposes of the Python 3 effort, a "tested" radio means
at least the following procedure was followed: at least the following procedure was followed:
1. Download from the radio 1. Download from the radio
1. Make some change to a memory 1. Make some change to a memory
1. If the radio has settings support, make sure settings load and tweak one setting 1. If the radio has settings support, make sure settings load and tweak
one setting
1. Upload to the radio 1. Upload to the radio
1. Confirm that the changes stick and look correct, or at least are not a 1. Confirm that the changes stick and look correct, or at least are not a
regression from the master py2 branch. regression from the master py2 branch.
The drivers are all passing the automated tests, but tests with real hardware The drivers are all passing the automated tests, but tests with real
and serial ports is important, especially around bytes-vs-string safety. hardware and serial ports is important, especially around bytes-vs-string
safety.
To update this document, add/edit entries in `tests/py3_driver_testers.txt` and To update this document, add/edit entries in `tests/py3_driver_testers.txt`
then run `tox -e makesupported`. Commit the result (including the changes to this `.md` and then run `tox -e makesupported`. Commit the result (including the
file) and submit a PR. changes to this `.md` file) and submit a PR.
The "Byte Clean" flag refers to whether or not the radio has set the The "Byte Clean" flag refers to whether or not the radio has set the
`NEEDS_COMPAT_SERIAL = False` flag on the radio class, and thus uses `NEEDS_COMPAT_SERIAL = False` flag on the radio class, and thus uses
`MemoryMapBytes` exclusively internally. Whenever possible, all radios `MemoryMapBytes` exclusively internally. Whenever possible, all radios
that are fixed for py3 should do so with this flag set to False and with that are fixed for py3 should do so with this flag set to False and with
the byte-native memory map. the byte-native memory map.

View File

@ -32,4 +32,3 @@ serialsniff: serialsniff.c
clean: clean:
$(REMOVE) serialsniff *~ *.o *.bak core tags shar a.out $(REMOVE) serialsniff *~ *.o *.bak core tags shar a.out

View File

@ -92,4 +92,3 @@ for usbserial in /sys/class/tty/ttyUSB*; do
break break
fi fi
done done

View File

@ -208,8 +208,7 @@ def main():
`NEEDS_COMPAT_SERIAL = False` flag on the radio class, and thus uses `NEEDS_COMPAT_SERIAL = False` flag on the radio class, and thus uses
`MemoryMapBytes` exclusively internally. Whenever possible, all radios `MemoryMapBytes` exclusively internally. Whenever possible, all radios
that are fixed for py3 should do so with this flag set to False and with that are fixed for py3 should do so with this flag set to False and with
the byte-native memory map. the byte-native memory map."""),
"""),
file=output) file=output)
for driver, (tester, tested) in testers.items(): for driver, (tester, tested) in testers.items():

View File

@ -146,7 +146,7 @@ int saferead(int fd, char *buf, int len)
if ((val.it_value.tv_sec == 0) && if ((val.it_value.tv_sec == 0) &&
(val.it_value.tv_usec == 0)) { (val.it_value.tv_usec == 0)) {
if (!quiescent) if (!quiescent)
printf("Timeout\n"); printf("Timeout\n");
break; break;
} }