diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/fluidsynth.py b/fluidsynth.py index 5f9d699..e4cb430 100644 --- a/fluidsynth.py +++ b/fluidsynth.py @@ -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 @@ -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) @@ -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) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..1f8b8f6 --- /dev/null +++ b/pyproject.toml @@ -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", +] diff --git a/test/__init__.py b/test/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/test/sequencerTest.py b/test/sequencerTest.py index 65a0e50..66ed022 100644 --- a/test/sequencerTest.py +++ b/test/sequencerTest.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import time + import fluidsynth seqduration = 1000 diff --git a/test/test1.py b/test/test1.py index 72f5139..da84abf 100644 --- a/test/test1.py +++ b/test/test1.py @@ -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. diff --git a/test/test2.py b/test/test2.py index 03f7d9c..c9efc12 100644 --- a/test/test2.py +++ b/test/test2.py @@ -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. diff --git a/test/test3.py b/test/test3.py index c42cedc..be74512 100644 --- a/test/test3.py +++ b/test/test3.py @@ -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. diff --git a/test/test4.py b/test/test4.py index cef3f66..d44649d 100644 --- a/test/test4.py +++ b/test/test4.py @@ -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.