-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
Formatting isn't applied across the whole file #302
Comments
Yeah, I can't really spot why the final block isn't being picked up. Could you minimize the file down to the smallest failing example? That would probably reveal the problem. |
@adamchainz First off, thanks for getting back to me so quickly, and sorry for taking so long to reply! Kept slipping my mind. Second, it looks like the issue is actually more significant. Here's a fairly minimal file, import operator
def accumulate(iterable, func=operator.add, *, initial=None):
"""Returns running totals.
```pycon
>>> def mul(a, b):
... '''Return ``a * b``, for *a* and *b* numbers.'''
... return a * b
...
>>> list(accumulate([1, 2, 3, 4, 5], mul))
[1, 2, 6, 24, 120]
```
"""
it = iter(iterable)
total = initial
if initial is None:
try:
total = next(it)
except StopIteration:
return
yield total
for element in it:
total = func(total, element)
yield total
def accumulate2(iterable, func=operator.add, *, initial=None):
"""Returns running totals.
```pycon
>>> def mul(a, b):
... '''Return ``a * b``, for *a* and *b* numbers.'''
... return a * b
...
>>> list(accumulate([1, 2, 3, 4, 5], mul))
[1, 2, 6, 24, 120]
```
"""
return accumulate(iterable, func, initial=initial) (It works; Once again, diff --git a/foo.py b/foo.py
index 4434688d7..2bf750329 100644
--- a/foo.py
+++ b/foo.py
@@ -6,7 +6,7 @@ def accumulate(iterable, func=operator.add, *, initial=None):
```pycon
>>> def mul(a, b):
- ... '''Return ``a * b``, for *a* and *b* numbers.'''
+ ... """Return ``a * b``, for *a* and *b* numbers."""
... return a * b
...
>>> list(accumulate([1, 2, 3, 4, 5], mul)) Without having debugged it, or having bothered to look into how |
I think I just fixed the “rest of the file” bug in #347. But the docstring is still being left in a broken state, and that isn't something we can easily prevent. The snippet passed to Black has no context that it's in a docstring, and I don't fancy trying to fix it up after the fact. Perhaps we should have a guard for |
Python Version
3.10.11
Package Version
1.16.0
Description
When I format https://github.com/deepyaman/ibis/blob/build/blacken-docs-issue/ibis/expr/operations/udf.py using
blacken-docs
, only one code block seems to be getting parsed:I would expect all of the remaining code blocks to also get formatted (similar issues with missing blank line and docstring quoting).
The text was updated successfully, but these errors were encountered: