jisaacstone / sfzlint

parser and linter for sfz files written in python using Lark
MIT License
17 stars 4 forks source link

Update syntax.yml from source #3

Closed kmturley closed 2 years ago

kmturley commented 2 years ago

Current syntax.yml file was last updated Feb 22, 2020: https://github.com/jisaacstone/sfzlint/blob/master/sfzlint/syntax.yml

Latest version available was last updated May 28 2021: https://github.com/sfzformat/sfzformat.github.io/blob/source/_data/sfz/syntax.yml

If I update the syntax.yml file manually there are errors in Python:

File "/usr/local/lib/python3.9/site-packages/sfzlint-0.1.2-py3.9.egg/sfzlint/spec.py", line 143, in op_to_validator
    ver=ver_mapping[op_data.get('version')],
KeyError: 'sfizz'

It seems that the new syntax.yml has breaking changes, which require Python code changes.

redtide commented 2 years ago

Yes, I added some sfizz opcode extensions and upgraded the format version (on line 1 of syntax.yml). Note that to make the following changes I had also to include the changes on PR #2. I tried to add a 'sfizz': 'sfizz', into sfzlint/spec.py#L20 but I got another unrelated error, here the backtrace:

Traceback (most recent call last):
  File "/usr/bin/sfzlint", line 33, in <module>
    sys.exit(load_entry_point('sfzlint==0.1.2', 'console_scripts', 'sfzlint')())
  File "/usr/bin/sfzlint", line 25, in importlib_load_entry_point
    return next(matches).load()
  File "/usr/lib/python3.9/importlib/metadata.py", line 77, in load
    module = import_module(match.group('module'))
  File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/usr/lib/python3.9/site-packages/sfzlint/cli.py", line 5, in <module>
    from . import spec, parser, lint, opcodes
  File "/usr/lib/python3.9/site-packages/sfzlint/spec.py", line 204, in <module>
    opcodes = _pickled('opcides', lambda: _override(_extract()))
  File "/usr/lib/python3.9/site-packages/sfzlint/spec.py", line 194, in _pickled
    data = fn()
  File "/usr/lib/python3.9/site-packages/sfzlint/spec.py", line 204, in <lambda>
    opcodes = _pickled('opcides', lambda: _override(_extract()))
  File "/usr/lib/python3.9/site-packages/sfzlint/spec.py", line 103, in _override
    opp = opp[key]
KeyError: 'varNN_target'

I might be wrong, but despite what it seems to be a typo ("opcides"), it seems to me there is something strange in code regarding the 'NN' bit of the var opcode, which is always numeric, unless it's being replaced in the application. That opcode series is also complex and I think I haven't managed them properly in the database, if were for me I would remove it from the linter temporarily until is fixed/consistent in the db.

jisaacstone commented 2 years ago

I had some hard-coded overrides for the inconsistent DB entries.

Pulled latest syntax.yml and updated the code to be more flexible about inconsistencies. All tests pass.

kmturley commented 2 years ago

Amazing it works! Thanks for taking the time to update it.

I've updated my GitHub workflow to use your version: https://github.com/studiorack/studiorack-template-sfz/blob/main/.github/workflows/test.yml

Passes correctly: https://github.com/studiorack/studiorack-template-sfz/runs/4613277252?check_suite_focus=true