Skip to content

UnboundLocalError when dynamically imported #34

@js-truework

Description

@js-truework

Describe the bug

The sly library that scim2-filter-parser relies on will no longer be updated and is currently pinned at ==0.4 in pyproject.toml. Unfortunately the sly library also behaves poorly when being dynamically imported (such as by celery in a django application, or by ddtrace-run from datadog).

I don't think the whole problem needs to be solved by scim2-filter-parser, but I wanted to raise an issue to understand whether or not the as-of-recently unmaintained sly library would/could be replaced in future versions of scim2-filter-parser.

Others may encounter this issue, which surfaces as local variable 'pattern' referenced before assignment in sly.lex.Lexer._build. This happens when including django_scim.views in your application, since one of the imports of django_scim.views is scim2_filter_parser.parser.SCIMParserError, which in turn imports from sly import Parser, which causes the __init__.py in sly to run, which does from .lex import *, which then causes class Lexer(metaclass=LexerMeta): to be evaluated.

Again, I don't necessarily think this whole bug chain is the responsibility of scim2-filter-parser, but the issue has to be opened somewhere and since sly is a direct dependency of this repo and is no longer going to be maintained, I figured it would be a good place to call attention to potential problems that result from it. I captured more details on the sly bug in ticket dabeaz/sly#106, but expect no release to be made to fix it as the project is explicitly no longer maintained.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions