Skip to content

Commit

Permalink
GitHub Action to spellcheck and lint Python code
Browse files Browse the repository at this point in the history
  • Loading branch information
cclauss committed Apr 27, 2024
1 parent 5a1920d commit d27fbbd
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 16 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/codespell_and_ruff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# This Action uses minimal steps to run in ~5 seconds to rapidly:
# look for typos in the codebase using codespell, and
# lint Python code using ruff and provide intuitive GitHub Annotations to contributors.
# https://github.com/codespell-project/codespell#readme
# https://docs.astral.sh/ruff/
name: codespell_and_ruff
on:
push:
branches: [master]
pull_request:
jobs:
codespell_and_ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: pip install --user codespell[toml] ruff
- run: codespell **/*.py **/*.txt
- run: ruff check --output-format=github --target-version=py38 .
17 changes: 8 additions & 9 deletions doc/utils/checkfiledocs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import os
import os.path
import string

paRootDirectory = '../../'
paHtmlDocDirectory = os.path.join( paRootDirectory, "doc", "html" )
Expand Down Expand Up @@ -52,9 +51,9 @@ def doxygenHtmlDocFileName( sourceFile ):
return sourceFile.replace( '_', '__' ).replace( '.', '_8' ) + '.html'


sourceFiles = recursiveFindFiles( os.path.join(paRootDirectory,'src'), [ '.c', '.h', '.cpp' ], ['.svn', 'mingw-include'], True );
sourceFiles += recursiveFindFiles( os.path.join(paRootDirectory,'include'), [ '.c', '.h', '.cpp' ], ['.svn'], True );
docFiles = recursiveFindFiles( paHtmlDocDirectory, [ '.html' ], ['.svn'], False );
sourceFiles = recursiveFindFiles( os.path.join(paRootDirectory,'src'), [ '.c', '.h', '.cpp' ], ['.svn', 'mingw-include'], True )
sourceFiles += recursiveFindFiles( os.path.join(paRootDirectory,'include'), [ '.c', '.h', '.cpp' ], ['.svn'], True )
docFiles = recursiveFindFiles( paHtmlDocDirectory, [ '.html' ], ['.svn'], False )



Expand All @@ -69,19 +68,19 @@ def printError( f, message ):


for f in sourceFiles:
if not doxygenHtmlDocFileName( os.path.basename(f) ) in docFiles:
if doxygenHtmlDocFileName( os.path.basename(f) ) not in docFiles:
printError( f, "no doxygen generated doc page" )

s = open( f, 'rt' ).read()

if not '/**' in s:
if '/**' not in s:
printError( f, "no doxygen /** block" )

if not '@file' in s:
if '@file' not in s:
printError( f, "no doxygen @file tag" )

if not '@brief' in s:
if '@brief' not in s:
printError( f, "no doxygen @brief tag" )

if not '@ingroup' in s:
if '@ingroup' not in s:
printError( f, "no doxygen @ingroup tag" )
2 changes: 1 addition & 1 deletion msvc/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ This DLL contains all 5 current Win32 PA APIS (MME/DS/ASIO/WASAPI/WDMKS)
http://www.microsoft.com/msdownload/platformsdk/sdkupdate/psdk-full.htm
(This will allow your code base to be x64 friendly, with correct defines
for LONG_PTR and such)
NOTE A) Yes you have to use IE activex scripts to install that - wont work in Firefox, you
NOTE A) Yes you have to use IE activex scripts to install that - won't work in Firefox, you
may have to temporarily change tyour default browser(aint life unfair)
NOTE B) Dont forget to hit "Register PSDK Directories with Visual Studio".
you can make sure its right in VC6 if you open tools/options/directories/include files and you see SDK 2003 as the FIRST entry
Expand Down
4 changes: 2 additions & 2 deletions pa_whitelint.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def allowStrangeIndentOfLine(lineText):
# check and then normalize to \n line endings for the benefit of the rest of the program
if b"\r" in data and b"\n" in data:
# CRLF (Windows) case: check for stray CR or LF, then convert CRLF to LF
assert not b"\f" in data # we'll use \f as a sentinel during conversion
assert b"\f" not in data # we'll use \f as a sentinel during conversion
d = data.replace(b"\r\n", b"\f")
if b"\r" in d:
status.incrementIssueCount("has-inconsistent-line-endings")
Expand Down Expand Up @@ -261,7 +261,7 @@ def allowStrangeIndentOfLine(lineText):
# 7. No "empty" (or whitespace) lines at end-of-file.
# Cases:
# 1. There is an EOL at EOF. Since the lines array is constructed by splitting on '\n',
# the final element in the lines array will be an empty string. This is expeced and allowed.
# the final element in the lines array will be an empty string. This is expected and allowed.
# Then continue to check for earlier empty lines.
# 2. There is no EOF at EOL.
# Check for empty lines, including the final line.
Expand Down
10 changes: 6 additions & 4 deletions test/patest_suggested_vs_streaminfo_latency.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from __future__ import print_function

import os
from pylab import *
from pylab import figure, gcf, grid, legend, plot, title, xlabel, xlim, ylabel, ylim
import numpy
from matplotlib.backends.backend_pdf import PdfPages

Expand All @@ -29,7 +29,7 @@ def loadCsvData( dataFileName ):
inputDevice = ""
outputDevice = ""

startLines = file(dataFileName).readlines(1024)
startLines = open(dataFileName).readlines(1024)
for line in startLines:
if "output device" in line:
outputDevice = line.strip(" \t\n\r#")
Expand All @@ -39,7 +39,9 @@ def loadCsvData( dataFileName ):

data = numpy.loadtxt(dataFileName, delimiter=",", skiprows=4).transpose()

class R(object): pass
class R(object):
pass

result = R()
result.params = params
for s in params.split(','):
Expand All @@ -53,7 +55,7 @@ class R(object): pass
result.halfDuplexInputLatency = data[2]
result.fullDuplexOutputLatency = data[3]
result.fullDuplexInputLatency = data[4]
return result;
return result


def setFigureTitleAndAxisLabels( framesPerBufferString ):
Expand Down

0 comments on commit d27fbbd

Please sign in to comment.