-
-
Notifications
You must be signed in to change notification settings - Fork 436
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
Fix incorrect backslash before multi-lines string #1828
Conversation
@nedbat Hi,do you have time to take a kook at this PR? Thanks. |
I will take a look, but it might take me some time. |
BTW, what name should I use for the Changelog and Contributors files? |
This is now released as part of coverage 7.6.1. |
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [coverage](https://github.com/nedbat/coveragepy) | `==7.6.0` -> `==7.6.1` | [![age](https://developer.mend.io/api/mc/badges/age/pypi/coverage/7.6.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/pypi/coverage/7.6.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/pypi/coverage/7.6.0/7.6.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/pypi/coverage/7.6.0/7.6.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>nedbat/coveragepy (coverage)</summary> ### [`v7.6.1`](https://github.com/nedbat/coveragepy/blob/HEAD/CHANGES.rst#Version-761--2024-08-04) [Compare Source](https://github.com/nedbat/coveragepy/compare/7.6.0...7.6.1) - Fix: coverage used to fail when measuring code using :func:`runpy.run_path <python:runpy.run_path>` with a :class:`Path <python:pathlib.Path>` argument. This is now fixed, thanks to `Ask Hjorth Larsen <pull 1819_>`\_. - Fix: backslashes preceding a multi-line backslashed string could confuse the HTML report. This is now fixed, thanks to `LiuYinCarl <pull 1828_>`\_. - Now we publish wheels for Python 3.13, both regular and free-threaded. .. \_pull 1819:[https://github.com/nedbat/coveragepy/pull/1819](https://github.com/nedbat/coveragepy/pull/1819)9 .. \_pull 1828[https://github.com/nedbat/coveragepy/pull/1828](https://github.com/nedbat/coveragepy/pull/1828)28 .. \_changes\_7-6-0: </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View the [repository job log](https://developer.mend.io/github/rustymotors/server-old). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40NDAuNyIsInVwZGF0ZWRJblZlciI6IjM3LjQ0MC43IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [coverage](https://github.com/nedbat/coveragepy) | `==7.6.0` -> `==7.6.1` | [![age](https://developer.mend.io/api/mc/badges/age/pypi/coverage/7.6.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/pypi/coverage/7.6.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/pypi/coverage/7.6.0/7.6.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/pypi/coverage/7.6.0/7.6.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>nedbat/coveragepy (coverage)</summary> ### [`v7.6.1`](https://github.com/nedbat/coveragepy/blob/HEAD/CHANGES.rst#Version-761--2024-08-04) [Compare Source](https://github.com/nedbat/coveragepy/compare/7.6.0...7.6.1) - Fix: coverage used to fail when measuring code using :func:`runpy.run_path <python:runpy.run_path>` with a :class:`Path <python:pathlib.Path>` argument. This is now fixed, thanks to `Ask Hjorth Larsen <pull 1819_>`\_. - Fix: backslashes preceding a multi-line backslashed string could confuse the HTML report. This is now fixed, thanks to `LiuYinCarl <pull 1828_>`\_. - Now we publish wheels for Python 3.13, both regular and free-threaded. .. \_pull 1819:[https://github.com/nedbat/coveragepy/pull/1819](https://github.com/nedbat/coveragepy/pull/1819)9 .. \_pull 1828[https://github.com/nedbat/coveragepy/pull/1828](https://github.com/nedbat/coveragepy/pull/1828)28 .. \_changes\_7-6-0: </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View the [repository job log](https://developer.mend.io/github/allenporter/flux-local). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40NDAuNyIsInVwZGF0ZWRJblZlciI6IjM3LjQ0MC43IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [test/coverage](https://github.com/nedbat/coveragepy) | `==7.6.0` -> `==7.6.1` | [![age](https://developer.mend.io/api/mc/badges/age/pypi/test%2fcoverage/7.6.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/pypi/test%2fcoverage/7.6.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/pypi/test%2fcoverage/7.6.0/7.6.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/pypi/test%2fcoverage/7.6.0/7.6.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>nedbat/coveragepy (test/coverage)</summary> ### [`v7.6.1`](https://github.com/nedbat/coveragepy/blob/HEAD/CHANGES.rst#Version-761--2024-08-04) [Compare Source](https://github.com/nedbat/coveragepy/compare/7.6.0...7.6.1) - Fix: coverage used to fail when measuring code using :func:`runpy.run_path <python:runpy.run_path>` with a :class:`Path <python:pathlib.Path>` argument. This is now fixed, thanks to `Ask Hjorth Larsen <pull 1819_>`\_. - Fix: backslashes preceding a multi-line backslashed string could confuse the HTML report. This is now fixed, thanks to `LiuYinCarl <pull 1828_>`\_. - Now we publish wheels for Python 3.13, both regular and free-threaded. .. \_pull 1819:[https://github.com/nedbat/coveragepy/pull/1819](https://github.com/nedbat/coveragepy/pull/1819)9 .. \_pull 1828[https://github.com/nedbat/coveragepy/pull/1828](https://github.com/nedbat/coveragepy/pull/1828)28 .. \_changes\_7-6-0: </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View the [repository job log](https://developer.mend.io/github/eduMFA/eduMFA). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40NDAuNyIsInVwZGF0ZWRJblZlciI6IjM3LjQ0MC43IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---|---|---| | | | lockFileMaintenance | All locks refreshed | | | | | | [black](https://github.com/psf/black) ([changelog](https://github.com/psf/black/blob/main/CHANGES.md)) | dev | minor | `24.4.2` -> `24.8.0` | [![age](https://developer.mend.io/api/mc/badges/age/pypi/black/24.8.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/pypi/black/24.8.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/pypi/black/24.4.2/24.8.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/pypi/black/24.4.2/24.8.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | | [coverage](https://github.com/nedbat/coveragepy) | dependencies | patch | `7.6.0` -> `7.6.1` | [![age](https://developer.mend.io/api/mc/badges/age/pypi/coverage/7.6.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/pypi/coverage/7.6.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/pypi/coverage/7.6.0/7.6.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/pypi/coverage/7.6.0/7.6.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | | [ruff](https://docs.astral.sh/ruff) ([source](https://github.com/astral-sh/ruff), [changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md)) | dev | patch | `0.5.5` -> `0.5.6` | [![age](https://developer.mend.io/api/mc/badges/age/pypi/ruff/0.5.6?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/pypi/ruff/0.5.6?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/pypi/ruff/0.5.5/0.5.6?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/pypi/ruff/0.5.5/0.5.6?slim=true)](https://docs.renovatebot.com/merge-confidence/) | 🔧 This Pull Request updates lock files to use the latest dependency versions. --- ### Release Notes <details> <summary>psf/black (black)</summary> ### [`v24.8.0`](https://github.com/psf/black/blob/HEAD/CHANGES.md#2480) [Compare Source](https://github.com/psf/black/compare/24.4.2...24.8.0) ##### Stable style - Fix crash when `# fmt: off` is used before a closing parenthesis or bracket. ([#​4363](https://github.com/psf/black/issues/4363)) ##### Packaging - Packaging metadata updated: docs are explictly linked, the issue tracker is now also linked. This improves the PyPI listing for Black. ([#​4345](https://github.com/psf/black/issues/4345)) ##### Parser - Fix regression where Black failed to parse a multiline f-string containing another multiline string ([#​4339](https://github.com/psf/black/issues/4339)) - Fix regression where Black failed to parse an escaped single quote inside an f-string ([#​4401](https://github.com/psf/black/issues/4401)) - Fix bug with Black incorrectly parsing empty lines with a backslash ([#​4343](https://github.com/psf/black/issues/4343)) - Fix bugs with Black's tokenizer not handling `\{` inside f-strings very well ([#​4422](https://github.com/psf/black/issues/4422)) - Fix incorrect line numbers in the tokenizer for certain tokens within f-strings ([#​4423](https://github.com/psf/black/issues/4423)) ##### Performance - Improve performance when a large directory is listed in `.gitignore` ([#​4415](https://github.com/psf/black/issues/4415)) ##### *Blackd* - Fix blackd (and all extras installs) for docker container ([#​4357](https://github.com/psf/black/issues/4357)) </details> <details> <summary>nedbat/coveragepy (coverage)</summary> ### [`v7.6.1`](https://github.com/nedbat/coveragepy/blob/HEAD/CHANGES.rst#Version-761--2024-08-04) [Compare Source](https://github.com/nedbat/coveragepy/compare/7.6.0...7.6.1) - Fix: coverage used to fail when measuring code using :func:`runpy.run_path <python:runpy.run_path>` with a :class:`Path <python:pathlib.Path>` argument. This is now fixed, thanks to `Ask Hjorth Larsen <pull 1819_>`\_. - Fix: backslashes preceding a multi-line backslashed string could confuse the HTML report. This is now fixed, thanks to `LiuYinCarl <pull 1828_>`\_. - Now we publish wheels for Python 3.13, both regular and free-threaded. .. \_pull 1819:[https://github.com/nedbat/coveragepy/pull/1819](https://github.com/nedbat/coveragepy/pull/1819)9 .. \_pull 1828[https://github.com/nedbat/coveragepy/pull/1828](https://github.com/nedbat/coveragepy/pull/1828)28 .. \_changes\_7-6-0: </details> <details> <summary>astral-sh/ruff (ruff)</summary> ### [`v0.5.6`](https://github.com/astral-sh/ruff/blob/HEAD/CHANGELOG.md#056) [Compare Source](https://github.com/astral-sh/ruff/compare/0.5.5...0.5.6) Ruff 0.5.6 automatically enables linting and formatting of notebooks in *preview mode*. You can opt-out of this behavior by adding `*.ipynb` to the `extend-exclude` setting. ```toml [tool.ruff] extend-exclude = ["*.ipynb"] ``` ##### Preview features - Enable notebooks by default in preview mode ([#​12621](https://github.com/astral-sh/ruff/pull/12621)) - \[`flake8-builtins`] Implement import, lambda, and module shadowing ([#​12546](https://github.com/astral-sh/ruff/pull/12546)) - \[`pydoclint`] Add `docstring-missing-returns` (`DOC201`) and `docstring-extraneous-returns` (`DOC202`) ([#​12485](https://github.com/astral-sh/ruff/pull/12485)) ##### Rule changes - \[`flake8-return`] Exempt cached properties and other property-like decorators from explicit return rule (`RET501`) ([#​12563](https://github.com/astral-sh/ruff/pull/12563)) ##### Server - Make server panic hook more error resilient ([#​12610](https://github.com/astral-sh/ruff/pull/12610)) - Use `$/logTrace` for server trace logs in Zed and VS Code ([#​12564](https://github.com/astral-sh/ruff/pull/12564)) - Keep track of deleted cells for reorder change request ([#​12575](https://github.com/astral-sh/ruff/pull/12575)) ##### Configuration - \[`flake8-implicit-str-concat`] Always allow explicit multi-line concatenations when implicit concatenations are banned ([#​12532](https://github.com/astral-sh/ruff/pull/12532)) ##### Bug fixes - \[`flake8-async`] Avoid flagging `asyncio.timeout`s as unused when the context manager includes `asyncio.TaskGroup` ([#​12605](https://github.com/astral-sh/ruff/pull/12605)) - \[`flake8-slots`] Avoid recommending `__slots__` for classes that inherit from more than `namedtuple` ([#​12531](https://github.com/astral-sh/ruff/pull/12531)) - \[`isort`] Avoid marking required imports as unused ([#​12537](https://github.com/astral-sh/ruff/pull/12537)) - \[`isort`] Preserve trailing inline comments on import-from statements ([#​12498](https://github.com/astral-sh/ruff/pull/12498)) - \[`pycodestyle`] Add newlines before comments (`E305`) ([#​12606](https://github.com/astral-sh/ruff/pull/12606)) - \[`pycodestyle`] Don't attach comments with mismatched indents ([#​12604](https://github.com/astral-sh/ruff/pull/12604)) - \[`pyflakes`] Fix preview-mode bugs in `F401` when attempting to autofix unused first-party submodule imports in an `__init__.py` file ([#​12569](https://github.com/astral-sh/ruff/pull/12569)) - \[`pylint`] Respect start index in `unnecessary-list-index-lookup` ([#​12603](https://github.com/astral-sh/ruff/pull/12603)) - \[`pyupgrade`] Avoid recommending no-argument super in `slots=True` dataclasses ([#​12530](https://github.com/astral-sh/ruff/pull/12530)) - \[`pyupgrade`] Use colon rather than dot formatting for integer-only types ([#​12534](https://github.com/astral-sh/ruff/pull/12534)) - Fix NFKC normalization bug when removing unused imports ([#​12571](https://github.com/astral-sh/ruff/pull/12571)) ##### Other changes - Consider more stdlib decorators to be property-like ([#​12583](https://github.com/astral-sh/ruff/pull/12583)) - Improve handling of metaclasses in various linter rules ([#​12579](https://github.com/astral-sh/ruff/pull/12579)) - Improve consistency between linter rules in determining whether a function is property ([#​12581](https://github.com/astral-sh/ruff/pull/12581)) </details> --- ### Configuration 📅 **Schedule**: Branch creation - "before 4am on monday" in timezone America/Los_Angeles, Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://github.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View the [repository job log](https://developer.mend.io/github/cerebrotech/cucu). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40NDAuNyIsInVwZGF0ZWRJblZlciI6IjM4LjE4LjE3IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
I stumbled across this while reviewing #1838. I think the tests (and this fix) are incomplete. Lines 1134 to 1154 in dc819ff
In lines 1146–1154, you are testing whether the HTML output correctly reproduces the backslash in the coveragepy/tests/test_phystokens.py Lines 101 to 117 in dc819ff
Testing the same input, just with the tokenizer instead of the HTML report renderer. You can see in line 112 that there is a Concerning this pull request in general:
|
My apologies, I forgot to ping @nedbat, as the author of these tests. See also #1838 (comment) for a sample file-plus-coverage-output of a run which is correct according to (my reading of) the aforementioned test functions, despite misaligning coverage info later on in the file. Screenshot: |
I appreciate all the work you are doing. I'm trying to keep up! You said:
When I print the HTML created by this test, I see: <main id="source">
<p class="run"><span class="n"><a id="t1" href="#t1">1</a></span><span class="t"><span class="nam">a</span> <span class="op">=</span> <span class="op">[</span><span class="str">"aaa"</span><span class="op">,</span><span class="xx">\</span> </span><span class="r"></span></p>
<p class="pln"><span class="n"><a id="t2" href="#t2">2</a></span><span class="t"> <span class="str">"bbb \</span> </span><span class="r"></span></p>
<p class="pln"><span class="n"><a id="t3" href="#t3">3</a></span><span class="t"><span class="str"> ccc"</span><span class="op">]</span> </span><span class="r"></span></p>
</main> Line 1 ends with backslash, and is separate from line 2. Can you show me more specifically what you mean? |
@nedbat maybe it's because the code of @the-13th-letter contain a blank between "," and "\", I fix it in a1aa6b8 |
To help with these kinds of tests, I added a new helper to extract the rendered test from an HTML report in 9494ba7. |
Currently, the I'm going to be busy at
Sounds plausible. I'll try that out too on Saturday. |
I changed that this morning: now it makes an assertion about all of the rendered text. I hope we can write more tests using the same technique. |
Wonderful. I've taken the liberty of extending (Installing 3.8, 3.9, 3.10 or PyPy on my system – with development headers – is quite a pain, so I only checked 3.11 and 3.12.) (Yes, I know, GitHub has proper pull requests, but this would be a pull request on a pull request, and it feels a little overkill for something like this.) |
The PR is used to fix incorrect backslash before multi-lines string which will result in incorrect lines alignment.
Source code for test
Run commands
coverage run main.py coverage html cd htmlcov python3 -m http.server 9000