Skip to content

Commit

Permalink
Merge pull request #66 from cclauss/more-ruff
Browse files Browse the repository at this point in the history
Lint: More ruff rules
  • Loading branch information
nwhitehead committed May 14, 2024
2 parents 6417932 + 81e3090 commit 56f6006
Show file tree
Hide file tree
Showing 9 changed files with 100 additions and 9 deletions.
Empty file added __init__.py
Empty file.
27 changes: 18 additions & 9 deletions fluidsynth.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,24 @@
================================================================================
"""

import os
from ctypes import (
CDLL, CFUNCTYPE, POINTER, Structure, byref, c_void_p, create_string_buffer, c_char,
c_char_p, c_double, c_float, c_int, c_short, c_uint
CDLL,
CFUNCTYPE,
POINTER,
Structure,
byref,
c_char,
c_char_p,
c_double,
c_float,
c_int,
c_short,
c_uint,
c_void_p,
create_string_buffer,
)
from ctypes.util import find_library
import os

# DLL search method changed in Python 3.8
# https://docs.python.org/3/library/os.html#os.add_dll_directory
Expand Down Expand Up @@ -93,10 +105,7 @@ def cfunc(name, result, *args):

majver = c_int()
fluid_version(majver, c_int(), c_int())
if majver.value > 1:
FLUIDSETTING_EXISTS = FLUID_OK
else:
FLUIDSETTING_EXISTS = 1
FLUIDSETTING_EXISTS = FLUID_OK if majver.value > 1 else 1

# fluid settings
new_fluid_settings = cfunc('new_fluid_settings', c_void_p)
Expand Down Expand Up @@ -710,11 +719,11 @@ def start(self, driver=None, device=None, midi_driver=None, midi_router=None):
see http://www.fluidsynth.org/api/fluidsettings.xml for allowed values and defaults by platform
"""
driver = driver or self.get_setting('audio.driver')
device = device or self.get_setting('audio.%s.device' % driver)
device = device or self.get_setting(f'audio.{driver}.device')
midi_driver = midi_driver or self.get_setting('midi.driver')

self.setting('audio.driver', driver)
self.setting('audio.%s.device' % driver, device)
self.setting(f'audio.{driver}.device', device)
self.audio_driver = new_fluid_audio_driver(self.settings, self.synth)
self.setting('midi.driver', midi_driver)
self.router = new_fluid_midi_router(self.settings, fluid_synth_handle_midi_event, self.synth)
Expand Down
74 changes: 74 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
[tool.ruff]
line-length = 123
target-version = "py38"

[tool.ruff.lint]
select = [
"AIR", # Airflow
"ASYNC", # flake8-async
"B", # flake8-bugbear
"BLE", # flake8-blind-except
"C4", # flake8-comprehensions
"C90", # McCabe cyclomatic complexity
"COM", # flake8-commas
"DJ", # flake8-django
"DTZ", # flake8-datetimez
"E", # pycodestyle
"F", # Pyflakes
"FA", # flake8-future-annotations
"FIX", # flake8-fixme
"FLY", # flynt
"G", # flake8-logging-format
"I", # isort
"INP", # flake8-no-pep420
"INT", # flake8-gettext
"ISC", # flake8-implicit-str-concat
"LOG", # flake8-logging
"NPY", # NumPy-specific rules
"PD", # pandas-vet
"PERF", # Perflint
"PGH", # pygrep-hooks
"PIE", # flake8-pie
"PT", # flake8-pytest-style
"PYI", # flake8-pyi
"RSE", # flake8-raise
"S", # flake8-bandit
"SIM", # flake8-simplify
"SLF", # flake8-self
"SLOT", # flake8-slots
"T10", # flake8-debugger
"TCH", # flake8-type-checking
"TD", # flake8-todos
"TID", # flake8-tidy-imports
"TRIO", # flake8-trio
"UP", # pyupgrade
"YTT", # flake8-2020
# "A", # flake8-builtins
# "ANN", # flake8-annotations
# "ARG", # flake8-unused-arguments
# "CPY", # flake8-copyright
# "D", # pydocstyle
# "EM", # flake8-errmsg
# "ERA", # eradicate
# "EXE", # flake8-executable
# "FBT", # flake8-boolean-trap
# "FURB", # refurb
# "ICN", # flake8-import-conventions
# "N", # pep8-naming
# "PL", # Pylint
# "PTH", # flake8-use-pathlib
# "Q", # flake8-quotes
# "RET", # flake8-return
# "RUF", # Ruff-specific rules
# "T20", # flake8-print
# "TRY", # tryceratops
# "W", # pycodestyle
]

[tool.ruff.lint.per-file-ignores]
"__init__.py" = [
"E402",
]
"test/*" = [
"S101",
]
Empty file added test/__init__.py
Empty file.
1 change: 1 addition & 0 deletions test/sequencerTest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python3

import time

import fluidsynth

seqduration = 1000
Expand Down
2 changes: 2 additions & 0 deletions test/test1.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import time

import fluidsynth


def local_file_path(file_name: str) -> str:
"""
Return a file path to a file that is in the same directory as this file.
Expand Down
2 changes: 2 additions & 0 deletions test/test2.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import numpy
import pyaudio

import fluidsynth


def local_file_path(file_name: str) -> str:
"""
Return a file path to a file that is in the same directory as this file.
Expand Down
1 change: 1 addition & 0 deletions test/test3.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import fluidsynth


def local_file_path(file_name: str) -> str:
"""
Return a file path to a file that is in the same directory as this file.
Expand Down
2 changes: 2 additions & 0 deletions test/test4.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import time

import fluidsynth


def local_file_path(file_name: str) -> str:
"""
Return a file path to a file that is in the same directory as this file.
Expand Down

0 comments on commit 56f6006

Please sign in to comment.