Skip to content

SyntaxWarning/SyntaxError upon import in Python>=3.12 #165

@qthequartermasterman

Description

@qthequartermasterman

Since at least Python 3.12 (and earlier, it looks: python/cpython#103493), the pattern index is not "" emits aSyntaxWarning or SyntaxError when the interpreter compiles the remote.py file to bytecode.

This can be reproduced easily by creating a fresh virtual environment and running:

$ python -m cenpy.remote            
/Users/<username>/cenpy/cenpy/remote.py:224: SyntaxWarning: "is not" with 'str' literal. Did you mean "!="?
  if index is not "":

This SyntaxWarning only happens upon compilation, so it's not normally a big deal. But for some reason, especially when running in a fresh environment in CI, this triggers a SyntaxError when running within pytest. I haven't been able to reproduce the SyntaxError in my local environment, curiously enough, but the fix should be the same either way.

This should be easy to resolve by changing is not to !=.

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