Return to using single quotes · rec/tuney@46e0d15

24 files changed

lines changed

Original file line numberDiff line numberDiff line change

@@ -35,6 +35,9 @@ branch = true

3535

[tool.coverage.report]

3636

skip_covered = true

3737

exclude_lines = ["pragma: no cover", "if False:", "if __name__ == .__main__.:", "raise NotImplementedError"]

38+
39+

[tool.ruff.format]

40+

quote-style = "single"

3841

[build-system]

3942

requires = ["hatchling"]

4043

build-backend = "hatchling.build"

Original file line numberDiff line numberDiff line change

@@ -39,10 +39,10 @@ def int_or_str(text):

3939
4040

parser = argparse.ArgumentParser(add_help=False)

4141

parser.add_argument(

42-

"-l",

43-

"--list-devices",

44-

action="store_true",

45-

help="show list of audio devices and exit",

42+

'-l',

43+

'--list-devices',

44+

action='store_true',

45+

help='show list of audio devices and exit',

4646

)

4747

args, remaining = parser.parse_known_args()

4848

if args.list_devices:

@@ -53,9 +53,9 @@ def int_or_str(text):

5353

formatter_class=argparse.RawDescriptionHelpFormatter,

5454

parents=[parser],

5555

)

56-

parser.add_argument("filename", metavar="FILENAME", help="audio file to be played back")

56+

parser.add_argument('filename', metavar='FILENAME', help='audio file to be played back')

5757

parser.add_argument(

58-

"-d", "--device", type=int_or_str, help="output device (numeric ID or substring)"

58+

'-d', '--device', type=int_or_str, help='output device (numeric ID or substring)'

5959

)

6060

args = parser.parse_args(remaining)

6161

@@ -87,6 +87,6 @@ def callback(outdata, frames, time, status):

8787

with stream:

8888

event.wait() # Wait until playback is finished

8989

except KeyboardInterrupt:

90-

parser.exit(1, "\nInterrupted by user")

90+

parser.exit(1, '\nInterrupted by user')

9191

except Exception as e:

92-

parser.exit(1, type(e).__name__ + ": " + str(e))

92+

parser.exit(1, type(e).__name__ + ': ' + str(e))

Original file line numberDiff line numberDiff line change

@@ -11,7 +11,7 @@

1111
1212
1313

class Grid(App):

14-

theme = "textual-light"

14+

theme = 'textual-light'

1515

CSS = CSS

1616
1717

def __init__(self, *a: Any, **ka: Any) -> None:

@@ -32,5 +32,5 @@ def resize_grid(self) -> None:

3232

s.grid_size_rows = 3

3333
3434
35-

if __name__ == "__main__":

35+

if __name__ == '__main__':

3636

Grid().run()

Original file line numberDiff line numberDiff line change

@@ -12,38 +12,38 @@ def count_scales(tones: int) -> tuple[str, ...]:

1212

if tones <= 0:

1313

return ()

1414

if tones == 1:

15-

return ("1",)

15+

return ('1',)

1616

if tones == 2:

17-

return ("11", "2")

17+

return ('11', '2')

1818
1919

def count() -> Iterator[str]:

20-

yield from (f"1{i}" for i in count_scales(tones - 1))

21-

yield from (f"2{i}" for i in count_scales(tones - 2))

20+

yield from (f'1{i}' for i in count_scales(tones - 1))

21+

yield from (f'2{i}' for i in count_scales(tones - 2))

2222
2323

return tuple(count())

2424
2525
2626

def count_to_notes(s: str) -> str:

2727

if len(s) < 7:

28-

notes = "CDEFGA"[: len(s)]

28+

notes = 'CDEFGA'[: len(s)]

2929

else:

30-

notes = UPPER[2 : len(s)] + "AB"

30+

notes = UPPER[2 : len(s)] + 'AB'

3131
3232

def parts() -> Iterator[str]:

3333

for char, n in zip(s, notes):

3434

yield n

35-

if char == "2":

36-

yield "_"

35+

if char == '2':

36+

yield '_'

3737
38-

return "".join(parts())

38+

return ''.join(parts())

3939
4040
41-

if __name__ == "__main__":

41+

if __name__ == '__main__':

4242

import sys

4343
4444

_, *a = sys.argv

4545

count = int(a[0]) if a else 12

4646
4747

for tones in range(count):

4848

it = (count_to_notes(i) for i in count_scales(tones + 1))

49-

print(tones + 1, *it, sep="\n ")

49+

print(tones + 1, *it, sep='\n ')

Original file line numberDiff line numberDiff line change

@@ -1,6 +1,6 @@

11

def main():

2-

print("Hello from tuney!")

2+

print('Hello from tuney!')

33
44
5-

if __name__ == "__main__":

5+

if __name__ == '__main__':

66

main()

Original file line numberDiff line numberDiff line change

@@ -2,7 +2,7 @@

22
33

from tuney.scale import twelve_tet as tt

44
5-

NOTES = ["C1", "C#3", "G♯5", "C-2", "F♭10"]

5+

NOTES = ['C1', 'C#3', 'G♯5', 'C-2', 'F♭10']

66
77
88

def canonical(s: str) -> str:

@@ -11,10 +11,10 @@ def canonical(s: str) -> str:

1111

return s

1212
1313
14-

@pytest.mark.parametrize("note", NOTES)

14+

@pytest.mark.parametrize('note', NOTES)

1515

def test_twelve_tet(note):

1616

number = tt.name_to_number(note)

1717

name = tt.number_to_name(number)

1818

assert tt.name_to_number(name) == number

1919
20-

assert note == "F♭10" or name == canonical(note)

20+

assert note == 'F♭10' or name == canonical(note)

Original file line numberDiff line numberDiff line change

@@ -2,13 +2,13 @@

22
33
44

def test_text_timings():

5-

tt = TextTimings(other={"!": 2000}, random_seed=23)

5+

tt = TextTimings(other={'!': 2000}, random_seed=23)

66

# actual = [int(i.time) for i in tt.lines_to_times(TEXT)]

77

letters, begins, ends = zip(*tt(TEXT), strict=True)

8-

text = "".join(letters)

8+

text = ''.join(letters)

99

begins = [int(i) for i in begins]

1010

ends = [int(i) for i in ends]

11-

assert text == "One, .\nThree!"

11+

assert text == 'One, .\nThree!'

1212

assert (begins, ends) == (BEGINS, ENDS)

1313
1414
Original file line numberDiff line numberDiff line change

@@ -6,5 +6,5 @@ def main() -> None:

66

pass

77
88
9-

if __name__ == "__main__":

9+

if __name__ == '__main__':

1010

main()

Original file line numberDiff line numberDiff line change

@@ -3,7 +3,7 @@

33
44

import sounddevice as sd

55
6-

_T = TypeVar("_T", bound=sd._StreamBase)

6+

_T = TypeVar('_T', bound=sd._StreamBase)

77
88
99

@dc.dataclass

@@ -24,7 +24,7 @@ class DeviceConfig:

2424

class DeviceMaker(Generic[_T]):

2525

@classmethod

2626

def type(cls) -> type[_T]:

27-

bases = getattr(cls, "__orig_bases__", None)

27+

bases = getattr(cls, '__orig_bases__', None)

2828

assert bases is not None

2929

return get_args(bases[0])[0]

3030

@@ -36,5 +36,5 @@ class OutputStreamMaker(DeviceMaker[sd.OutputStream]):

3636

pass

3737
3838
39-

if __name__ == "__main__":

39+

if __name__ == '__main__':

4040

print(OutputStreamMaker.type())

Original file line numberDiff line numberDiff line change

@@ -29,9 +29,9 @@ def _fill(self, out: Data) -> bool:

2929

return success

3030
3131
32-

if __name__ == "__main__":

32+

if __name__ == '__main__':

3333

import sys

3434
3535

for a in sys.argv[1:]:

36-

print("open", a)

36+

print('open', a)

3737

FilePlayer(a).run()