https://bugs.kde.org/show_bug.cgi?id=442012

            Bug ID: 442012
           Summary: [python3] Keywords-only enforcement using `*,` partly
                    breaks syntax highlighting
           Product: frameworks-syntax-highlighting
           Version: 5.85.0
          Platform: Neon Packages
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: syntax
          Assignee: kwrite-bugs-n...@kde.org
          Reporter: geisse...@gmail.com
                CC: walter.von.entfer...@posteo.net
  Target Milestone: ---

Created attachment 141294
  --> https://bugs.kde.org/attachment.cgi?id=141294&action=edit
With *, syntax

SUMMARY

Since Python 3, one can enforce the use of keyword arguments in method
definitions. This ensures that downstream code is proof against possible future
changes to the order of positional arguments. All arguments from a `*,` onwards
need to be preceeded with explicit keywords (cf.
https://www.vegardstikbakke.com/python-keyword-only/).

However, this syntax seems to partly break KDevelop's Python syntax
highlighting, with default arguments following the `*,` not being
recognised/highlighted anymore.

Example:
```python3
import os

class Backend:
    AUTO = None

def run(
        info,
        tempdir,
        *,
        backend = Backend.AUTO,
        n_processes = os.cpu_count()+1,
        n_chunks = 1,
        scaling = 1,
        cache_name = 'cache',
        verbose = True,
    ):
    pass
```

STEPS TO REPRODUCE
1. Paste a Python code using the keyword-only enforcing `*,` into KDevelop, for
instance the above example.
2. Save it as $SOME_FILENAME.py for syntax highlighting to get active.
3. Remove the `*,` and see how syntax highlighting changes

OBSERVED RESULT
Default arguments after `*,` are not highlighted. Without `*,` they are.

EXPECTED RESULT
Default arguments should always be highlighted correctly, regardless of whether
there is a `*,` or not.

SOFTWARE/OS VERSIONS
Operating System: KDE neon 5.22
KDE Plasma Version: 5.22.5
KDE Frameworks Version: 5.85.0
Qt Version: 5.15.3
Kernel Version: 5.11.0-27-generic (64-bit)
Graphics Platform: Wayland

ADDITIONAL INFORMATION
Maybe this is rather a problem with KDevelop than with the syntax highlighting
framework. If you think so, feel free to move the issue.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to