Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SyntaxWarnings related to invalid escape sequences when installing by Poetry #51

Open
Cybernetic-Ransomware opened this issue Sep 20, 2024 · 1 comment

Comments

@Cybernetic-Ransomware
Copy link

Hi,
recently tried to instal library by poetry. That started some background validations processes. So, right now i have a list of SyntaxWarning prints during stetting the containers. All of them are about invalid escape sequence. I think that could be simply fixed by raw string synthax: r'', but i wonder, did someone met inproper functionalities during the rular usage?

Hi,

I recently tried to install the library using Poetry, which triggered some background validation processes. Currently, I am encountering a list of SyntaxWarning messages related to invalid escape sequences while setting up the containers. All of the warnings are about invalid escape sequences:

app-1            | /usr/local/lib/python3.12/site-packages/ftrack_api/query.py:13: SyntaxWarning: invalid escape sequence '\d'
app-1            |   OFFSET_EXPRESSION = re.compile("(?P<offset>offset (?P<value>\d+))")
app-1            | /usr/local/lib/python3.12/site-packages/ftrack_api/query.py:14: SyntaxWarning: invalid escape sequence '\d'                                                                                                                                                                                     
app-1            |   LIMIT_EXPRESSION = re.compile("(?P<limit>limit (?P<value>\d+))")                                                                                                                                                                                                                              
app-1            | /usr/local/lib/python3.12/site-packages/ftrack_api/query.py:13: SyntaxWarning: invalid escape sequence '\d'                                                                                                                                                                                     
app-1            |   OFFSET_EXPRESSION = re.compile("(?P<offset>offset (?P<value>\d+))")
app-1            | /usr/local/lib/python3.12/site-packages/ftrack_api/query.py:14: SyntaxWarning: invalid escape sequence '\d'                                                                                                                                                                                     
app-1            |   LIMIT_EXPRESSION = re.compile("(?P<limit>limit (?P<value>\d+))")                                                                                                                                                                                                                              
app-1            | /usr/local/lib/python3.12/site-packages/ftrack_api/query.py:13: SyntaxWarning: invalid escape sequence '\d'                                                                                                                                                                                     
app-1            |   OFFSET_EXPRESSION = re.compile("(?P<offset>offset (?P<value>\d+))")
app-1            | /usr/local/lib/python3.12/site-packages/ftrack_api/query.py:14: SyntaxWarning: invalid escape sequence '\d'                                                                                                                                                                                     
app-1            |   LIMIT_EXPRESSION = re.compile("(?P<limit>limit (?P<value>\d+))")                                                                                                                                                                                                                              
app-1            | /usr/local/lib/python3.12/site-packages/ftrack_api/plugin.py:32: SyntaxWarning: invalid escape sequence '\*'
app-1            |   """Find and load plugins in search *paths*.
app-1            | /usr/local/lib/python3.12/site-packages/ftrack_api/structure/standard.py:133: SyntaxWarning: invalid escape sequence '\w'                                                                                                                                                                       
app-1            |   "[^\w\.-]", self.illegal_character_substitute, value.decode("utf-8")
app-1            | /usr/local/lib/python3.12/site-packages/ftrack_api/structure/standard.py:133: SyntaxWarning: invalid escape sequence '\w'                                                                                                                                                                       
app-1            |   "[^\w\.-]", self.illegal_character_substitute, value.decode("utf-8")                                                                                                                                                                                                                          
app-1            | /usr/local/lib/python3.12/site-packages/ftrack_api/structure/standard.py:133: SyntaxWarning: invalid escape sequence '\w'                                                                                                                                                                       
app-1            |   "[^\w\.-]", self.illegal_character_substitute, value.decode("utf-8")
app-1            | /usr/local/lib/python3.12/site-packages/ftrack_api/structure/standard.py:133: SyntaxWarning: invalid escape sequence '\w'                                                                                                                                                                       
app-1            |   "[^\w\.-]", self.illegal_character_substitute, value.decode("utf-8")        

I believe this could be easily fixed by using raw string syntax (r''), but I wonder if anyone has experienced any functionality issues related to this during regular usage?

@Cybernetic-Ransomware Cybernetic-Ransomware changed the title SyntaxWarnings related to invalid escape sequences when installing with Poetry SyntaxWarnings related to invalid escape sequences when installing by Poetry Sep 23, 2024
@stat1c-void
Copy link

Same. Those affected strings definitely should be prefixed with raw modifier.

Not necessarily needs to be installed through Poetry in order to reproduce the warnings. Checked with Python versions: 3.10.15, 3.11.10.

Reproduction steps

docker run --rm -it python:3.11-slim bash

# inside the container:
pip install --no-compile ftrack-python-api
python -B -Wall -c "import ftrack_api"

--no-compile seems important for reproduction, because pip might mask those warnings.

Output:

/usr/local/lib/python3.11/site-packages/ftrack_api/query.py:13: DeprecationWarning: invalid escape sequence '\d'
  OFFSET_EXPRESSION = re.compile("(?P<offset>offset (?P<value>\d+))")
/usr/local/lib/python3.11/site-packages/ftrack_api/query.py:14: DeprecationWarning: invalid escape sequence '\d'
  LIMIT_EXPRESSION = re.compile("(?P<limit>limit (?P<value>\d+))")
/usr/local/lib/python3.11/site-packages/pyparsing.py:108: DeprecationWarning: module 'sre_constants' is deprecated
  import sre_constants
/usr/local/lib/python3.11/site-packages/ftrack_api/plugin.py:32: DeprecationWarning: invalid escape sequence '\*'
  """Find and load plugins in search *paths*.
/usr/local/lib/python3.11/site-packages/ftrack_api/structure/standard.py:133: DeprecationWarning: invalid escape sequence '\w'
  "[^\w\.-]", self.illegal_character_substitute, value.decode("utf-8")

Those aren't the only problematic strings in the codebase. Somewhat crude regexp grep of the codebase yields the following:

test/unit/test_plugin.py
73:    output = re.sub("(\w+)=\w+", '"\g<1>={}".format(\g<1>)', specification)
74:    output = re.sub("\*args", "args", output)
75:    output = re.sub("\*\*kwargs", "sorted(kwargs.items())", output)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants