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

Switch from docopt to docopt-ng #454

Merged
merged 2 commits into from
Nov 21, 2024
Merged

Conversation

maxwell-k
Copy link
Contributor

@maxwell-k maxwell-k commented Nov 17, 2024

Running dotdrop under recent releases of Python — 3.12 and 3.13 — outputs syntax warnings from the docopt module.

Output with syntax warnings on Python 3.12 and 3.13

Command to run dotdrop with Python 3.12:

rm -rf ~/.cache/uv \
&& ~/.local/bin/uv tool run --python=python3.12 dotdrop install --profile=default

Output:

   Built docopt==0.6.2
Installed 15 packages in 7ms
/home/maxwell-k/.cache/uv/archive-v0/IhmhuswofFs7ywBBC0kJs/lib64/python3.12/site-packages/docopt.py:165: SyntaxWarning: invalid escape sequence '\S'
  name = re.findall('(<\S*?>)', source)[0]
/home/maxwell-k/.cache/uv/archive-v0/IhmhuswofFs7ywBBC0kJs/lib64/python3.12/site-packages/docopt.py:166: SyntaxWarning: invalid escape sequence '\['
  value = re.findall('\[default: (.*)\]', source, flags=re.I)
/home/maxwell-k/.cache/uv/archive-v0/IhmhuswofFs7ywBBC0kJs/lib64/python3.12/site-packages/docopt.py:207: SyntaxWarning: invalid escape sequence '\['
  matched = re.findall('\[default: (.*)\]', description, flags=re.I)
/home/maxwell-k/.cache/uv/archive-v0/IhmhuswofFs7ywBBC0kJs/lib64/python3.12/site-packages/docopt.py:456: SyntaxWarning: invalid escape sequence '\S'
  split = re.split('\n *(<\S+?>|-\S+?)', doc)[1:]
     _       _      _
  __| | ___ | |_ __| |_ __ ___  _ __
 / _` |/ _ \| __/ _` | '__/ _ \| '_ |
 \__,_|\___/ \__\__,_|_|  \___/| .__/  v1.14.2
                               |_|

0 dotfile(s) installed.

The output is similar using python3.13.

docopt hasn't had a release to PyPI in 10 years. No wheels are published to PyPI. docopt is used throughout the dotdrop code base. Advice online suggests adopting docopt-ng instead.

Running dotdrop under recent releases of Python — 3.12 and 3.13 — [outputs
syntax warnings] when from the docopt module.

[outputs syntax warnings]:
  https://docs.python.org/3/whatsnew/3.12.html#other-language-changes

<details>

<summary>Output with syntax warnings on Python 3.12 and 3.13</summary>

Command to run `dotdrop` with Python 3.12:

    rm -rf ~/.cache/uv \
    && ~/.local/bin/uv tool run --python=python3.12 dotdrop install --profile=default

Output:

```
   Built docopt==0.6.2
Installed 15 packages in 7ms
/home/maxwell-k/.cache/uv/archive-v0/IhmhuswofFs7ywBBC0kJs/lib64/python3.12/site-packages/docopt.py:165: SyntaxWarning: invalid escape sequence '\S'
  name = re.findall('(<\S*?>)', source)[0]
/home/maxwell-k/.cache/uv/archive-v0/IhmhuswofFs7ywBBC0kJs/lib64/python3.12/site-packages/docopt.py:166: SyntaxWarning: invalid escape sequence '\['
  value = re.findall('\[default: (.*)\]', source, flags=re.I)
/home/maxwell-k/.cache/uv/archive-v0/IhmhuswofFs7ywBBC0kJs/lib64/python3.12/site-packages/docopt.py:207: SyntaxWarning: invalid escape sequence '\['
  matched = re.findall('\[default: (.*)\]', description, flags=re.I)
/home/maxwell-k/.cache/uv/archive-v0/IhmhuswofFs7ywBBC0kJs/lib64/python3.12/site-packages/docopt.py:456: SyntaxWarning: invalid escape sequence '\S'
  split = re.split('\n *(<\S+?>|-\S+?)', doc)[1:]
     _       _      _
  __| | ___ | |_ __| |_ __ ___  _ __
 / _` |/ _ \| __/ _` | '__/ _ \| '_ |
 \__,_|\___/ \__\__,_|_|  \___/| .__/  v1.14.2
                               |_|

0 dotfile(s) installed.
```

The output is similar using `python3.13`.

</details>

[docopt] hasn't had a [release to PyPI] in 10 years. [No wheels] are
published to PyPI. `docopt` is used throughout the [dotdrop] code base.
Advice online suggests adopting [docopt-ng] instead.

[docopt]: https://github.com/docopt/docopt
[no wheels]: docopt/docopt#502
[release to PyPI]: https://pypi.org/project/docopt/#history
[docopt-ng]: https://github.com/jazzband/docopt-ng
[dotdrop]: https://github.com/deadc0de6/dotdrop
@maxwell-k
Copy link
Contributor Author

maxwell-k commented Nov 17, 2024

At first I didn't notice #435 ; this pull request is effectively the same.

The syntax warnings appear in Python 3.12 and later. The relevant section of the Python 3.12 change log is:

A backslash-character pair that is not a valid escape sequence now generates a SyntaxWarning, instead of DeprecationWarning. For example, re.compile("\d+.\d+") now emits a SyntaxWarning ("\d" is an invalid escape sequence, use raw strings for regular expression: re.compile(r"\d+.\d+")). In a future Python version, SyntaxError will eventually be raised, instead of SyntaxWarning. (Contributed by Victor Stinner in gh-98401.)

A example syntax warning, output when using dotdrop is:

✂/python3.12/site-packages/docopt.py:165: SyntaxWarning: invalid escape sequence '\S'

I'm not sure about changing the PKGBUILD files; they do not appear to be up to date with recent releases of dotdrop. I include changes here so that this PR contains everything from #435.

Copy link

codecov bot commented Nov 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.77%. Comparing base (f50f3ec) to head (59c7c95).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #454      +/-   ##
==========================================
- Coverage   90.83%   90.77%   -0.07%     
==========================================
  Files          23       23              
  Lines        4780     4780              
==========================================
- Hits         4342     4339       -3     
- Misses        438      441       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

@deadc0de6 deadc0de6 merged commit dd062f2 into deadc0de6:master Nov 21, 2024
9 checks passed
@deadc0de6
Copy link
Owner

@maxwell-k thanks a lot for this and for the explanations!

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

Successfully merging this pull request may close these issues.

2 participants