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

fix: runpy.run_path(path) crashes with pathlib.Path #1819

Merged
merged 8 commits into from
Jul 19, 2024

Conversation

askhl
Copy link
Contributor

@askhl askhl commented Jul 18, 2024

I ran into the following problem where coverage replaces runpy.run_path() in a way that does not accept Path objects:

import runpy

script = "print('hello, world!')\n"

def test_path(tmp_path):
    pyfile = tmp_path / 'script.py'
    pyfile.write_text(script)
    runpy.run_path(pyfile)

This passes with ordinary pytest but crashes with pytest --cov with the following traceback:

Traceback (most recent call last):
  File "/home/askhl/install/pyenv/lib/python3.10/site-packages/_pytest/runner.py", line 341, in from_call
    result: Optional[TResult] = func()
  File "/home/askhl/install/pyenv/lib/python3.10/site-packages/flaky/flaky_pytest_plugin.py", line 146, in <lambda>
    lambda: ihook(item=item, **kwds), when=when, reraise=reraise
  File "/home/askhl/install/pyenv/lib/python3.10/site-packages/pluggy/_hooks.py", line 513, in __call__
    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
  File "/home/askhl/install/pyenv/lib/python3.10/site-packages/pluggy/_manager.py", line 120, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File "/home/askhl/install/pyenv/lib/python3.10/site-packages/pluggy/_callers.py", line 182, in _multicall
    return outcome.get_result()
  File "/home/askhl/install/pyenv/lib/python3.10/site-packages/pluggy/_result.py", line 100, in get_result
    raise exc.with_traceback(exc.__traceback__)
  File "/home/askhl/install/pyenv/lib/python3.10/site-packages/pluggy/_callers.py", line 103, in _multicall
    res = hook_impl.function(*args)
  File "/home/askhl/install/pyenv/lib/python3.10/site-packages/_pytest/runner.py", line 177, in pytest_runtest_call
    raise e
  File "/home/askhl/install/pyenv/lib/python3.10/site-packages/_pytest/runner.py", line 169, in pytest_runtest_call
    item.runtest()
  File "/home/askhl/install/pyenv/lib/python3.10/site-packages/_pytest/python.py", line 1792, in runtest
    self.ihook.pytest_pyfunc_call(pyfuncitem=self)
  File "/home/askhl/install/pyenv/lib/python3.10/site-packages/pluggy/_hooks.py", line 513, in __call__
    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
  File "/home/askhl/install/pyenv/lib/python3.10/site-packages/pluggy/_manager.py", line 120, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File "/home/askhl/install/pyenv/lib/python3.10/site-packages/pluggy/_callers.py", line 139, in _multicall
    raise exception.with_traceback(exception.__traceback__)
  File "/home/askhl/install/pyenv/lib/python3.10/site-packages/pluggy/_callers.py", line 103, in _multicall
    res = hook_impl.function(*args)
  File "/home/askhl/install/pyenv/lib/python3.10/site-packages/_pytest/python.py", line 194, in pytest_pyfunc_call
    result = testfunction(**testargs)
  File "/home/askhl/coverage-runpy/test.py", line 11, in test_path
    runpy.run_path(pyfile)
  File "/usr/lib/python3.10/runpy.py", line 289, in run_path
    return _run_module_code(code, init_globals, run_name,
  File "/usr/lib/python3.10/runpy.py", line 96, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/askhl/src/coveragepy/coverage/control.py", line 395, in _should_trace
    disp = self._inorout.should_trace(filename, frame)
  File "/home/askhl/src/coveragepy/coverage/inorout.py", line 324, in should_trace
    filename = source_for_file(dunder_file)
  File "/home/askhl/src/coveragepy/coverage/python.py", line 107, in source_for_file
    if filename.endswith(".py"):
AttributeError: 'PosixPath' object has no attribute 'endswith'

This PR contains a minimal fix which sends the input through str(Path(...)). However a proper fix might require some awareness of the surrounding code as well as a test, so I'd expect the PR in its current form to be insufficient. Feedback would be appreciated.

@nedbat
Copy link
Owner

nedbat commented Jul 18, 2024

Thanks, I see there is a problem. I'd want to understand the full call stack to know where I should be accepting Path|str instead of just str.

@askhl
Copy link
Contributor Author

askhl commented Jul 18, 2024

Thanks @nedbat!

It crossed my mind that it could originate with pytest or pytest-cov, since there's something finicky going on between runpy and the code object that could originate from some out-of-sight hook. I reproduced it now with only coverage run:

import runpy
from pathlib import Path

script = "print('hello, world!')\n"
pyfile = Path('script.py')
pyfile.write_text(script)
runpy.run_path(pyfile)

This yields the considerably shorter stacktrace

(pyenv) askhl@alberich:~/coverage-runpy$ coverage run test.py 
Traceback (most recent call last):
  File "/home/askhl/coverage-runpy/test.py", line 8, in <module>
    runpy.run_path(pyfile)
  File "/usr/lib/python3.10/runpy.py", line 289, in run_path
    return _run_module_code(code, init_globals, run_name,
  File "/usr/lib/python3.10/runpy.py", line 96, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/askhl/src/coveragepy/coverage/control.py", line 395, in _should_trace
    disp = self._inorout.should_trace(filename, frame)
  File "/home/askhl/src/coveragepy/coverage/inorout.py", line 324, in should_trace
    filename = source_for_file(dunder_file)
  File "/home/askhl/src/coveragepy/coverage/python.py", line 107, in source_for_file
    if filename.endswith(".py"):
AttributeError: 'PosixPath' object has no attribute 'endswith'

After some messing around I found that usually the function receives a str, but it receives a Path('script.py') when it does dunder_file = frame.f_globals and frame.f_globals.get("__file__").

I pushed a change inserting a conversion there instead of in the previous place.

So that fix will equally well solve the problem without the need to think about Path|str in multiple places, and hence is a more credible fix.

But I don't know if there's any documentation that could reveal what types frame.f_globals.get('__file__') should have.

@nedbat
Copy link
Owner

nedbat commented Jul 18, 2024

It crossed my mind that it could originate with pytest or pytest-cov

No worries, when a bug report mentions pytest-cov, the first thing I do is try to reproduce it without it. I also saw it with just coverage run.

I like the latest change: it feels like the right place.

Do you want to add yourself to CONTRIBUTORS and add a changelog entry? I can take care of it if you like.

@askhl askhl marked this pull request as ready for review July 18, 2024 23:02
@askhl
Copy link
Contributor Author

askhl commented Jul 18, 2024

I have added a test in what I perceive to be a reasonably correct place.

Do you want to add yourself to CONTRIBUTORS and add a changelog entry? I can take care of it if you like.

Thanks. Since the list of unreleased changes is empty, I was not sure whether to add a note before or after .. scriv-start-here, or whether that's necessarily the correct place. Please make any changes you think appropriate.

@askhl
Copy link
Contributor Author

askhl commented Jul 19, 2024

I just pushed a lint-fixing change but you have apparently already done something about it. Feel free to ignore/adapt/close this.

I am not sure whether this should actually be considered an issue with runpy. The docs (https://docs.python.org/3/reference/import.html#file__) say rather clearly that __file__ should be str if it exists.

Thanks a lot!

@nedbat
Copy link
Owner

nedbat commented Jul 19, 2024

I also beefed up the test a bit in askhl#1. You can merge that pull request to get my changes.

@askhl askhl force-pushed the fix-runpy-pathlib branch from 9c4c2e5 to ecf9ccf Compare July 19, 2024 17:03
@askhl
Copy link
Contributor Author

askhl commented Jul 19, 2024

I also beefed up the test a bit in askhl#1. You can merge that pull request to get my changes.

Nice. It's merged.

@nedbat nedbat merged commit 7fb846e into nedbat:master Jul 19, 2024
35 checks passed
@nedbat
Copy link
Owner

nedbat commented Jul 19, 2024

Thanks!

@askhl askhl deleted the fix-runpy-pathlib branch July 19, 2024 17:31
@nedbat
Copy link
Owner

nedbat commented Aug 4, 2024

This is now released as part of coverage 7.6.1.

github-merge-queue bot referenced this pull request in rustymotors/server Aug 4, 2024
[![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://togithub.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://togithub.com/nedbat/coveragepy/blob/HEAD/CHANGES.rst#Version-761--2024-08-04)

[Compare
Source](https://togithub.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://togithub.com/nedbat/coveragepy/pull/1819)9
.. \_pull
1828[https://github.com/nedbat/coveragepy/pull/1828](https://togithub.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-->
renovate bot referenced this pull request in allenporter/flux-local Aug 5, 2024
[![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://togithub.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://togithub.com/nedbat/coveragepy/blob/HEAD/CHANGES.rst#Version-761--2024-08-04)

[Compare
Source](https://togithub.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://togithub.com/nedbat/coveragepy/pull/1819)9
.. \_pull
1828[https://github.com/nedbat/coveragepy/pull/1828](https://togithub.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>
fritterhoff referenced this pull request in eduMFA/eduMFA Aug 5, 2024
[![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://togithub.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://togithub.com/nedbat/coveragepy/blob/HEAD/CHANGES.rst#Version-761--2024-08-04)

[Compare
Source](https://togithub.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://togithub.com/nedbat/coveragepy/pull/1819)9
.. \_pull
1828[https://github.com/nedbat/coveragepy/pull/1828](https://togithub.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>
ddl-joy-liao referenced this pull request in dominodatalab/cucu Aug 6, 2024
[![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://togithub.com/psf/black)
([changelog](https://togithub.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://togithub.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://togithub.com/astral-sh/ruff),
[changelog](https://togithub.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://togithub.com/psf/black/blob/HEAD/CHANGES.md#2480)

[Compare Source](https://togithub.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. ([#&#8203;4363](https://togithub.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.
([#&#8203;4345](https://togithub.com/psf/black/issues/4345))

##### Parser

- Fix regression where Black failed to parse a multiline f-string
containing another
multiline string
([#&#8203;4339](https://togithub.com/psf/black/issues/4339))
- Fix regression where Black failed to parse an escaped single quote
inside an f-string
    ([#&#8203;4401](https://togithub.com/psf/black/issues/4401))
- Fix bug with Black incorrectly parsing empty lines with a backslash
([#&#8203;4343](https://togithub.com/psf/black/issues/4343))
- Fix bugs with Black's tokenizer not handling `\{` inside f-strings
very well ([#&#8203;4422](https://togithub.com/psf/black/issues/4422))
- Fix incorrect line numbers in the tokenizer for certain tokens within
f-strings
    ([#&#8203;4423](https://togithub.com/psf/black/issues/4423))

##### Performance

- Improve performance when a large directory is listed in `.gitignore`
([#&#8203;4415](https://togithub.com/psf/black/issues/4415))

##### *Blackd*

- Fix blackd (and all extras installs) for docker container
([#&#8203;4357](https://togithub.com/psf/black/issues/4357))

</details>

<details>
<summary>nedbat/coveragepy (coverage)</summary>

###
[`v7.6.1`](https://togithub.com/nedbat/coveragepy/blob/HEAD/CHANGES.rst#Version-761--2024-08-04)

[Compare
Source](https://togithub.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://togithub.com/nedbat/coveragepy/pull/1819)9
.. \_pull
1828[https://github.com/nedbat/coveragepy/pull/1828](https://togithub.com/nedbat/coveragepy/pull/1828)28

.. \_changes\_7-6-0:

</details>

<details>
<summary>astral-sh/ruff (ruff)</summary>

###
[`v0.5.6`](https://togithub.com/astral-sh/ruff/blob/HEAD/CHANGELOG.md#056)

[Compare
Source](https://togithub.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
([#&#8203;12621](https://togithub.com/astral-sh/ruff/pull/12621))
- \[`flake8-builtins`] Implement import, lambda, and module shadowing
([#&#8203;12546](https://togithub.com/astral-sh/ruff/pull/12546))
- \[`pydoclint`] Add `docstring-missing-returns` (`DOC201`) and
`docstring-extraneous-returns` (`DOC202`)
([#&#8203;12485](https://togithub.com/astral-sh/ruff/pull/12485))

##### Rule changes

- \[`flake8-return`] Exempt cached properties and other property-like
decorators from explicit return rule (`RET501`)
([#&#8203;12563](https://togithub.com/astral-sh/ruff/pull/12563))

##### Server

- Make server panic hook more error resilient
([#&#8203;12610](https://togithub.com/astral-sh/ruff/pull/12610))
- Use `$/logTrace` for server trace logs in Zed and VS Code
([#&#8203;12564](https://togithub.com/astral-sh/ruff/pull/12564))
- Keep track of deleted cells for reorder change request
([#&#8203;12575](https://togithub.com/astral-sh/ruff/pull/12575))

##### Configuration

- \[`flake8-implicit-str-concat`] Always allow explicit multi-line
concatenations when implicit concatenations are banned
([#&#8203;12532](https://togithub.com/astral-sh/ruff/pull/12532))

##### Bug fixes

- \[`flake8-async`] Avoid flagging `asyncio.timeout`s as unused when the
context manager includes `asyncio.TaskGroup`
([#&#8203;12605](https://togithub.com/astral-sh/ruff/pull/12605))
- \[`flake8-slots`] Avoid recommending `__slots__` for classes that
inherit from more than `namedtuple`
([#&#8203;12531](https://togithub.com/astral-sh/ruff/pull/12531))
- \[`isort`] Avoid marking required imports as unused
([#&#8203;12537](https://togithub.com/astral-sh/ruff/pull/12537))
- \[`isort`] Preserve trailing inline comments on import-from statements
([#&#8203;12498](https://togithub.com/astral-sh/ruff/pull/12498))
- \[`pycodestyle`] Add newlines before comments (`E305`)
([#&#8203;12606](https://togithub.com/astral-sh/ruff/pull/12606))
- \[`pycodestyle`] Don't attach comments with mismatched indents
([#&#8203;12604](https://togithub.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
([#&#8203;12569](https://togithub.com/astral-sh/ruff/pull/12569))
- \[`pylint`] Respect start index in `unnecessary-list-index-lookup`
([#&#8203;12603](https://togithub.com/astral-sh/ruff/pull/12603))
- \[`pyupgrade`] Avoid recommending no-argument super in `slots=True`
dataclasses
([#&#8203;12530](https://togithub.com/astral-sh/ruff/pull/12530))
- \[`pyupgrade`] Use colon rather than dot formatting for integer-only
types ([#&#8203;12534](https://togithub.com/astral-sh/ruff/pull/12534))
- Fix NFKC normalization bug when removing unused imports
([#&#8203;12571](https://togithub.com/astral-sh/ruff/pull/12571))

##### Other changes

- Consider more stdlib decorators to be property-like
([#&#8203;12583](https://togithub.com/astral-sh/ruff/pull/12583))
- Improve handling of metaclasses in various linter rules
([#&#8203;12579](https://togithub.com/astral-sh/ruff/pull/12579))
- Improve consistency between linter rules in determining whether a
function is property
([#&#8203;12581](https://togithub.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://togithub.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>
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