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

DeprecationWarning with Python 3.11 #90

Closed
pathawks opened this issue Mar 29, 2023 · 2 comments · Fixed by #92
Closed

DeprecationWarning with Python 3.11 #90

pathawks opened this issue Mar 29, 2023 · 2 comments · Fixed by #92
Labels
bug Something isn't working

Comments

@pathawks
Copy link

Describe the bug
This regular expression generates a DeprecationWarning on Python 3.11.

To Reproduce

  1. Install Python 3.11
  2. Run pytest
  3. Observe warning

Expected behavior
No warnings.

Desktop (please complete the following information):

  • OS: Ubuntu
  • Version: 22.04.2 LTS

Additional context
I believe the fix should be as simple as removing the backslash. Making this change and running pytest gives me 107 passing tests and no warnings.

-                     + re.sub("[^a-z0-9_\-]", "", item.lower().replace(" ", "-"))
+                     + re.sub("[^a-z0-9_-]", "", item.lower().replace(" ", "-"))
@pathawks pathawks added the bug Something isn't working label Mar 29, 2023
@didix21
Copy link
Owner

didix21 commented Mar 30, 2023

Can you provide the warning?

@pathawks
Copy link
Author

$ pytest
========================================== test session starts ===========================================
platform linux -- Python 3.11.0, pytest-7.2.2, pluggy-1.0.0
rootdir: /home/phawks/github/mdutils
collected 107 items                                                                                      

tests/test_mdutils.py .............................                                                [ 27%]
tests/test_fileutils/test_fileutils.py ........                                                    [ 34%]
tests/test_tools/test_header.py .........                                                          [ 42%]
tests/test_tools/test_html.py ...............                                                      [ 57%]
tests/test_tools/test_image.py .....                                                               [ 61%]
tests/test_tools/test_inline.py .....                                                              [ 66%]
tests/test_tools/test_mdcheckbox.py .....                                                          [ 71%]
tests/test_tools/test_mdlist.py ......                                                             [ 76%]
tests/test_tools/test_reference.py .......                                                         [ 83%]
tests/test_tools/test_table.py ....                                                                [ 86%]
tests/test_tools/test_table_of_contents.py .....                                                   [ 91%]
tests/test_tools/test_textutils.py .........                                                       [100%]

============================================ warnings summary ============================================
tests/test_mdutils.py:119
  /home/phawks/github/mdutils/tests/test_mdutils.py:119: DeprecationWarning: invalid escape sequence '\-'
    + re.sub("[^a-z0-9_\-]", "", list_headers[0].lower().replace(" ", "-"))

tests/test_mdutils.py:124
  /home/phawks/github/mdutils/tests/test_mdutils.py:124: DeprecationWarning: invalid escape sequence '\-'
    + re.sub("[^a-z0-9_\-]", "", list_headers[2].lower().replace(" ", "-"))

tests/test_mdutils.py:168
  /home/phawks/github/mdutils/tests/test_mdutils.py:168: DeprecationWarning: invalid escape sequence '\-'
    "[^a-z0-9_\-]", "", list_headers[x].lower().replace(" ", "-")

tests/test_mdutils.py:178
  /home/phawks/github/mdutils/tests/test_mdutils.py:178: DeprecationWarning: invalid escape sequence '\-'
    "[^a-z0-9_\-]", "", list_headers[x].lower().replace(" ", "-")

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
==================================== 107 passed, 4 warnings in 0.13s =====================================

didix21 pushed a commit that referenced this issue Apr 21, 2023
@didix21 didix21 linked a pull request Apr 21, 2023 that will close this issue
didix21 pushed a commit that referenced this issue Apr 21, 2023
- Upgrade ubuntu machine.
didix21 pushed a commit that referenced this issue Apr 21, 2023
- Upgrade ubuntu machine.
didix21 pushed a commit that referenced this issue Apr 21, 2023
- Upgrade ubuntu machine.
didix21 pushed a commit that referenced this issue Apr 21, 2023
- Upgrade ubuntu machine.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants