repo string | pull_number int64 | instance_id string | issue_numbers list | base_commit string | patch string | test_patch string | problem_statement string | hints_text string | created_at timestamp[ns, tz=UTC] | version float64 |
|---|---|---|---|---|---|---|---|---|---|---|
python-pillow/Pillow | 1,594 | python-pillow__Pillow-1594 | [
"1561"
] | 8d3b240096a2f9b888942a7a643ed4574e0edd09 | diff --git a/PIL/TiffImagePlugin.py b/PIL/TiffImagePlugin.py
--- a/PIL/TiffImagePlugin.py
+++ b/PIL/TiffImagePlugin.py
@@ -1277,8 +1277,10 @@ def _save(im, fp, filename):
except io.UnsupportedOperation:
pass
- # ICC Profile crashes.
- blocklist = [STRIPOFFSETS, STRIPBYTECOU... | diff --git a/Tests/test_file_libtiff.py b/Tests/test_file_libtiff.py
--- a/Tests/test_file_libtiff.py
+++ b/Tests/test_file_libtiff.py
@@ -165,6 +165,13 @@ def test_write_metadata(self):
self.assertEqual(
val, value, msg="%s didn't roundtrip" % tag)
+ #... | TIFF tags removed when using libtiff
My specific utilization of Pillow requires that I generate a TIFF image with G4 compression and provide at least the following tags; 256, 257, 259, 262, 273, 274, 278, 279, 282, and 283.
The following line in TiffImagePlugin.py specifies a list of tags to exclude from the file whe... | I took the liberty of removing "ROWSPERSTRIP" from the blocklist collection on my local environment and it appears to behave as expected, error free. Any additional information would be greatly appreciated.
IIRC, libtiff was supposed to be adding those tags based on how the library was doing the encoding.
ICCprofile... | 2015-12-14T20:44:33Z | 3 |
python-pillow/Pillow | 1,539 | python-pillow__Pillow-1539 | [
"1526"
] | def22c1d2724972ddb6d911aeaf699e7c00be724 | diff --git a/PIL/TiffTags.py b/PIL/TiffTags.py
--- a/PIL/TiffTags.py
+++ b/PIL/TiffTags.py
@@ -133,7 +133,7 @@ def cvt_enum(self, value):
# FIXME add more tags here
34665: ("ExifIFD", 3, 1),
- 34675: ('ICCProfile', 7, 1),
+ 34675: ('ICCProfile', 7, 0),
# MPInfo
45056: ("MPFVersion", 7, 1),... | diff --git a/Tests/images/hopper.iccprofile_binary.tif b/Tests/images/hopper.iccprofile_binary.tif
new file mode 100644
Binary files /dev/null and b/Tests/images/hopper.iccprofile_binary.tif differ
diff --git a/Tests/test_file_tiff_metadata.py b/Tests/test_file_tiff_metadata.py
--- a/Tests/test_file_tiff_metadata.py
++... | Not able to open tiff-file with Pillow (regression)
We encountered a tiff-file that Pillow failed to open in version 3.0.0, in version 2.9.0 it works just fine.
https://drive.google.com/a/greyrook.com/file/d/0Bypf_GpBFGxZU3A1QmsxQlRXVXc/view
on `Image.open(path)`: `IOError: cannot identify image file`
| I've encountered the same problem on OS X and Ubuntu 14.04 LTS.
It looks like the wheels distributed on PyPI were compiled on a machine without libtiff – if I install from source (`pip install --no-binary=all --no-use-wheel Pillow==3`) it works as expected.
@acdha Which platform is missing tiff in the distributed fil... | 2015-11-15T16:45:27Z | 3 |
python-pillow/Pillow | 1,401 | python-pillow__Pillow-1401 | [
"1399"
] | cc19ca496da4c08f226a78cfd184781eebcbafd9 | diff --git a/PIL/PpmImagePlugin.py b/PIL/PpmImagePlugin.py
--- a/PIL/PpmImagePlugin.py
+++ b/PIL/PpmImagePlugin.py
@@ -93,6 +93,8 @@ def _open(self):
s = self.fp.read(1)
if s not in b_whitespace:
break
+ if s == b"":
+ ... | diff --git a/Tests/test_file_ppm.py b/Tests/test_file_ppm.py
--- a/Tests/test_file_ppm.py
+++ b/Tests/test_file_ppm.py
@@ -35,6 +35,14 @@ def test_16bit_pgm_write(self):
reloaded = Image.open(f)
self.assert_image_equal(im, reloaded)
+ def test_truncated_file(self):
+ path = self.tempfile('... | Three "images" that cause PIL.Image.open() to hang
Hello,
Here's what I found with my early afl-fuzz fuzzing:
```
(virtualenv)[1/6][14:45:24][~/workspace/Pillow/pillow-virtualenv/o/hangs]$ for file in *; do hexdump -C $file; done
00000000 50 36 |P6|
00000002
00000000 50 3... | Hi. Thanks for reporting, but unfortunately I don't quite follow. Would you be able to post some Python code that reproduces the problem?
| 2015-08-28T15:25:01Z | 2.9 |
python-pillow/Pillow | 1,400 | python-pillow__Pillow-1400 | [
"1396"
] | 8d6f6fb355ea1265930afcf9ca0d4ffd9e0e2bb8 | diff --git a/PIL/ImageMorph.py b/PIL/ImageMorph.py
--- a/PIL/ImageMorph.py
+++ b/PIL/ImageMorph.py
@@ -198,6 +198,9 @@ def apply(self, image):
if self.lut is None:
raise Exception('No operator loaded')
+ if image.mode != 'L':
+ raise Exception('Image must be binary, meaning it ... | diff --git a/Tests/test_imagemorph.py b/Tests/test_imagemorph.py
--- a/Tests/test_imagemorph.py
+++ b/Tests/test_imagemorph.py
@@ -1,5 +1,5 @@
# Test the ImageMorphology functionality
-from helper import unittest, PillowTestCase
+from helper import unittest, PillowTestCase, hopper
from PIL import Image
from PIL im... | ImageMorph.MorphOp() crashes Python when applied to a non-grayscale image
python 3.4.3 from macports
pillow34 from macports
pycharm 4.5.2
osx 10.10 (yosemite)
``` python
from PIL import ImageMorph
from PIL import Image
from PIL import ImageOps
a_path = "......."
a = Image.open(a_path)
#need to do this because pillow... | Reproducible with hopper.png and:
Python 2.7.9
Pillow 2.9.0
OS X 10.10 (Yosemite)
``` python
Python 2.7.9 (default, Dec 19 2014, 06:05:48)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.56)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from PIL import ImageMorph
>>> from PIL... | 2015-08-28T12:58:08Z | 2.9 |
python-pillow/Pillow | 1,152 | python-pillow__Pillow-1152 | [
"1104"
] | 15727e2685df8f6b167e1e56f7ad715d85774462 | diff --git a/PIL/EpsImagePlugin.py b/PIL/EpsImagePlugin.py
--- a/PIL/EpsImagePlugin.py
+++ b/PIL/EpsImagePlugin.py
@@ -275,13 +275,13 @@ def _open(self):
s = fp.readline().strip('\r\n')
- if s[0] != "%":
+ if s[:1] != "%":
break
#
# Scan for an... | diff --git a/Tests/images/illu10_no_preview.eps b/Tests/images/illu10_no_preview.eps
new file mode 100644
--- /dev/null
+++ b/Tests/images/illu10_no_preview.eps
@@ -0,0 +1,10346 @@
+%!PS-Adobe-3.1 EPSF-3.0
+%ADO_DSC_Encoding: Windows Roman
+%%Title: illu10_no_preview.eps
+%%Creator: Adobe Illustrator(R) 16.0
+%%For... | After upgrading Pillow 2.3.0 to 2.7.0 .eps-files are not recognized anymore
After updating to version 2.7.0 Pillow fails to recognize an input .eps-file. After downgrading to 2.3.0 again the file is read like intended.
The Error Message:
```
Traceback (most recent call last):
File "img_pil.py", line 25, in <module... | @RomanTschirf Can you reproduce it with any of these test eps files?
https://github.com/python-pillow/Pillow/tree/master/Tests/images
Or can you share a problematic file?
And does it work with 2.4, 2.5 or 2.6?
@hugovk It worked with 2.3.0, 2.4.0 and 2.5.0 which is used now. 2.6.0 and 2.7.0 failed with the same erro... | 2015-03-26T12:32:56Z | 2.7 |
python-pillow/Pillow | 1,302 | python-pillow__Pillow-1302 | [
"1301"
] | ae0dfa8379fd790dc8f484ac7b7803e87f5f020c | diff --git a/PIL/BmpImagePlugin.py b/PIL/BmpImagePlugin.py
--- a/PIL/BmpImagePlugin.py
+++ b/PIL/BmpImagePlugin.py
@@ -103,7 +103,9 @@ def _bitmap(self, header=0, offset=0):
file_info['pixels_per_meter'] = (i32(header_data[20:24]), i32(header_data[24:28]))
file_info['colors'] = i32(hea... | diff --git a/Tests/images/hopper.bmp b/Tests/images/hopper.bmp
new file mode 100644
Binary files /dev/null and b/Tests/images/hopper.bmp differ
diff --git a/Tests/test_file_bmp.py b/Tests/test_file_bmp.py
--- a/Tests/test_file_bmp.py
+++ b/Tests/test_file_bmp.py
@@ -49,6 +49,22 @@ def test_dpi(self):
self.as... | "integer expected, got float" exception trying to save a BMP image with original DPI
Consider the following code:
```python
from PIL import Image
from StringIO import StringIO
image = Image.open('image.jpg')
out = StringIO()
print image.info
image.save(out, 'JPEG', quality=95, dpi=image.info['dpi'])
```
... | 2015-06-25T20:22:07Z | 2.8 | |
python-pillow/Pillow | 997 | python-pillow__Pillow-997 | [
"986"
] | e0b94d65bedb4a2124228aa579686a3ba2974d11 | diff --git a/PIL/Image.py b/PIL/Image.py
--- a/PIL/Image.py
+++ b/PIL/Image.py
@@ -876,7 +876,7 @@ def convert(self, mode=None, matrix=None, dither=None,
elif self.mode == 'P' and mode == 'RGBA':
t = self.info['transparency']
delete_trns = True
-
+
... | diff --git a/Tests/test_image_resize.py b/Tests/test_image_resize.py
--- a/Tests/test_image_resize.py
+++ b/Tests/test_image_resize.py
@@ -1,5 +1,91 @@
+"""
+Tests for resize functionality.
+"""
+from itertools import permutations
+
from helper import unittest, PillowTestCase, hopper
+from PIL import Image
+
+
+clas... | Image.resize() incorrectly centers non-nearest filters
(Discovered in the context of scipy, see https://github.com/scipy/scipy/issues/4112 for more details)
Using an interpolation method other than 'nearest' with Image.resize results in an image shift away from (0,0) in the result (among other problems)
It behaves as... | Thanks for reporting. I've also noticed this issue recently. There is no need to fix this particular issue, because `im.resize()` should be whole replaced with `im,stretch()` internal implementation. These and many other errors will go away.
That bicubic one is pretty freaky.
Just for fun, here's the output on anoth... | 2014-11-09T02:38:00Z | 2.6 |
python-pillow/Pillow | 808 | python-pillow__Pillow-808 | [
"806",
"806"
] | cf8f191c54aaec0d39938edbb12f3fd37b16aef6 | diff --git a/PIL/ImageFile.py b/PIL/ImageFile.py
--- a/PIL/ImageFile.py
+++ b/PIL/ImageFile.py
@@ -133,11 +133,27 @@ def load(self):
return pixel
self.map = None
-
+ use_mmap = self.filename and len(self.tile) == 1
+ # As of pypy 2.1.0, memory mapping was failing here.
+ use... | diff --git a/Tests/test_file_xpm.py b/Tests/test_file_xpm.py
--- a/Tests/test_file_xpm.py
+++ b/Tests/test_file_xpm.py
@@ -1,21 +1,34 @@
-from helper import unittest, PillowTestCase
+from helper import unittest, PillowTestCase, lena
from PIL import Image
# sample ppm stream
-file = "Tests/images/lena.xpm"
-data =... | More tests for XpmImagePlugin.py
- Test `load_read()`.
- Helps towards: Test coverage >= 80% #722.
- flake8.
More tests for XpmImagePlugin.py
- Test `load_read()`.
- Helps towards: Test coverage >= 80% #722.
- flake8.
| 2014-07-18T17:42:21Z | 2.5 | |
python-pillow/Pillow | 898 | python-pillow__Pillow-898 | [
"870"
] | af8bf3f1d2e67f78f2f8bfb90157ea8760e929d4 | diff --git a/PIL/ImageFile.py b/PIL/ImageFile.py
--- a/PIL/ImageFile.py
+++ b/PIL/ImageFile.py
@@ -227,6 +227,8 @@ def load(self):
break
b = b[n:]
t = t + n
+ # Need to cleanup here to prevent leaks in PyPy
+ d.cleanup()
... | diff --git a/Tests/check_j2k_leaks.py b/Tests/check_j2k_leaks.py
new file mode 100755
--- /dev/null
+++ b/Tests/check_j2k_leaks.py
@@ -0,0 +1,42 @@
+from helper import unittest, PillowTestCase
+import sys
+from PIL import Image
+from io import BytesIO
+
+# Limits for testing the leak
+mem_limit = 1024*1048576
+stack_si... | JPEG 2000 memory leak
When JPEG 2000 images are decoded, they are read using the Incremental decoding adapter.
On Linux, this uses pthreads to do the decoding in a separate thread.
However, after the image is loaded, the associated resources are never actually released.
The functionality for this is present in `Imagin... | Would you like to make a pull request?
It'd be useful to have `jp2k_test.py` in Tests/ as well (and update the `test_file` path), but call it something like `check_jp2k.py` as if has `test` in the name it'll be picked up and run on the CI.
(Unless you can think of a useful unit test to show this broken before and wo... | 2014-09-13T05:52:35Z | 2.5 |
python-pillow/Pillow | 669 | python-pillow__Pillow-669 | [
"659"
] | 24cb7bf3df6660bb2bd705b3197e97947dd40a50 | diff --git a/PIL/TiffImagePlugin.py b/PIL/TiffImagePlugin.py
--- a/PIL/TiffImagePlugin.py
+++ b/PIL/TiffImagePlugin.py
@@ -984,11 +984,7 @@ def _save(im, fp, filename):
compression = im.encoderinfo.get('compression',im.info.get('compression','raw'))
- libtiff = WRITE_LIBTIFF or compression in ["tiff_ccitt",... | diff --git a/Tests/test_file_libtiff.py b/Tests/test_file_libtiff.py
--- a/Tests/test_file_libtiff.py
+++ b/Tests/test_file_libtiff.py
@@ -258,9 +258,6 @@ def test_compressions():
im = lena('RGB')
out = tempfile('temp.tif')
- TiffImagePlugin.READ_LIBTIFF = True
- TiffImagePlugin.WRITE_LIBTIFF = True
-... | Document saving LZW-compressed TIFF files
This [works](http://stackoverflow.com/a/23612127/1389680), but it is missing [in the docs](http://pillow.readthedocs.org/en/latest/handbook/image-file-formats.html#saving-tiff-images).
| Actually, that's ... not quite right.
First, there are two flags, READ_LIBTIFF and WRITE_LIBTIFF, which are (currently) only used for testing. Setting READ_LIBTIFF before a write is a noop.
Second, it may be a bug that we're not setting tiff_lzw to use libtiff by default. There is LZW and packbits support in old PI... | 2014-05-20T18:05:20Z | 2.3 |
python-pillow/Pillow | 638 | python-pillow__Pillow-638 | [
"629"
] | f6262505cd185ee6c932d58a3ab6fa639ef891fa | diff --git a/PIL/Image.py b/PIL/Image.py
--- a/PIL/Image.py
+++ b/PIL/Image.py
@@ -30,6 +30,7 @@
import warnings
+
class _imaging_not_installed:
# module placeholder
def __getattr__(self, id):
@@ -52,8 +53,8 @@ def __getattr__(self, id):
# directly; import Image and use the Image.core variable inst... | diff --git a/Tests/test_pickle.py b/Tests/test_pickle.py
new file mode 100644
--- /dev/null
+++ b/Tests/test_pickle.py
@@ -0,0 +1,70 @@
+from tester import *
+
+from PIL import Image
+
+
+def helper_test_pickle_file(pickle, protocol=0):
+ im = Image.open('Images/lena.jpg')
+ filename = tempfile('temp.pkl')
+
+ ... | Add pickle support
Currently `Image` instances are not pickle-able.
It should be relatively simple to to implement pickle support on top of the existing `tobytes()` and `frombytes()` methods.
| :+1:
| 2014-04-25T08:08:27Z | 2.3 |
python-pillow/Pillow | 537 | python-pillow__Pillow-537 | [
"513",
"513"
] | aa864f4ab412fb2a2bae6b6e7fcc3bf804b61250 | diff --git a/PIL/GifImagePlugin.py b/PIL/GifImagePlugin.py
--- a/PIL/GifImagePlugin.py
+++ b/PIL/GifImagePlugin.py
@@ -237,7 +237,10 @@ def _save(im, fp, filename):
# convert on the fly (EXPERIMENTAL -- I'm not sure PIL
# should automatically convert images on save...)
if Image.getmodebase(im... | diff --git a/Tests/images/test.colors.gif b/Tests/images/test.colors.gif
new file mode 100644
Binary files /dev/null and b/Tests/images/test.colors.gif differ
diff --git a/Tests/test_file_gif.py b/Tests/test_file_gif.py
--- a/Tests/test_file_gif.py
+++ b/Tests/test_file_gif.py
@@ -38,7 +38,7 @@ def test_roundtrip():
... | Converting P->RGB, modifying, and converting back to P results in incorrect palette
Running this script (which converts a paletted image to RGB, resizes it with antialiasing enabled, and converts it back to paletted) on the provided in.gif results in an image with a broken palette.
From git bisect, the offending commi... | 2014-03-05T06:09:04Z | 2.3 | |
python-pillow/Pillow | 525 | python-pillow__Pillow-525 | [
"522"
] | df87d7d46e9a2ac2bbf49dcc94ed6843b882d830 | diff --git a/PIL/IcoImagePlugin.py b/PIL/IcoImagePlugin.py
--- a/PIL/IcoImagePlugin.py
+++ b/PIL/IcoImagePlugin.py
@@ -222,6 +222,10 @@ def load(self):
self.mode = im.mode
self.size = im.size
+
+ def load_seek(self):
+ # Flage the ImageFile.Parser so that it just does all the decode at the... | diff --git a/Tests/images/python.ico b/Tests/images/python.ico
new file mode 100644
Binary files /dev/null and b/Tests/images/python.ico differ
diff --git a/Tests/test_imagefile.py b/Tests/test_imagefile.py
--- a/Tests/test_imagefile.py
+++ b/Tests/test_imagefile.py
@@ -57,6 +57,13 @@ def roundtrip(format):
# http... | load ico file with ImageFile will raise an exception
> Traceback (most recent call last):
> File "t.py", line 12, in <module>
> p.feed(data)
> File "/.../lib/python2.7/site-packages/PIL/ImageFile.py", line 383, in feed
> if flag or len(im.tile) != 1:
> TypeError: object of type 'NoneType' has no len()
```
... | Does it work if you just read the file directly?
```
from PIL import Image
im = Image.open('favicon.ico')
im = im.convert('RGBA')
```
The parser class isn't always quite as robust as just simply opening and reading the file.
It works, but im.tile is still None. So in `feed` function when checking condition `len(im.... | 2014-02-17T04:59:45Z | 2.3 |
python-pillow/Pillow | 380 | python-pillow__Pillow-380 | [
"343"
] | e83455d0e50bc17c3bd1a19565f42cb7dfb11ad2 | diff --git a/PIL/Image.py b/PIL/Image.py
--- a/PIL/Image.py
+++ b/PIL/Image.py
@@ -200,6 +200,7 @@ def isImageType(t):
"RGBA": ("RGB", "L", ("R", "G", "B", "A")),
"CMYK": ("RGB", "L", ("C", "M", "Y", "K")),
"YCbCr": ("RGB", "L", ("Y", "Cb", "Cr")),
+ "LAB": ("RGB", "L", ("L", "A", "B")),
# Expe... | diff --git a/Tests/images/lab-green.tif b/Tests/images/lab-green.tif
new file mode 100644
Binary files /dev/null and b/Tests/images/lab-green.tif differ
diff --git a/Tests/images/lab-red.tif b/Tests/images/lab-red.tif
new file mode 100644
Binary files /dev/null and b/Tests/images/lab-red.tif differ
diff --git a/Tests/i... | Drop support for LCMS version 1
Due to security issue: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=718682
| 2013-10-16T05:11:43Z | 2.2 | |
python-pillow/Pillow | 364 | python-pillow__Pillow-364 | [
"66"
] | fcfa97498bc542e879c6d92573ef2fd54b53c95b | diff --git a/PIL/Image.py b/PIL/Image.py
--- a/PIL/Image.py
+++ b/PIL/Image.py
@@ -1309,6 +1309,9 @@ def resize(self, size, resample=NEAREST):
if self.mode in ("1", "P"):
resample = NEAREST
+ if self.mode == 'RGBA':
+ return self.convert('RGBa').resize(size, resample).convert('... | diff --git a/Tests/test_image_transform.py b/Tests/test_image_transform.py
--- a/Tests/test_image_transform.py
+++ b/Tests/test_image_transform.py
@@ -57,6 +57,40 @@ def test_mesh():
assert_image_equal(blank, transformed.crop((w//2,0,w,h//2)))
assert_image_equal(blank, transformed.crop((0,h//2,w//2,h)))
+de... | Add correct alpha pre-multiplication handling
See http://stackoverflow.com/questions/13027169/scale-images-with-pil-preserving-transparency-and-color
I will take a look into this when I've time. This issue should be fixed but is no block to a 2.0 release.
| @d-schmidt Still interested in working on this?
Yep. Still annoys me.
Am 12.05.2013 00:39 schrieb "Alex Clark ☺" notifications@github.com:
> @d-schmidt https://github.com/d-schmidt Still interested in working on
> this?
>
> —
> Reply to this email directly or view it on GitHubhttps://github.com/python-imaging/Pillow... | 2013-10-04T20:39:16Z | 2.2 |
python-pillow/Pillow | 333 | python-pillow__Pillow-333 | [
"285"
] | 9bb76ea8e4d8258a6e4d42bdc00d7dc3401e48e4 | diff --git a/PIL/ImageColor.py b/PIL/ImageColor.py
--- a/PIL/ImageColor.py
+++ b/PIL/ImageColor.py
@@ -102,6 +102,8 @@ def getcolor(color, mode):
if mode == "RGB":
return color
if mode == "RGBA":
+ if len(color) == 3:
+ color = (color + (255,))
r, g, b, a = color
ret... | diff --git a/Tests/images/multiline_text.png b/Tests/images/multiline_text.png
new file mode 100644
Binary files /dev/null and b/Tests/images/multiline_text.png differ
diff --git a/Tests/test_imagefont.py b/Tests/test_imagefont.py
--- a/Tests/test_imagefont.py
+++ b/Tests/test_imagefont.py
@@ -35,7 +35,7 @@ def test_fo... | TrueType fonts rendered from top pixel instead of top of font
As of [this commit in Pillow 2.1.0](https://github.com/python-imaging/Pillow/commit/efd70fb295c94936abb099256411f52a46a5c483), TrueType fonts are drawn from the top pixel down, instead of from the max height of the font. This means that lines containing only... | Can you send a PR to fix this issue please? I remember some confusion at the time about it… but I thought we had it figured out. Thanks
IIRC, we've already applied and reversed one patch for this or very similar behavior. I think that perhaps it's time to define exactly what behavior we want from draw.text, then test ... | 2013-09-24T21:31:41Z | 2.1 |
python-pillow/Pillow | 171 | python-pillow__Pillow-171 | [
"131"
] | c20d24e421880c0d12ce10129220dd95447d7240 | diff --git a/PIL/ImageFilter.py b/PIL/ImageFilter.py
--- a/PIL/ImageFilter.py
+++ b/PIL/ImageFilter.py
@@ -17,7 +17,7 @@
from functools import reduce
-class Filter:
+class Filter(object):
pass
##
| diff --git a/Tests/test_file_webp.py b/Tests/test_file_webp.py
--- a/Tests/test_file_webp.py
+++ b/Tests/test_file_webp.py
@@ -2,7 +2,12 @@
from PIL import Image
-def xtest_read():
+try:
+ import _webp
+except:
+ skip('webp support not installed')
+
+def test_read():
""" Can we write a webp without er... | Ubuntu 10.04 LTS Compatibility
2 Errors, both in the Gaussian blur filter.
10.04, Stock python 2.6.5, x86
```
Tests/test_image_filter.py:28: filter(ImageFilter.Kernel((3, 3), list(range(9)))) failed:
Traceback (most recent call last):
File "Tests/test_image_filter.py", line 28, in test_sanity
filter(ImageFilter... | There's a single failure for the shipped python3 (3.1) in 10.04 LTS
I wouldn't consider this a priority, since 3.1 isn't supported anywhere else, and no one sane would be trying to use 3.1 on an old LTS. (but hey, I've got the vm so I thought I'd give it a whirl)
```
running test_image_getim ...
Tests/test_image_geti... | 2013-03-27T17:03:47Z | 2 |
python-pillow/Pillow | 228 | python-pillow__Pillow-228 | [
"211"
] | c84a77bae75ee050aa86b418cb284ada4a9253ff | diff --git a/PIL/GifImagePlugin.py b/PIL/GifImagePlugin.py
--- a/PIL/GifImagePlugin.py
+++ b/PIL/GifImagePlugin.py
@@ -252,8 +252,9 @@ def _save(im, fp, filename):
palette = im.encoderinfo["palette"]
except KeyError:
palette = None
-
- for s in getheader(imOut, palette, im.encoderinfo):
+
... | diff --git a/Tests/test_file_gif.py b/Tests/test_file_gif.py
--- a/Tests/test_file_gif.py
+++ b/Tests/test_file_gif.py
@@ -9,7 +9,8 @@
# sample gif stream
file = "Images/lena.gif"
-data = open(file, "rb").read()
+with open(file, "rb") as f:
+ data = f.read()
def test_sanity():
im = Image.open(file)
@@ -2... | Saving gifs with optimize=True results in bad image
As already discovered by other people:
http://mail.python.org/pipermail/image-sig/2011-June/006777.html

Image was created using:
``` python
image = Image.new('RGB', ... | Of course we can use PNG8 instead - which works perfectly.
Thanks, any idea how to fix? If so, please send a pull request.
Optimize tries to reduce the palette size and seems to fail. I've no time to look into this now but I can debug it in a few weeks.
Thanks! No hurry
@saily or anyone else want to look at this? I... | 2013-05-23T12:25:50Z | 2 |
python-pillow/Pillow | 64 | python-pillow__Pillow-64 | [
"15"
] | e09ff61b81ff23baf635eeb98b788ad0a51cc86f | diff --git a/PIL/Image.py b/PIL/Image.py
--- a/PIL/Image.py
+++ b/PIL/Image.py
@@ -541,7 +541,11 @@ def tobytes(self, encoder_name="raw", *args):
if bytes is str:
# Declare tostring as alias to tobytes
def tostring(self, *args, **kw):
- warnings.warn('tostring() is deprecated. Please c... | diff --git a/Tests/run.py b/Tests/run.py
--- a/Tests/run.py
+++ b/Tests/run.py
@@ -91,5 +91,6 @@ def tests(n):
print(skipped)
if failure:
print("***", tests(failure), "of", (success + failure), "failed.")
+ sys.exit(1)
else:
print(tests(success), "passed.")
diff --git a/Tests/test_000_sanity.py b/Te... | RuntimeError: dictionary changed size during iteration
I got this error:
```/home/user/.virtualenvs/myproj/lib/python3.2/site-packages/Pillow-1.7.8-py3.2-linux-x86_64.egg/PIL/JpegImagePlugin.py in _getexif(self)
379 info = TiffImagePlugin.ImageFileDirectory(head)
380 info.load(file)
--> 381 ... | Any idea why?
When i commented line 236 `del self.tagdata[tag]` in file `PIL/TiffImagePlugin.py` error disappeared.
OK…
| 2013-02-26T10:46:34Z | 1.7 |
pallets/click | 2,840 | pallets__click-2840 | [
"2832",
"2832"
] | 0bf333e1b77b4ae0e85d387531b38930fc657f12 | diff --git a/src/click/__init__.py b/src/click/__init__.py
--- a/src/click/__init__.py
+++ b/src/click/__init__.py
@@ -19,7 +19,6 @@
from .decorators import confirmation_option as confirmation_option
from .decorators import group as group
from .decorators import help_option as help_option
-from .decorators import He... | diff --git a/tests/test_options.py b/tests/test_options.py
--- a/tests/test_options.py
+++ b/tests/test_options.py
@@ -724,6 +724,45 @@ def cmd2(testoption):
assert "you wont see me" not in result.output
+@pytest.mark.parametrize("custom_class", (True, False))
+@pytest.mark.parametrize(
+ ("name_specs",... | Regression: Help option subclassing no longer works with verion 8.1.8
Click 8.18 has a regression wrt. to help with Option subclasses.
This was found in this issue originally:
- https://github.com/aboutcode-org/scancode-toolkit/issues/4044
This was introduced in this PR by @kdeldycke :wave: :
- https://github.... | @kdeldycke I guess that no refactor goes unpunished!
The short term fix by @AyanSinhaMahapatra is that we skip using 8.1.8 entirely in https://github.com/aboutcode-org/scancode-toolkit/pull/4043/files#diff-fa602a8a75dc9dcc92261bac5f533c2a85e34fcceaff63b3a3a81d9acde2fc52R70
`click >= 6.7, !=7.0, !=8.1.8`
I just star... | 2025-01-09T20:00:38Z | 8.1 |
pallets/click | 2,622 | pallets__click-2622 | [
"2621"
] | 1787497713fa389435ed732c9b26274c3cdc458d | diff --git a/src/click/types.py b/src/click/types.py
--- a/src/click/types.py
+++ b/src/click/types.py
@@ -304,16 +304,21 @@ def convert(
if normed_value in normed_choices:
return normed_choices[normed_value]
+ self.fail(self.get_invalid_choice_message(value), param, ctx)
+
+ def get_i... | diff --git a/tests/test_types.py b/tests/test_types.py
--- a/tests/test_types.py
+++ b/tests/test_types.py
@@ -244,3 +244,9 @@ def test_invalid_path_with_esc_sequence():
click.Path(dir_okay=False).convert(tempdir, None, None)
assert "my\\ndir" in exc_info.value.message
+
+
+def test_choice_get_inval... | Allow customizing fail message for invalid choice in `click.types.Choice`
Move the fail art of `convert()` in the `Choice` class to a new method `get_invalid_choice_fail_message(self)` so in my subclass of `click.Choice` I can customize the way it shows the failing value for the choice
Some CLI option choices are mu... | 2023-10-04T21:40:39Z | 8.1 | |
pallets/click | 2,607 | pallets__click-2607 | [
"2606"
] | 53f14d3ac4791718f259531dec3433e04a6e45ce | diff --git a/src/click/utils.py b/src/click/utils.py
--- a/src/click/utils.py
+++ b/src/click/utils.py
@@ -311,7 +311,7 @@ def echo(
out = strip_ansi(out)
elif WIN:
if auto_wrap_for_ansi is not None:
- file = auto_wrap_for_ansi(file) # type: ignore
+ fil... | diff --git a/tests/test_utils.py b/tests/test_utils.py
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -36,9 +36,7 @@ def cli():
def test_echo_custom_file():
- import io
-
- f = io.StringIO()
+ f = StringIO()
click.echo("hello", file=f)
assert f.getvalue() == "hello\n"
@@ -209,7 +207,6 ... | click.echo does not force colors on Windows with color=True
Using `click.echo(click.style("Foo", fg="red"), color=True)` on Windows will not print "Foo" in red if the output is not a terminal that supports colors, so it seems that `color=True` is ignored on Windows.
Here is an example code to reproduce the bug:
```... | Windows uses a different mechanism for color than Unix. It's not possible to force it on. Or if it is, you'd need to take that up with colorama.
I've looked into it and it seems that there is a bug in `click` itself: the `color` parameter is not passed when `auto_wrap_for_ansi()` is called on line 317 in `utils.py`:
... | 2023-09-05T18:10:04Z | 8.1 |
pallets/click | 2,591 | pallets__click-2591 | [
"2590"
] | f5e47a6fc29c515c5c23bab297e1454c054844cb | diff --git a/examples/complex/complex/cli.py b/examples/complex/complex/cli.py
--- a/examples/complex/complex/cli.py
+++ b/examples/complex/complex/cli.py
@@ -28,7 +28,7 @@ def vlog(self, msg, *args):
cmd_folder = os.path.abspath(os.path.join(os.path.dirname(__file__), "commands"))
-class ComplexCLI(click.MultiCom... | diff --git a/src/click/testing.py b/src/click/testing.py
--- a/src/click/testing.py
+++ b/src/click/testing.py
@@ -14,7 +14,7 @@
from ._compat import _find_binary_reader
if t.TYPE_CHECKING:
- from .core import BaseCommand
+ from .core import Command
class EchoingStdin:
@@ -187,7 +187,7 @@ def __init__(
... | deprecate `MultiCommand`, merge into `Group`
As part of rewriting the parser in #2205, I was looking at the complexities of Click's definitions and processing. `MultiCommand` and `CommandCollection` could be combined with `Group` to simplify to a single way of working with multiple commands. This is a little more diffi... | 2023-08-19T19:52:35Z | 8.1 | |
pallets/click | 2,397 | pallets__click-2397 | [
"2396"
] | fcd85032cff78aa536a6d2b455fb83bfcc02b228 | diff --git a/src/click/core.py b/src/click/core.py
--- a/src/click/core.py
+++ b/src/click/core.py
@@ -8,6 +8,7 @@
import sys
import typing as t
from collections import abc
+from collections import Counter
from contextlib import AbstractContextManager
from contextlib import contextmanager
from contextlib import E... | diff --git a/tests/test_arguments.py b/tests/test_arguments.py
--- a/tests/test_arguments.py
+++ b/tests/test_arguments.py
@@ -401,3 +401,23 @@ def bar(arg):
assert isinstance(foo.params[0], CustomArgument)
assert isinstance(bar.params[0], CustomArgument)
+
+
+@pytest.mark.parametrize(
+ "args_one,args_t... | Issue UserWarning when overriding Parameter name
When a command is given multiple parameters that use the same name, a UserWarning should be fired to highlight the conflict. Currently, the command will quietly allow one parameter to override the names of another.
(This is a slightly different problem than https://gi... | 2022-11-07T03:47:35Z | 8.1 | |
pallets/click | 2,333 | pallets__click-2333 | [
"2332"
] | 6e704050f1149b00f3b3e7576e25b1e28c76ccf3 | diff --git a/src/click/utils.py b/src/click/utils.py
--- a/src/click/utils.py
+++ b/src/click/utils.py
@@ -523,7 +523,8 @@ def _detect_program_name(
# The value of __package__ indicates how Python was called. It may
# not exist if a setuptools script is installed as an egg. It may be
# set incorrectly fo... | diff --git a/tests/test_utils.py b/tests/test_utils.py
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -446,6 +446,7 @@ def __init__(self, package_name):
("example", None, "example"),
(str(pathlib.Path("example/__main__.py")), "example", "python -m example"),
(str(pathlib.Path("example... | Invalid info_name with shiv and pex
## Summary
When Click is used inside zipapps produced by Shiv or PEX, it displays an invalid "Usage" string. Instead of "Usage: program" it says "Usage: python -m program".
I did some digging and found that this is due to *info_name* being guessed incorrectly in the code introd... | If you know you're packaging your app with those tools, you can set the program name directly:
```python
main(prog_name="my-command")
``` | 2022-08-02T16:25:33Z | 8.1 |
pallets/click | 2,271 | pallets__click-2271 | [
"2263"
] | fde47b4b4f978f179b9dff34583cb2b99021f482 | diff --git a/src/click/core.py b/src/click/core.py
--- a/src/click/core.py
+++ b/src/click/core.py
@@ -856,12 +856,15 @@ class Command:
If enabled this will add ``--help`` as argument
if no arguments are passed
:param hidden: hide this command from help out... | diff --git a/tests/test_arguments.py b/tests/test_arguments.py
--- a/tests/test_arguments.py
+++ b/tests/test_arguments.py
@@ -275,6 +275,44 @@ def cli(f):
assert result.output == "test\n"
+def test_deprecated_usage(runner):
+ @click.command()
+ @click.argument("f", required=False, deprecated=True)
+ ... | Mark parameter as deprecated
Thanks for this great project!
Perhaps it's just me who feels that it is rather cumbersome mark a single parameter as deprecated (the closet I found was https://stackoverflow.com/a/50402799). Is there perhaps a more official method to mark a single parameter as deprecated?
That would some... | I'll work on this
@davidism I just implemented to show the message with `--help`.
Is it better to show same message running without `--help`? | 2022-05-02T21:09:55Z | 8.1 |
pallets/click | 2,151 | pallets__click-2151 | [
"2149"
] | 4262661a0fffabe3803f1bd876b19244f587dafa | diff --git a/src/click/core.py b/src/click/core.py
--- a/src/click/core.py
+++ b/src/click/core.py
@@ -1156,9 +1156,9 @@ class Command(BaseCommand):
the command is deprecated.
.. versionchanged:: 8.1
- Indentation in ``help`` is cleaned here instead of only in the
- ``... | diff --git a/tests/test_commands.py b/tests/test_commands.py
--- a/tests/test_commands.py
+++ b/tests/test_commands.py
@@ -95,6 +95,20 @@ def long():
)
+def test_help_truncation(runner):
+ @click.command()
+ def cli():
+ """This is a command with truncated help.
+ \f
+
+ This text sh... | Access untruncated help string
There's an [open feature request against sphinx-click](https://github.com/click-contrib/sphinx-click/issues/56), asking that we stop ignoring truncation of help strings when generating the documentation. Unfortunately, a quick look suggests [this is not currently possible](https://github.... | 2021-12-09T09:46:06Z | 8 | |
pallets/click | 2,094 | pallets__click-2094 | [
"2088"
] | 96146c9d0b25d700d00b65c916739bd491dd15e0 | diff --git a/src/click/types.py b/src/click/types.py
--- a/src/click/types.py
+++ b/src/click/types.py
@@ -836,20 +836,11 @@ def convert(
if not is_dash:
if self.resolve_path:
- # Get the absolute directory containing the path.
- dir_ = os.path.dirname(os.path.abspa... | diff --git a/tests/conftest.py b/tests/conftest.py
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -1,5 +1,4 @@
import os
-import shutil
import tempfile
import pytest
@@ -12,20 +11,17 @@ def runner(request):
return CliRunner()
-def check_symlink_impl():
- """This function checks if using symlinks is... | 8.0.2 doesn't validate paths correctly
Path arguments with a directory fail validation with "file not exists", despite existing, when resolve_path=True is specified
It looks like the code here concats the passed-in-path to its resolved directory, which means if the path contains a directory, the directory part gets ... | Seems that the fix for resolving across symlinks caused this. See #1813 (original discussion), #1825 (reverted), #1921 (next discussion), #2006 (currently applied), #2046.
Now that I look at the current code again, `os.readlink` really isn't a replacement for `os.path.realpath` the way it's used there, it's only being ... | 2021-10-10T17:17:54Z | 8 |
pallets/click | 2,219 | pallets__click-2219 | [
"2168"
] | 19be092b6db4e4300e31906498e354ec0adf870c | diff --git a/src/click/types.py b/src/click/types.py
--- a/src/click/types.py
+++ b/src/click/types.py
@@ -63,7 +63,14 @@ def to_info_dict(self) -> t.Dict[str, t.Any]:
# The class name without the "ParamType" suffix.
param_type = type(self).__name__.partition("ParamType")[0]
param_type = para... | diff --git a/tests/test_info_dict.py b/tests/test_info_dict.py
--- a/tests/test_info_dict.py
+++ b/tests/test_info_dict.py
@@ -266,3 +266,10 @@ def test_context():
"ignore_unknown_options": False,
"auto_envvar_prefix": None,
}
+
+
+def test_paramtype_no_name():
+ class TestType(click.ParamType... | `ParamType` missing `name` errors on `to_info_dict`
When calling `to_info_dict` on a `ParamType` instance which doesn't have a `name` attribute, an exception is raised. While this is a bug in the downstream code, only `to_info_dict` is affected, so the bug often goes unnoticed.
```py3
class TestType(click.ParamType... | 2022-03-19T18:28:51Z | 8 | |
pallets/click | 2,030 | pallets__click-2030 | [
"2017"
] | 6aff09eeb48d1d805c903b58ba393565a0cfd3e1 | diff --git a/src/click/core.py b/src/click/core.py
--- a/src/click/core.py
+++ b/src/click/core.py
@@ -46,17 +46,6 @@
V = t.TypeVar("V")
-def _fast_exit(code: int) -> "te.NoReturn":
- """Low-level exit that skips Python's cleanup but speeds up exit by
- about 10ms for things like shell completion.
-
- :pa... | diff --git a/tests/test_shell_completion.py b/tests/test_shell_completion.py
--- a/tests/test_shell_completion.py
+++ b/tests/test_shell_completion.py
@@ -1,5 +1,3 @@
-import sys
-
import pytest
from click.core import Argument
@@ -265,7 +263,6 @@ def test_completion_item_data():
@pytest.fixture()
def _patch_for... | Resource tracker warning on fish completion
Issue:
I am having the same issue described in #1738 although I am using `fish`. Essentially, I get an error from `resource_tracker.py` related to "leaked semaphore objects," when I run the completion. The completion still works, but the text of the error is garbled along wi... | Closing for the same reason as the linked issue. I can't reproduce this. This does not appear to be an issue with Click, but with something else about your project.
@davidism So, I have been trying to track down this error further. I am talking with @Delgan who is the dev for `loguru` which appeared to be where the err... | 2021-08-03T17:43:32Z | 8 |
pallets/click | 1,998 | pallets__click-1998 | [
"1971"
] | 68e65ee2bf3e057a99d1192cc256cc2cb2a12203 | diff --git a/src/click/core.py b/src/click/core.py
--- a/src/click/core.py
+++ b/src/click/core.py
@@ -2416,25 +2416,26 @@ class Option(Parameter):
All other parameters are passed onwards to the parameter constructor.
- :param show_default: controls if the default value should be shown on the
- ... | diff --git a/tests/test_formatting.py b/tests/test_formatting.py
--- a/tests/test_formatting.py
+++ b/tests/test_formatting.py
@@ -322,12 +322,13 @@ def cli():
pass
result = runner.invoke(cli, ["--help"])
+ # the default to "--help" is not shown because it is False
assert result.output.splitline... | Consider not showing the default value of boolean flags without a secondary option (False)
Unless I'm missing something, the default value of such options should be obvious: `False`. As a consequence, `[default: False]` feels like superfluous noise. This is certainly true for the `--help` option, which should never sho... | 2021-07-08T08:05:52Z | 8 | |
pallets/click | 1,840 | pallets__click-1840 | [
"1568"
] | 6c7624491911f0b18f869e5d0a989506e7b416f8 | diff --git a/src/click/core.py b/src/click/core.py
--- a/src/click/core.py
+++ b/src/click/core.py
@@ -678,6 +678,10 @@ def invoke(*args, **kwargs): # noqa: B902
in against the intention of this code and no context was created. For
more information about this change and why it was done in a bugfix
... | diff --git a/tests/test_commands.py b/tests/test_commands.py
--- a/tests/test_commands.py
+++ b/tests/test_commands.py
@@ -39,6 +39,28 @@ def dist(ctx, count):
assert result.output == "Count: 1\nCount: 42\n"
+def test_forwarded_params_consistency(runner):
+ cli = click.Group()
+
+ @cli.command()
+ @cl... | context.forward inconsistently removes undeclared options
### Expected Behavior
Three commands. The first takes a subset of the options that the last two take. Each prints the arguments they were called with. All but the first call the one before it via `context.forward`.
```python
import click
from pprint impo... | @thejohnfreeman I am looking into this. Doing preliminary investigations on why this is happening.
`Context.forward` uses `Context.params` to fill in the options and passes the `kwargs` to `Context.invoke` which creates a new `Context` for the sub command but doesn't pass the params to the new `Context` nor does it re... | 2021-04-09T12:45:33Z | 8 |
pallets/click | 1,829 | pallets__click-1829 | [
"303"
] | c0f9c06aa123e75466829bd41985a44a70b6c625 | diff --git a/src/click/_termui_impl.py b/src/click/_termui_impl.py
--- a/src/click/_termui_impl.py
+++ b/src/click/_termui_impl.py
@@ -8,6 +8,7 @@
import os
import sys
import time
+from gettext import gettext as _
from ._compat import _default_text_stdout
from ._compat import CYGWIN
@@ -489,9 +490,13 @@ def edit... | diff --git a/tests/test_arguments.py b/tests/test_arguments.py
--- a/tests/test_arguments.py
+++ b/tests/test_arguments.py
@@ -230,7 +230,7 @@ def test_missing_argument_string_cast():
with pytest.raises(click.MissingParameter) as excinfo:
click.Argument(["a"], required=True).process_value(ctx, None)
- ... | Provide i18n with gettext
It would be useful to wrap every public message with gettext function to allow i18n for application.
| + 1
+1
For those interrested, I've made a gist showing how to catch click exceptions and translate them.
It's **quick and dirty** (use regexps), but right now it does the job:
https://gist.github.com/lapause/ed148b2b1481f83f39c5
To core developers: if you don't want to implement i18n, you could create one excepti... | 2021-04-01T13:12:10Z | 8 |
pallets/click | 1,785 | pallets__click-1785 | [
"457"
] | 98e471fb871f211dd40b1bea80942acb7bb9f176 | diff --git a/src/click/core.py b/src/click/core.py
--- a/src/click/core.py
+++ b/src/click/core.py
@@ -1769,9 +1769,10 @@ class Parameter:
:param default: the default value if omitted. This can also be a callable,
in which case it's invoked when the default is needed
with... | diff --git a/tests/test_arguments.py b/tests/test_arguments.py
--- a/tests/test_arguments.py
+++ b/tests/test_arguments.py
@@ -228,7 +228,7 @@ def test_missing_argument_string_cast():
ctx = click.Context(click.Command(""))
with pytest.raises(click.MissingParameter) as excinfo:
- click.Argument(["a"],... | Sanitization for click inputs
I would like to see some method of easy sanitation after an input. I guess I could define a type and require that type for the input but that seems a little extravagant if I want to make sure that say a field entered is a valid email address during input or to strip out spaces automaticall... | Can you not use our callback system for this?
Oh I see. We might only invoke the type conversion but not the callbacks for prompts currently. I wonder if that can be changed though.
It would be a good feature indeed.
Yeah in the code I wrote I ended up just calling strip to sanitize it somewhat and prevent spaces a... | 2021-02-16T19:28:19Z | 8 |
pallets/click | 1,784 | pallets__click-1784 | [
"1546"
] | ea3bb6f1bf5db675f2dec0350f57e704da6ea00b | diff --git a/examples/colors/colors.py b/examples/colors/colors.py
--- a/examples/colors/colors.py
+++ b/examples/colors/colors.py
@@ -23,9 +23,8 @@
@click.command()
def cli():
- """This script prints some colors. If colorama is installed this will
- also work on Windows. It will also automatically remove a... | diff --git a/requirements/tests.in b/requirements/tests.in
--- a/requirements/tests.in
+++ b/requirements/tests.in
@@ -1,3 +1,2 @@
pytest
-colorama
importlib_metadata
diff --git a/requirements/tests.txt b/requirements/tests.txt
--- a/requirements/tests.txt
+++ b/requirements/tests.txt
@@ -6,8 +6,6 @@
#
attrs==20.3.... | Use of Setuptools' "extras_require" for colorama?
Might it make sense to use Setuptools' ["extras"](https://setuptools.readthedocs.io/en/latest/setuptools.html#declaring-extras-optional-features-with-their-own-dependencies) feature for automatically installing colorama on Windows?
Currently the docs contain fragment... | I think in this case I'd like to just make it an automatically installed dependency on Windows. | 2021-02-16T02:34:22Z | 8 |
pallets/click | 1,786 | pallets__click-1786 | [
"723"
] | 0805f60cfc7a48b9a951733a81639e7fda430152 | diff --git a/src/click/core.py b/src/click/core.py
--- a/src/click/core.py
+++ b/src/click/core.py
@@ -2146,8 +2146,9 @@ class Option(Parameter):
:param prompt: if set to `True` or a non empty string then the user will be
prompted for input. If set to `True` the prompt will be the
... | diff --git a/tests/test_termui.py b/tests/test_termui.py
--- a/tests/test_termui.py
+++ b/tests/test_termui.py
@@ -446,3 +446,27 @@ def cli(value, o):
result = runner.invoke(cli, args=args, input="prompt", standalone_mode=False)
assert result.exception is None
assert result.return_value == expect
+
+
+@p... | Configurable "Repeat for confirmation:" text
It would be nice to be able to set this prompt confirmation text.
| This is also something I'd like, and I'd be willing to submit a PR for this if it can make things faster, but I wonder if it would have any chance to be merged when I see the amount of unanswered issues and PR's. If the repo owner passes by, do you think it would be worth it to work on a PR?
I can't comment on whether ... | 2021-02-18T19:01:04Z | 8 |
pallets/click | 1,543 | pallets__click-1543 | [
"1514"
] | a6b10db3882fe464898f1ffaa6fbba6fc390f894 | diff --git a/src/click/_compat.py b/src/click/_compat.py
--- a/src/click/_compat.py
+++ b/src/click/_compat.py
@@ -174,8 +174,6 @@ def seekable(self):
iteritems = lambda x: x.iteritems()
range_type = xrange
- from pipes import quote as shlex_quote
-
def is_bytes(x):
return isinstance(x, (bu... | diff --git a/tests/test_imports.py b/tests/test_imports.py
--- a/tests/test_imports.py
+++ b/tests/test_imports.py
@@ -49,7 +49,6 @@ def tracking_import(module, locals=None, globals=None, fromlist=None,
"fcntl",
"datetime",
"pipes",
- "shlex",
}
if WIN:
| echo_via_pager broken on Windows in 7.1
Calls to `click.echo_via_pager` are failing on Windows since upgrading to 7.1
### Expected behavior (7.0)
```
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.... | Same issue as [here](https://github.com/dbcli/pgcli/issues/1167) - and same root cause:
```python
>>> os.environ['PAGER'] = 'less -SRXF'
>>> import click
>>> text = [f"hello {i} \n" for i in range(1000)]
>>> click.echo_via_pager(text)
The system cannot find the file specified.
>>> os.environ['PAGER'] = 'less'
... | 2020-04-27T19:32:20Z | 7.1 |
pallets/click | 1,402 | pallets__click-1402 | [
"1381"
] | b41940747860a13e1d12b54d2d55b0cec57f0ce3 | diff --git a/src/click/termui.py b/src/click/termui.py
--- a/src/click/termui.py
+++ b/src/click/termui.py
@@ -172,21 +172,29 @@ def confirm(
If the user aborts the input by sending a interrupt signal this
function will catch it and raise a :exc:`Abort` exception.
- .. versionadded:: 4.0
- Added th... | diff --git a/tests/test_utils.py b/tests/test_utils.py
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -131,6 +131,14 @@ def test_no():
assert result.output == "Foo [Y/n]: n\nno :(\n"
+def test_confirm_repeat(runner):
+ cli = click.Command(
+ "cli", params=[click.Option(["--a/--no-a"], default... | Option to reask on no input in `click.confirm`
It would be nice if similarly to `click.prompt`, `click.confirm` would allow to reask the user if no input is given.
| 2019-09-30T17:23:37Z | 8 | |
pallets/click | 1,318 | pallets__click-1318 | [
"1277"
] | 68c93287a8195af539c85656927f5c67ba5631d5 | diff --git a/click/types.py b/click/types.py
--- a/click/types.py
+++ b/click/types.py
@@ -133,6 +133,10 @@ class Choice(ParamType):
You should only pass a list or tuple of choices. Other iterables
(like generators) may lead to surprising results.
+ The resulting value will always be one of the originall... | diff --git a/tests/test_normalization.py b/tests/test_normalization.py
--- a/tests/test_normalization.py
+++ b/tests/test_normalization.py
@@ -20,7 +20,7 @@ def test_choice_normalization(runner):
@click.command(context_settings=CONTEXT_SETTINGS)
@click.option('--choice', type=click.Choice(['Foo', 'Bar']))
... | Add coercion/normalization of Choice values
I want my CLI to be case insensitive for certain `Choice` options but I don't want to deal with that variability internally as it has no meaning. I think an option like `coerce_case` or `normalize_case` would be a reasonable addition.
PR to follow.
| It appears #887 already added this.
Never mind, this is about what value gets returned, that was about what got matched.
> I don't want to deal with that variability internally as it has no meaning.
Sounds like you should just be handling things in all-lowercase? #887 set things to return the `normed_value` -- so wh... | 2019-05-11T19:41:38Z | 7 |
pallets/click | 1,304 | pallets__click-1304 | [
"1285"
] | 278a054432dbbe077f8921249d657c992ccf99fb | diff --git a/click/core.py b/click/core.py
--- a/click/core.py
+++ b/click/core.py
@@ -1323,12 +1323,6 @@ class Parameter(object):
Some settings are supported by both options and arguments.
- .. versionchanged:: 2.0
- Changed signature for parameter callback to also be passed the
- parameter. I... | diff --git a/tests/test_options.py b/tests/test_options.py
--- a/tests/test_options.py
+++ b/tests/test_options.py
@@ -113,6 +113,17 @@ def cli(message):
assert 'Error: Missing option "-m" / "--message".' in result.output
+def test_empty_envvar(runner):
+ @click.command()
+ @click.option('--mypath', type... | Path(exists=True, envvar='FOO') tries to interpret FOO="" as an existing path
Example:
```python
@click.command()
@click.option('--mypath', type=click.Path(exists=True), envvar='MYPATH')
def cli(mypath):
click.echo(f'mypath: {mypath}')
```
Test case:
```
➜ env MYPATH= ./mycli.py
```
Observed output:
... | 2019-05-06T18:50:49Z | 7 | |
pallets/click | 1,261 | pallets__click-1261 | [
"1253"
] | 93d947c2e3c5584729d7de35644f778c0e8e147e | diff --git a/click/core.py b/click/core.py
--- a/click/core.py
+++ b/click/core.py
@@ -335,6 +335,8 @@ def __init__(self, command, parent=None, info_name=None, obj=None,
self.info_name.upper())
else:
auto_envvar_prefix = auto_envvar_prefix.upper()
+ ... | diff --git a/tests/test_options.py b/tests/test_options.py
--- a/tests/test_options.py
+++ b/tests/test_options.py
@@ -273,6 +273,22 @@ def cmd(arg):
assert 'TEST_ARG1' in result.output
+def test_show_envvar_auto_prefix_dash_in_command(runner):
+ @click.group()
+ def cli():
+ pass
+
+ @cli.comm... | Environment variable name generation from command name is broken
When command names contain a `-` character, automatic environment variable name generation is broken
```
#!/usr/bin/env python3
import click
@click.group()
@click.option('--debug/--no-debug')
def cli(debug):
click.echo('Debug mode is %s' ... | In fact, it also happens when not setting the command name explicitly but letting `click` renaming function names with underscore to command names.
```
#!/usr/bin/env python3
import click
@click.group()
@click.option('--debug/--no-debug')
def cli(debug):
click.echo('Debug mode is %s' % ('on' if debug e... | 2019-03-21T08:42:16Z | 7 |
pallets/click | 1,167 | pallets__click-1167 | [
"1156"
] | 68ecafd8096253fe020d73097ecb3351d4e1cd87 | diff --git a/click/core.py b/click/core.py
--- a/click/core.py
+++ b/click/core.py
@@ -785,6 +785,10 @@ class Command(BaseCommand):
shown on the command listing of the parent command.
:param add_help_option: by default each command registers a ``--help``
option.... | diff --git a/tests/test_commands.py b/tests/test_commands.py
--- a/tests/test_commands.py
+++ b/tests/test_commands.py
@@ -68,6 +68,16 @@ def long():
result.output) is not None
+def test_no_args_is_help(runner):
+ @click.command(no_args_is_help=True)
+ def cli():
+ pass
+
+ result = runner.... | explicitly print help when no arguments are given
Hi,
I would like to explicitly print **full** help for my script if no arguments are given. The code:
```python
@click.command()
@click.argument('input_dir', type=click.Path(exists=True))
@click.argument('output_dir', type=click.Path(exists=True))
@click.option(... | If you just want something which works trivially...
```python
@click.command()
@click.argument('FOO')
def cli(foo):
click.echo(foo)
if __name__ == '__main__':
if len(sys.argv) == 1:
cli.main(['--help'])
else:
cli()
```
I don't really think that `click` should do more than p... | 2018-11-10T06:04:09Z | 7 |
pallets/click | 1,014 | pallets__click-1014 | [
"574"
] | 0650d3659fbce0c880a8c300104bd4c74daef8bd | diff --git a/click/core.py b/click/core.py
--- a/click/core.py
+++ b/click/core.py
@@ -1324,7 +1324,7 @@ def __init__(self, param_decls=None, type=None, required=False,
self.is_eager = is_eager
self.metavar = metavar
self.envvar = envvar
- self.autocompletion = autocompletion
+ ... | diff --git a/tests/test_arguments.py b/tests/test_arguments.py
--- a/tests/test_arguments.py
+++ b/tests/test_arguments.py
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
+import pytest
import click
from click._compat import PY2
@@ -287,3 +288,11 @@ def cmd(a):
result = runner.invoke(cmd, ['3'])
assert result.ex... | Validate *args passed to `click.option`
See https://github.com/pallets/click/issues/568
| 2018-05-15T20:32:25Z | 6.7 | |
pallets/click | 1,098 | pallets__click-1098 | [
"667"
] | a0e0328e142f63a6e98e69ae20220a51142251d3 | diff --git a/click/core.py b/click/core.py
--- a/click/core.py
+++ b/click/core.py
@@ -9,7 +9,7 @@
from .types import convert_type, IntRange, BOOL
from .utils import make_str, make_default_short_help, echo, get_os_args
from .exceptions import ClickException, UsageError, BadParameter, Abort, \
- MissingParameter
... | diff --git a/tests/test_context.py b/tests/test_context.py
--- a/tests/test_context.py
+++ b/tests/test_context.py
@@ -193,6 +193,7 @@ def test_close_before_pop(runner):
@click.pass_context
def cli(ctx):
ctx.obj = 'test'
+
@ctx.call_on_close
def foo():
assert click.get_... | standalone_mode does not affect the help option
If we use `standalone_mode=True` passing arguments to command execution will not call `sys.exit`, except if the argument to the command is `["--help"]`.
From inside ipython:
> In [12]: import click
>
> In [13]: @click.command()
> ...: def hello():
> ...: pr... | 2018-08-26T22:18:21Z | 6.7 | |
pallets/click | 865 | pallets__click-865 | [
"323"
] | bf307371b3b5eda1b3170b58e6f89df3913336c4 | diff --git a/click/_bashcomplete.py b/click/_bashcomplete.py
--- a/click/_bashcomplete.py
+++ b/click/_bashcomplete.py
@@ -10,7 +10,7 @@
WORDBREAK = '='
-COMPLETION_SCRIPT = '''
+COMPLETION_SCRIPT_BASH = '''
%(complete_func)s() {
local IFS=$'\n'
COMPREPLY=( $( env COMP_WORDS="${COMP_WORDS[*]}" \\
@@ -19... | diff --git a/tests/test_compat.py b/tests/test_compat.py
--- a/tests/test_compat.py
+++ b/tests/test_compat.py
@@ -20,6 +20,6 @@ def cli(foo):
def test_bash_func_name():
from click._bashcomplete import get_completion_script
- script = get_completion_script('foo-bar baz_blah', '_COMPLETE_VAR').strip()
+ sc... | Autocomplete support for zsh
Bash autocompletion works well, but I would really like zsh to work as well
| Related https://github.com/mitsuhiko/click/issues/241.
Has zsh implementation: https://github.com/kislyuk/argcomplete
I have to release a `tmuxp.bash`, `tmuxp.zsh` and `tmuxp.tcsh` to get autocomplete working with argcomplete. The user has to source the correct one depending on their `$SHELL`, https://github.com/tony... | 2017-10-10T01:11:46Z | 6.7 |
pallets/click | 552 | pallets__click-552 | [
"551"
] | 159d0e577ca88ee14e543ff3ebeab3f21515eb59 | diff --git a/click/types.py b/click/types.py
--- a/click/types.py
+++ b/click/types.py
@@ -418,26 +418,26 @@ def convert(self, value, param, ctx):
filename_to_ui(value)
), param, ctx)
- if not self.file_okay and stat.S_ISREG(st.st_mode):
- self.fail('%s "%s" is ... | diff --git a/tests/test_arguments.py b/tests/test_arguments.py
--- a/tests/test_arguments.py
+++ b/tests/test_arguments.py
@@ -106,6 +106,17 @@ def inout(input, output):
assert result.exit_code == 0
+def test_path_args(runner):
+ @click.command()
+ @click.argument('input', type=click.Path(dir_okay=Fa... | UnboundLocalError when combining allow_dash and dir_okay
``` python
import click
@click.command()
@click.argument('filename', type=click.Path(dir_okay=False, allow_dash=True))
def foo(filename):
pass
if __name__ == '__main__':
foo()
```
When this script is invoked with the argument '-' I see the following er... | 2016-04-04T16:16:19Z | 6.4 | |
pallets/click | 706 | pallets__click-706 | [
"651",
"485"
] | e6f22c652fb537b11f7b51d77b1013d876176512 | diff --git a/click/_termui_impl.py b/click/_termui_impl.py
--- a/click/_termui_impl.py
+++ b/click/_termui_impl.py
@@ -102,7 +102,7 @@ def __iter__(self):
if not self.entered:
raise RuntimeError('You need to use progress bars in a with block.')
self.render_progress()
- return self
... | diff --git a/tests/test_termui.py b/tests/test_termui.py
--- a/tests/test_termui.py
+++ b/tests/test_termui.py
@@ -1,4 +1,5 @@
import click
+import time
def test_progressbar_strip_regression(runner, monkeypatch):
@@ -69,3 +70,41 @@ def test_secho(runner):
click.secho(None, nl=False)
bytes = out.... | Progress bar should advance at end of loop
I'm using the progress bar with a piece of code like this:
``` python
with click.progressbar(some_list) as bar:
for element in bar:
element.long_calculation
```
It seems that the progress bar updates every time it enters the loop, which for the last element means... | This just seems like a off-by-one error to me.
Might be. The ETA is definitely off by one.
Here is the small script I used to test this:
``` python
import time
import click
@click.command()
@click.option('--count', default=1)
def test(count):
with click.progressbar(range(count)) as bar:
for x in bar:
... | 2016-12-22T20:47:35Z | 6.6 |
pallets/click | 545 | pallets__click-545 | [
"471"
] | 84e1572839d551f6ac700609ce7b6fd4ba754780 | diff --git a/click/_bashcomplete.py b/click/_bashcomplete.py
--- a/click/_bashcomplete.py
+++ b/click/_bashcomplete.py
@@ -30,27 +30,19 @@ def get_completion_script(prog_name, complete_var):
def resolve_ctx(cli, prog_name, args):
ctx = cli.make_context(prog_name, args, resilient_parsing=True)
- while ctx.arg... | diff --git a/tests/test_bashcomplete.py b/tests/test_bashcomplete.py
new file mode 100644
--- /dev/null
+++ b/tests/test_bashcomplete.py
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+
+import click
+from click._bashcomplete import get_choices
+
+def test_basic():
+ @click.group()
+ @click.option('--global-opt')
+ ... | Bash completion for MultiCommands returns subcommands twice until it stops.
Python 2.7.10
broken in click >= 6
ok in click (5.1)
```
manage hello hello world world
```
| +1
Still a problem in click v6.2
Bash completion isn't working properly beyond the first click command level.
I've noticed this problem as well. Some `git bisect` experiments indicate that the problem was introduced in commit 0a2919f34fcbc635d8530b4c5b60bf119b2bcedb on Nov 24th.
Still observing this issue with cli... | 2016-03-23T23:09:40Z | 6.3 |
pallets/click | 240 | pallets__click-240 | [
"231"
] | 308cc08a711f1ec372fd7fa5acca8e8a1a04ee70 | diff --git a/click/formatting.py b/click/formatting.py
--- a/click/formatting.py
+++ b/click/formatting.py
@@ -18,6 +18,12 @@ def iter_rows(rows, col_count):
yield row + ('',) * (col_count - len(row))
+def add_subsequent_indent(text, subsequent_indent):
+ lines = text.splitlines()
+ lines = [lines[0]... | diff --git a/tests/test_formatting.py b/tests/test_formatting.py
--- a/tests/test_formatting.py
+++ b/tests/test_formatting.py
@@ -48,3 +48,42 @@ def cli():
'Options:',
' --help Show this message and exit.',
]
+
+
+def test_wrapping_long_options_strings(runner):
+ @click.group()
+ def cli... | Single-character wrapped lines with long options
When I run the script at the bottom I get the following output. I would, obviously, expect ALSOLONG to be all together on the second row.
```
Usage: example.py relatively_long example [OPTIONS] FIRST SECOND LONGISH
A
... | This is on click 3.3 and Python 2.7.
I've just done a bit of digging, and the problem is that click passes a subsequent_indent in to textwrap.TextWrapper; this is subtracted from the total width available on all but the first line to determine how wide they can be. In this example, that means that all but the first li... | 2014-10-22T09:49:57Z | 3.3 |
pallets/click | 212 | pallets__click-212 | [
"211"
] | 4507fd537e93ce661ef96a122149e36104e84c61 | diff --git a/click/termui.py b/click/termui.py
--- a/click/termui.py
+++ b/click/termui.py
@@ -33,7 +33,8 @@ def _build_prompt(text, suffix, show_default=False, default=None):
def prompt(text, default=None, hide_input=False,
confirmation_prompt=False, type=None,
- value_proc=None, prompt_suffix... | diff --git a/tests/test_utils.py b/tests/test_utils.py
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -151,6 +151,64 @@ def test_echo_color_flag(monkeypatch, capfd):
assert out == text + '\n'
+def test_echo_writing_to_standard_error(capfd, monkeypatch):
+ def emulate_input(text):
+ """Emulate... | Option for click.prompt to write to standard error
click.echo can write to standard error nicely, however I have a usecase where I want to redirect output to a file with shell builtin `>>`, but don't want to write the conversation between the user and the script.
Example:
```
$ command getinfo Walkma >> outputfile.tx... | I played with it a bit more and tried:
``` python
click.echo('Message', err=True)
click.prompt('', prompt_suffix='')
```
In this case, the message don't get written to the redirected file, but the question will not be repeated (just an empty prompt).
Echoing the message to stdout is not good at all, because it will ... | 2014-08-26T16:39:28Z | 3.2 |
pallets/click | 123 | pallets__click-123 | [
"122"
] | 1bc0a1995d9a0b6b25d63c96a7fb55a181449bcd | diff --git a/click/decorators.py b/click/decorators.py
--- a/click/decorators.py
+++ b/click/decorators.py
@@ -150,6 +150,8 @@ def option(*param_decls, **attrs):
:attr:`Command.params` list.
"""
def decorator(f):
+ if 'help' in attrs:
+ attrs['help'] = inspect.cleandoc(attrs['help'])
... | diff --git a/tests/test_options.py b/tests/test_options.py
--- a/tests/test_options.py
+++ b/tests/test_options.py
@@ -169,3 +169,23 @@ def cmd(foo):
assert result.exit_code == 2
assert 'Error: Missing option "--foo". Choose from foo, bar.' \
in result.output
+
+
+def test_multiline_help(runner):
+ ... | Automatically dedent help text of options?
```
import click
@click.command()
@click.option('--foo', help="""
heyho
i am
multiline
""")
def cli(foo):
click.echo(foo)
cli()
```
This currently does not remove the leading whitespace from each paragraph in the help text for `--foo`:
```
untitaker@untib... | From what i can see in `write_dl`, this seems to be a bug.
| 2014-06-05T12:03:11Z | 1.1 |
reduxjs/redux-toolkit | 4,758 | reduxjs__redux-toolkit-4758 | [
"3778"
] | 45a95cbe87a70ae0748a9a5d239754e51e1f874b | diff --git a/packages/toolkit/src/query/react/buildHooks.ts b/packages/toolkit/src/query/react/buildHooks.ts
--- a/packages/toolkit/src/query/react/buildHooks.ts
+++ b/packages/toolkit/src/query/react/buildHooks.ts
@@ -1661,8 +1661,6 @@ export function buildHooks<Definitions extends EndpointDefinitions>({
skipPo... | diff --git a/packages/toolkit/src/query/tests/buildHooks.test.tsx b/packages/toolkit/src/query/tests/buildHooks.test.tsx
--- a/packages/toolkit/src/query/tests/buildHooks.test.tsx
+++ b/packages/toolkit/src/query/tests/buildHooks.test.tsx
@@ -902,6 +902,71 @@ describe('hooks tests', () => {
status: 'uninitia... | [RTK-Query]: `useQuery` hook does not refetch after `resetApiState` (2)
### Description:
This issue appears to be a bug in RTK-Query, which should have been resolved by #1735 and #3333. However, it appears that the problem persists.
### Reproduction Steps:
1. Access the following example showcasing the issue: [Cod... | Yup, I can see that. Weird that it only happens after a rerender 🤔
@phryneas
Is there any fixes for this?
I have same issue on my project
Same thing in my project. | 2024-12-09T08:26:01Z | 2.6 |
reduxjs/redux-toolkit | 4,768 | reduxjs__redux-toolkit-4768 | [
"4749"
] | 6590cec1cee83fcab165eb340f6b78762c4ad5a2 | diff --git a/packages/toolkit/src/query/core/buildSlice.ts b/packages/toolkit/src/query/core/buildSlice.ts
--- a/packages/toolkit/src/query/core/buildSlice.ts
+++ b/packages/toolkit/src/query/core/buildSlice.ts
@@ -84,7 +84,7 @@ export type ProcessedQueryUpsertEntry = {
/**
* A typesafe representation of a util acti... | diff --git a/packages/toolkit/src/query/tests/optimisticUpserts.test.tsx b/packages/toolkit/src/query/tests/optimisticUpserts.test.tsx
--- a/packages/toolkit/src/query/tests/optimisticUpserts.test.tsx
+++ b/packages/toolkit/src/query/tests/optimisticUpserts.test.tsx
@@ -5,7 +5,13 @@ import {
hookWaitFor,
setupApi... | UpsertQueryEntries breaks query invalidation when the invalidationBehavior is set to delayed
```ts
// api configuration
invalidationBehavior: "delayed"
// queries
getQuery: build.query<>({
query:...,
providesTags: ["QueryTag"]
}),
editQuery: build.mutation<>({
invalidatesTags: ["QueryTag"]
}),
getSom... | I experienced the same issue.
The issue here seems to be that the when `upsertQueryEntries` is called, the upserted "queries" stay in `status: "pending"` forever.

As you can see in the Redux Browser Devtools, these are all upser... | 2024-12-14T02:14:05Z | 2.5 |
reduxjs/redux-toolkit | 4,762 | reduxjs__redux-toolkit-4762 | [
"4751"
] | 40b8aedf8bf3306795814e6a868881ae7a025171 | diff --git a/packages/toolkit/src/query/react/buildHooks.ts b/packages/toolkit/src/query/react/buildHooks.ts
--- a/packages/toolkit/src/query/react/buildHooks.ts
+++ b/packages/toolkit/src/query/react/buildHooks.ts
@@ -905,16 +905,17 @@ export function buildHooks<Definitions extends EndpointDefinitions>({
const ... | diff --git a/packages/toolkit/src/query/tests/buildHooks.test.tsx b/packages/toolkit/src/query/tests/buildHooks.test.tsx
--- a/packages/toolkit/src/query/tests/buildHooks.test.tsx
+++ b/packages/toolkit/src/query/tests/buildHooks.test.tsx
@@ -3077,6 +3077,48 @@ describe('skip behavior', () => {
expect(getSubscript... | Add missing API ref docs for the `invalidationBehavior` option for `createApi`
We merged https://github.com/reduxjs/redux-toolkit/pull/3116 for the new `invalidationBehavior` setting in RTK 2.0, but never actually covered that in the API docs. Needs to be covered in the `createApi` options.
We do have a docblock with ... | 2024-12-11T02:03:15Z | 2.4 | |
reduxjs/redux-toolkit | 4,869 | reduxjs__redux-toolkit-4869 | [
"4859"
] | 18ddd7eb4515122c5922c67c93f515afe5eeb5eb | diff --git a/packages/toolkit/src/query/core/buildThunks.ts b/packages/toolkit/src/query/core/buildThunks.ts
--- a/packages/toolkit/src/query/core/buildThunks.ts
+++ b/packages/toolkit/src/query/core/buildThunks.ts
@@ -26,6 +26,7 @@ import type {
PageParamFrom,
QueryArgFrom,
QueryDefinition,
+ ResultDescripti... | diff --git a/packages/toolkit/src/query/tests/infiniteQueries.test-d.ts b/packages/toolkit/src/query/tests/infiniteQueries.test-d.ts
--- a/packages/toolkit/src/query/tests/infiniteQueries.test-d.ts
+++ b/packages/toolkit/src/query/tests/infiniteQueries.test-d.ts
@@ -5,6 +5,7 @@ import {
QueryStatus,
} from '@reduxj... | infinite query matchFulfilled returns wrong type
```ts
// api
getInfinityScrollThreads: build.infiniteQuery<GetPostsResponse, Args, number>
// slice
extraReducers: (builder) => {
builder.addMatcher(api.endpoints.getInfiniteQueryPosts.matchFulfilled, (state, action) => {
const payload = action.payload <-- sh... | No, that's presumably an actual bug - I didn't think to update the types for the matchers there. Thanks for catching this!
> No, that's presumably an actual bug - I didn't think to update the types for the matchers there. Thanks for catching this!
same issue:
```ts
providesTags: (result: { pages: GetPostsResponse[], ... | 2025-03-03T04:11:12Z | 2.6 |
reduxjs/redux-toolkit | 4,732 | reduxjs__redux-toolkit-4732 | [
"4240"
] | 4d92026d4a853a3b121400aef19f9cbb5c27d449 | diff --git a/packages/toolkit/src/query/react/buildHooks.ts b/packages/toolkit/src/query/react/buildHooks.ts
--- a/packages/toolkit/src/query/react/buildHooks.ts
+++ b/packages/toolkit/src/query/react/buildHooks.ts
@@ -934,12 +934,13 @@ export function buildHooks<Definitions extends EndpointDefinitions>({
!hasDa... | diff --git a/packages/toolkit/src/query/tests/buildHooks.test.tsx b/packages/toolkit/src/query/tests/buildHooks.test.tsx
--- a/packages/toolkit/src/query/tests/buildHooks.test.tsx
+++ b/packages/toolkit/src/query/tests/buildHooks.test.tsx
@@ -39,6 +39,7 @@ import type { MockInstance } from 'vitest'
// the refetching b... | Unexpected behaviour of isSuccess on second refetch
I have a simple endpoint `getData`
https://stackblitz.com/edit/react-ts-7vwdac?file=App.tsx
```ts
const delay = () => {
return new Promise((resolve) => {
setTimeout(resolve, 500);
});
};
let count = 0;
const api = createApi({
reducerPath: 'ap... | This appears to be intentional behaviour - `useQuery` holds onto the last successful request's `data`, and `isSuccess` is true if it has data and is currently fetching.
I don't fully understand the motivation behind this, though - hopefully somebody else can explain.
https://github.com/reduxjs/redux-toolkit/blob/... | 2024-11-24T00:48:23Z | 2.3 |
reduxjs/redux-toolkit | 4,204 | reduxjs__redux-toolkit-4204 | [
"4203"
] | d712ab34152f011a3859babc3f724f4c74bb325d | diff --git a/packages/toolkit/src/query/react/buildHooks.ts b/packages/toolkit/src/query/react/buildHooks.ts
--- a/packages/toolkit/src/query/react/buildHooks.ts
+++ b/packages/toolkit/src/query/react/buildHooks.ts
@@ -589,7 +589,7 @@ export type MutationTrigger<D extends MutationDefinition<any, any, any, any>> =
... | diff --git a/packages/toolkit/src/query/tests/unionTypes.test-d.ts b/packages/toolkit/src/query/tests/unionTypes.test-d.ts
--- a/packages/toolkit/src/query/tests/unionTypes.test-d.ts
+++ b/packages/toolkit/src/query/tests/unionTypes.test-d.ts
@@ -10,7 +10,7 @@ import type {
TypedUseLazyQuery,
TypedUseLazyQuerySub... | `TypedUseMutationTrigger` should not contain the word "Use"
`TypedUseMutationTrigger` is a helpful wrapper for `MutationTrigger` (thanks for adding it by the way! It resolved an issue I was facing). However, the name is inconsistent. `TypedUseMutation` is a wrapper for `UseMutation`. The extra `Use` breaks the parallel... | 2024-02-14T18:23:15Z | 2.2 | |
reduxjs/redux-toolkit | 4,084 | reduxjs__redux-toolkit-4084 | [
"4058"
] | 37328ca9658b7f10c1d60721ff6ae9758392c021 | diff --git a/packages/rtk-query-codegen-openapi/src/generate.ts b/packages/rtk-query-codegen-openapi/src/generate.ts
--- a/packages/rtk-query-codegen-openapi/src/generate.ts
+++ b/packages/rtk-query-codegen-openapi/src/generate.ts
@@ -278,10 +278,14 @@ export async function generateApi(
).name
);
- con... | diff --git a/packages/rtk-query-codegen-openapi/test/__snapshots__/generateEndpoints.test.ts.snap b/packages/rtk-query-codegen-openapi/test/__snapshots__/generateEndpoints.test.ts.snap
--- a/packages/rtk-query-codegen-openapi/test/__snapshots__/generateEndpoints.test.ts.snap
+++ b/packages/rtk-query-codegen-openapi/tes... | Question/Feature (@rtk-query/codegen-openapi): Support for overriding path-level parameters at operation Level
Hey.
I was trying to set up my query client with the auto generator and noticed that the generated `ApiArg` types are not following the OpenAPI specs for overriding path-level parameters. At least not how I w... | 2024-01-16T15:46:43Z | 2.2 | |
reduxjs/redux-toolkit | 4,082 | reduxjs__redux-toolkit-4082 | [
"2943"
] | b283b1c9d7fc9b7b9bd5729998ab84490db1dbe5 | diff --git a/packages/toolkit/src/query/core/buildMiddleware/cacheLifecycle.ts b/packages/toolkit/src/query/core/buildMiddleware/cacheLifecycle.ts
--- a/packages/toolkit/src/query/core/buildMiddleware/cacheLifecycle.ts
+++ b/packages/toolkit/src/query/core/buildMiddleware/cacheLifecycle.ts
@@ -253,7 +253,9 @@ export co... | diff --git a/packages/toolkit/src/query/tests/useMutation-fixedCacheKey.test.tsx b/packages/toolkit/src/query/tests/useMutation-fixedCacheKey.test.tsx
--- a/packages/toolkit/src/query/tests/useMutation-fixedCacheKey.test.tsx
+++ b/packages/toolkit/src/query/tests/useMutation-fixedCacheKey.test.tsx
@@ -8,8 +8,11 @@ impo... | onCacheEntryAdded doesn't work with fixedCacheKey
**onCacheEntryAdded** is not called when **fixedCacheKey** is specified for mutation ([getCacheKey doesn't handle that case](https://github.com/reduxjs/redux-toolkit/blob/f7a828255e0612bed0856a0b6d1b9b8d6d6ac30d/packages/toolkit/src/query/core/buildMiddleware/cacheLifec... | I have an issue too with **fixedCacheKey** when using it in hooks, it does not seem to have any effect (using the same hook with the same fixedCacheKey and then fetching with the same set of parameters still runs an Ajax query against the server every time)
@Cadrach as a mutation is meant to *change something on the se... | 2024-01-15T10:14:40Z | 2 |
reduxjs/redux-toolkit | 4,055 | reduxjs__redux-toolkit-4055 | [
"2516"
] | 6041460307c2df52d7fc1ed574ff19de9744adf6 | diff --git a/packages/toolkit/src/query/core/apiState.ts b/packages/toolkit/src/query/core/apiState.ts
--- a/packages/toolkit/src/query/core/apiState.ts
+++ b/packages/toolkit/src/query/core/apiState.ts
@@ -83,6 +83,14 @@ export type SubscriptionOptions = {
* How frequently to automatically re-fetch data (in millis... | diff --git a/packages/toolkit/src/query/tests/polling.test.tsx b/packages/toolkit/src/query/tests/polling.test.tsx
--- a/packages/toolkit/src/query/tests/polling.test.tsx
+++ b/packages/toolkit/src/query/tests/polling.test.tsx
@@ -122,4 +122,112 @@ describe('polling tests', () => {
expect(mockBaseQuery.mock.call... | Option to pause Polling when window Unfocused
Sorry if this is a silly question, but is it possible to pause polling on a query if the window loses focus.
I currently have a situation where i need to manually `initiate` a query due to some other bad code where i have used prefetch in a horrible hacky way to bypass c... | Hmm. ~~I don't _think_ there's a way to pause polling atm~~, but I'm also not familiar with that portion of the codebase.
actually, looking at the code...
```ts
if (
api.internalActions.updateSubscriptionOptions.match(action) ||
api.internalActions.unsubscribeQueryResult.match(actio... | 2024-01-09T07:28:44Z | 2 |
reduxjs/redux-toolkit | 3,878 | reduxjs__redux-toolkit-3878 | [
"3875"
] | 0dc7fddacde3097eb2d57379dbf72e3a37c234a3 | diff --git a/packages/toolkit/src/combineSlices.ts b/packages/toolkit/src/combineSlices.ts
--- a/packages/toolkit/src/combineSlices.ts
+++ b/packages/toolkit/src/combineSlices.ts
@@ -8,6 +8,7 @@ import type {
UnionToIntersection,
WithOptionalProp,
} from './tsHelpers'
+import { emplace } from './utils'
type S... | diff --git a/packages/toolkit/src/tests/createSlice.test.ts b/packages/toolkit/src/tests/createSlice.test.ts
--- a/packages/toolkit/src/tests/createSlice.test.ts
+++ b/packages/toolkit/src/tests/createSlice.test.ts
@@ -466,12 +466,15 @@ describe('createSlice', () => {
reducers: {},
selectors: {
s... | Improve `createSlice.selectors` internals
Per @EskiMojo14 :
> we may still want to pull over the emplace and .unwrapped changes . emplace just simplifies some of the map logic we have, and .unwrapped attaches the original selector to the wrapped version
| 2023-11-14T22:58:23Z | 2 | |
reduxjs/redux-toolkit | 3,800 | reduxjs__redux-toolkit-3800 | [
"3799"
] | e657098ad8e8d13e3757b5c2cfe17c594320f6b9 | diff --git a/packages/toolkit/src/mapBuilders.ts b/packages/toolkit/src/mapBuilders.ts
--- a/packages/toolkit/src/mapBuilders.ts
+++ b/packages/toolkit/src/mapBuilders.ts
@@ -166,7 +166,7 @@ export function executeReducerBuilderCallback<S>(
}
if (type in actionsMap) {
throw new Error(
- ... | diff --git a/packages/toolkit/src/tests/createReducer.test.ts b/packages/toolkit/src/tests/createReducer.test.ts
--- a/packages/toolkit/src/tests/createReducer.test.ts
+++ b/packages/toolkit/src/tests/createReducer.test.ts
@@ -460,7 +460,7 @@ describe('createReducer', () => {
.addCase(decrement, (state, ac... | Clarifying error message about type in addCase
I am newbie in RTK and when I met error `'builder.addCase' cannot be called with two reducers for the same action type` I cannot recognize which one of my types is duplcated.
I solved my problem with devtools logpoint but it's not convenient at all
`.
This doesn't currently raise any errors:
- In Typescript, RTK's action creators having a static `type` property mean they conform to t... | 2023-05-02T22:42:26Z | 1.9 | |
reduxjs/redux-toolkit | 3,388 | reduxjs__redux-toolkit-3388 | [
"1045"
] | 4249786f9fe861b84c1c5b8d00b4c007a0605457 | diff --git a/packages/toolkit/src/createAsyncThunk.ts b/packages/toolkit/src/createAsyncThunk.ts
--- a/packages/toolkit/src/createAsyncThunk.ts
+++ b/packages/toolkit/src/createAsyncThunk.ts
@@ -105,7 +105,7 @@ export const miniSerializeError = (value: any): SerializedError => {
return { message: String(value) }
}
... | diff --git a/packages/toolkit/src/tests/createSlice.test.ts b/packages/toolkit/src/tests/createSlice.test.ts
--- a/packages/toolkit/src/tests/createSlice.test.ts
+++ b/packages/toolkit/src/tests/createSlice.test.ts
@@ -1,7 +1,11 @@
import { vi } from 'vitest'
import type { PayloadAction, WithSlice } from '@reduxjs/to... | Suggestion: Define thunk on createSlice
I'm sure this has already been discussed elsewhere, but perhaps not with the following reasoning in mind, so please bear with me :)
One thing that I often come across is the desire to reuse a whole reducer across different parts of the state, so different slices would be the c... | We would desperately like to do this, and we even had a prototype. Unfortunately, it turned out to be basically impossible due to circular TS type definitions. Thunks require knowledge of `RootState` for `getState`, which is formed by looking at the slice reducer state type. But, if you try to define thunks in the sli... | 2023-04-19T01:23:41Z | 2 |
reduxjs/redux-toolkit | 3,188 | reduxjs__redux-toolkit-3188 | [
"3182"
] | 43d94a0b6de88c85c3e7c50bb53f2f4c58e88f4f | diff --git a/packages/toolkit/src/query/react/buildHooks.ts b/packages/toolkit/src/query/react/buildHooks.ts
--- a/packages/toolkit/src/query/react/buildHooks.ts
+++ b/packages/toolkit/src/query/react/buildHooks.ts
@@ -626,9 +626,7 @@ export function buildHooks<Definitions extends EndpointDefinitions>({
)
... | diff --git a/packages/toolkit/src/query/tests/buildHooks.test.tsx b/packages/toolkit/src/query/tests/buildHooks.test.tsx
--- a/packages/toolkit/src/query/tests/buildHooks.test.tsx
+++ b/packages/toolkit/src/query/tests/buildHooks.test.tsx
@@ -9,7 +9,14 @@ import {
QueryStatus,
skipToken,
} from '@reduxjs/toolkit... | RTK Query: Subscription leak in React using useQuery() with skip parameter
There seems to be a subscription leak in RTK Query (1.9.2) with React (18.2).
When using useQuery / useQuerySubscription with the skip parameter, some of the subscriptions randomly won't go away when the component/hook unmounts or the args c... | Interesting! Don't immediately have an idea why this would be happening, but thanks for the report and the repro!
Thanks for the quick reply! I'm actually a little bit unsure whether this is the actual cause of the subscription leakage in our specific situation, as it is fixed by disabling the autoBatchEnhancer. Howeve... | 2023-02-19T18:01:14Z | 1.9 |
reduxjs/redux-toolkit | 3,116 | reduxjs__redux-toolkit-3116 | [
"2203"
] | 1bf2a99d94dd56577c18a40f73fec6ac0abcd5cb | diff --git a/packages/toolkit/src/query/apiTypes.ts b/packages/toolkit/src/query/apiTypes.ts
--- a/packages/toolkit/src/query/apiTypes.ts
+++ b/packages/toolkit/src/query/apiTypes.ts
@@ -45,6 +45,7 @@ export type Module<Name extends ModuleName> = {
| 'refetchOnMountOrArgChange'
| 'refetchOnFocus'
|... | diff --git a/packages/toolkit/src/query/tests/buildSlice.test.ts b/packages/toolkit/src/query/tests/buildSlice.test.ts
--- a/packages/toolkit/src/query/tests/buildSlice.test.ts
+++ b/packages/toolkit/src/query/tests/buildSlice.test.ts
@@ -51,6 +51,7 @@ describe('buildSlice', () => {
api: {
config: {
... | Document how to batch RTK Query mutations properly
I feel that the documentation needs to cover the following scenario.
I have an array of objects that I need to send to the API. The API only allows mutating one object per request. What is a good way to do this while:
- avoiding a race condition where the final c... | From the "endpoint specification" side, there is literally no difference between queries and mutations, apart that queries provideTags and mutations invalidateTags. Doing it with a `queryFn` is a fine way to do it - with exactly the code as you would do with a query.
Thanks, that helped. I was able to get it working us... | 2023-01-23T22:17:12Z | 2 |
reduxjs/redux-toolkit | 3,089 | reduxjs__redux-toolkit-3089 | [
"3591"
] | 44cd3b1fffa2bd556197a2919a5723d7de581859 | diff --git a/docs/virtual/redux-logger/index.ts b/docs/virtual/redux-logger/index.ts
new file mode 100644
--- /dev/null
+++ b/docs/virtual/redux-logger/index.ts
@@ -0,0 +1,7 @@
+import type { Middleware } from 'redux'
+
+declare const logger: Middleware
+
+export { logger }
+
+export default logger
diff --git a/example... | diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -30,7 +30,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
- node: ['16.x']
+ node: ['18.x']
steps:
- name: Checkout repo
@@ -47,7... | [RTK v2.0] createApi (React) exceeds the maximum length the compiler will serialize
Version: `2.0.0-beta.0`
Hello, I'm having an issue inferring types when using `createApi` from `@reduxjs/toolkit/query/react`.
I get this issue with a very minimal setup.
[Code Sandbox link](https://codesandbox.io/p/sandbox/rtk-t... | 2023-01-14T22:43:45Z | 1.2 | |
reduxjs/redux-toolkit | 2,835 | reduxjs__redux-toolkit-2835 | [
"2821"
] | e0a8bd53196ae12c70941355c88082761a57a4cd | diff --git a/packages/toolkit/src/query/createApi.ts b/packages/toolkit/src/query/createApi.ts
--- a/packages/toolkit/src/query/createApi.ts
+++ b/packages/toolkit/src/query/createApi.ts
@@ -249,8 +249,22 @@ export function buildCreateApi<Modules extends [Module<any>, ...Module<any>[]]>(
serializeQueryArgs(query... | diff --git a/packages/toolkit/src/query/tests/createApi.test.ts b/packages/toolkit/src/query/tests/createApi.test.ts
--- a/packages/toolkit/src/query/tests/createApi.test.ts
+++ b/packages/toolkit/src/query/tests/createApi.test.ts
@@ -854,6 +854,16 @@ describe('custom serializeQueryArgs per endpoint', () => {
cons... | Rework `serializeQueryArgs` and export `defaultSerializeQueryArgs`
The new `serializeQueryArgs` option is annoying to use.
We should let you return just a value and use that as the serialization instead.
| 2022-10-28T02:58:17Z | 1.9 | |
reduxjs/redux-toolkit | 2,804 | reduxjs__redux-toolkit-2804 | [
"2619"
] | 82cf232ae3f151df6a43e71149ea7107a9e9e2ca | diff --git a/.yarn/releases/yarn-3.1.0.cjs b/.yarn/releases/yarn-3.1.0.cjs
deleted file mode 100644
--- a/.yarn/releases/yarn-3.1.0.cjs
+++ /dev/null
@@ -1,768 +0,0 @@
-#!/usr/bin/env node
-/* eslint-disable */
-//prettier-ignore
-(()=>{var Mfe=Object.create,Vf=Object.defineProperty,Ofe=Object.defineProperties,Kfe=Obje... | diff --git a/packages/toolkit/src/query/tests/optimisticUpserts.test.tsx b/packages/toolkit/src/query/tests/optimisticUpserts.test.tsx
--- a/packages/toolkit/src/query/tests/optimisticUpserts.test.tsx
+++ b/packages/toolkit/src/query/tests/optimisticUpserts.test.tsx
@@ -182,7 +182,7 @@ describe('basic lifecycle', () =>... | Document any additional 1.9 behavior
Don't think we have docs for `merge` or some of the other options. Need to add those.
| 2022-10-21T03:33:14Z | 1.9 | |
reduxjs/redux-toolkit | 2,595 | reduxjs__redux-toolkit-2595 | [
"2535"
] | f7689133ee56e7787447e6089907fa6d1639b771 | diff --git a/packages/toolkit/src/query/core/buildMiddleware/cacheCollection.ts b/packages/toolkit/src/query/core/buildMiddleware/cacheCollection.ts
--- a/packages/toolkit/src/query/core/buildMiddleware/cacheCollection.ts
+++ b/packages/toolkit/src/query/core/buildMiddleware/cacheCollection.ts
@@ -28,6 +28,13 @@ declar... | diff --git a/packages/toolkit/src/query/tests/cacheCollection.test.ts b/packages/toolkit/src/query/tests/cacheCollection.test.ts
--- a/packages/toolkit/src/query/tests/cacheCollection.test.ts
+++ b/packages/toolkit/src/query/tests/cacheCollection.test.ts
@@ -2,6 +2,10 @@ import { createApi, fetchBaseQuery } from '@redu... | RTK-Query - keepUnusedDataFor has problems with very high values
I use RTK-Query for api fetches in my project, and I've met with an issue I can't fully understand.
Use Case:
I open a modal, once the modal mounts, I call a query endpoint by the auto generated query hook. So this will trigger a couple of actions, ... | That is how it should work. Are you running any mutation that would invalidate that query? Because then instead of refetching it (which would refetch data that is potentially never being displayed again), that data is removed from cache entries without subscribers.
> That is how it should work. Are you running any muta... | 2022-08-14T03:17:01Z | 1.8 |
reduxjs/redux-toolkit | 2,363 | reduxjs__redux-toolkit-2363 | [
"2354"
] | 59dfcd201b65ddcf153e8ed028321e255fd200b3 | diff --git a/packages/toolkit/src/query/fetchBaseQuery.ts b/packages/toolkit/src/query/fetchBaseQuery.ts
--- a/packages/toolkit/src/query/fetchBaseQuery.ts
+++ b/packages/toolkit/src/query/fetchBaseQuery.ts
@@ -4,6 +4,7 @@ import type { BaseQueryApi, BaseQueryFn } from './baseQueryTypes'
import type { MaybePromise, Ov... | diff --git a/packages/toolkit/src/query/tests/fetchBaseQuery.test.tsx b/packages/toolkit/src/query/tests/fetchBaseQuery.test.tsx
--- a/packages/toolkit/src/query/tests/fetchBaseQuery.test.tsx
+++ b/packages/toolkit/src/query/tests/fetchBaseQuery.test.tsx
@@ -181,6 +181,64 @@ describe('fetchBaseQuery', () => {
})... | The responseHandler should respect Content-Type headers
Howdy!
I believe the default responseHandler should be a _little_ more intelligent to handle the response based on the content type header.
For example, in the default Go http package, [you can see it is typical to return a response body of "404 page not fou... | 2022-05-28T02:46:27Z | 1.8 | |
reduxjs/redux-toolkit | 2,225 | reduxjs__redux-toolkit-2225 | [
"2224"
] | 35853a602d467c002731a19c2dcec91c716b7d11 | diff --git a/packages/toolkit/src/query/baseQueryTypes.ts b/packages/toolkit/src/query/baseQueryTypes.ts
--- a/packages/toolkit/src/query/baseQueryTypes.ts
+++ b/packages/toolkit/src/query/baseQueryTypes.ts
@@ -54,7 +54,8 @@ export type BaseQueryEnhancer<
BaseQueryArg<BaseQuery> & AdditionalArgs,
BaseQueryResult<... | diff --git a/packages/toolkit/src/query/tests/baseQueryTypes.typetest.ts b/packages/toolkit/src/query/tests/baseQueryTypes.typetest.ts
new file mode 100644
--- /dev/null
+++ b/packages/toolkit/src/query/tests/baseQueryTypes.typetest.ts
@@ -0,0 +1,33 @@
+import { createApi, fetchBaseQuery, retry } from '@reduxjs/toolkit... | BaseQuery meta types stripped when using retry()
When I wrap the base query into `retry()`, the resulting api is unaware of the meta types.
| 2022-04-10T07:20:44Z | 2.1 | |
reduxjs/redux-toolkit | 2,000 | reduxjs__redux-toolkit-2000 | [
"1996"
] | f86d1e668b680bc3a47b5a488b6abf0d158e58ae | diff --git a/packages/toolkit/src/serializableStateInvariantMiddleware.ts b/packages/toolkit/src/serializableStateInvariantMiddleware.ts
--- a/packages/toolkit/src/serializableStateInvariantMiddleware.ts
+++ b/packages/toolkit/src/serializableStateInvariantMiddleware.ts
@@ -169,41 +169,40 @@ export function createSeria... | diff --git a/packages/toolkit/src/tests/serializableStateInvariantMiddleware.test.ts b/packages/toolkit/src/tests/serializableStateInvariantMiddleware.test.ts
--- a/packages/toolkit/src/tests/serializableStateInvariantMiddleware.test.ts
+++ b/packages/toolkit/src/tests/serializableStateInvariantMiddleware.test.ts
@@ -3... | Why `ignoreActions` and `ignoredActions` overrides `ignoreState`?
I want to check the state but ignore the data that is passed to the action.. But i can`t do that.
Сonfiguration
```
{
ignoreActions: true,
ignoreState: false,
}
```
is identical
```
{
ignoreActions: true,
ignoreState: true,
}... | Yeah, that's a fair point. We should probably restructure the logic here.
@msutkowski , want to try rearranging it so that skipping actions doesn't skip the state? | 2022-02-05T05:07:21Z | 1.7 |
reduxjs/redux-toolkit | 1,984 | reduxjs__redux-toolkit-1984 | [
"1967"
] | fee16b95c521f011e927af3420e05ddd2bd4c5ad | diff --git a/packages/toolkit/src/serializableStateInvariantMiddleware.ts b/packages/toolkit/src/serializableStateInvariantMiddleware.ts
--- a/packages/toolkit/src/serializableStateInvariantMiddleware.ts
+++ b/packages/toolkit/src/serializableStateInvariantMiddleware.ts
@@ -132,9 +132,14 @@ export interface Serializabl... | diff --git a/packages/toolkit/src/tests/serializableStateInvariantMiddleware.test.ts b/packages/toolkit/src/tests/serializableStateInvariantMiddleware.test.ts
--- a/packages/toolkit/src/tests/serializableStateInvariantMiddleware.test.ts
+++ b/packages/toolkit/src/tests/serializableStateInvariantMiddleware.test.ts
@@ -3... | More control over serializableCheck option in middleware?
I'm using redux-toolkit with redux-persist. In order to avoid serialization errors, middleware is configured to ignore redux-persist actions:
```
serializableCheck: {
ignoredActions: [FLUSH, REHYDRATE, PAUSE, PERSIST, PURGE, REGISTER]
},
```
I don'... | 2022-02-01T04:45:11Z | 1.7 | |
reduxjs/redux-toolkit | 1,662 | reduxjs__redux-toolkit-1662 | [
"1024"
] | 1f1164b8bfc499568ec6964faed90f34d583286d | diff --git a/packages/toolkit/src/createReducer.ts b/packages/toolkit/src/createReducer.ts
--- a/packages/toolkit/src/createReducer.ts
+++ b/packages/toolkit/src/createReducer.ts
@@ -66,6 +66,16 @@ export type CaseReducers<S, AS extends Actions> = {
[T in keyof AS]: AS[T] extends Action ? CaseReducer<S, AS[T]> : voi... | diff --git a/packages/toolkit/src/tests/createReducer.test.ts b/packages/toolkit/src/tests/createReducer.test.ts
--- a/packages/toolkit/src/tests/createReducer.test.ts
+++ b/packages/toolkit/src/tests/createReducer.test.ts
@@ -98,8 +98,10 @@ describe('createReducer', () => {
test('Freezes initial state', () => {
... | Add createReducer() with init-state-as-a-lazy-getter overload
In my project, I have a piece of state that may be preloaded from the local storage:
```js
import { loadState } from './storage';
export default createReducer(loadState(), builder => ...);
```
The issue comes when I try to test this reducer because I ... | Hmm. A few thoughts:
- Seems like a mostly reasonable request in general
- I could see this requiring some complexity with the types and overloads
- That would also have to carry through to `createSlice`
- On the other hand: testing reducers is usually just `const actual = reducer(testState, action)`, in which ca... | 2021-10-28T04:17:36Z | 1.6 |
reduxjs/redux-toolkit | 1,496 | reduxjs__redux-toolkit-1496 | [
"1494"
] | 38a93162165ce8f9936423f6ad0234cbdd7f5670 | diff --git a/packages/toolkit/src/createAsyncThunk.ts b/packages/toolkit/src/createAsyncThunk.ts
--- a/packages/toolkit/src/createAsyncThunk.ts
+++ b/packages/toolkit/src/createAsyncThunk.ts
@@ -286,7 +286,7 @@ export type AsyncThunkOptions<
condition?(
arg: ThunkArg,
api: Pick<GetThunkAPI<ThunkApiConfig>,... | diff --git a/packages/toolkit/src/tests/createAsyncThunk.test.ts b/packages/toolkit/src/tests/createAsyncThunk.test.ts
--- a/packages/toolkit/src/tests/createAsyncThunk.test.ts
+++ b/packages/toolkit/src/tests/createAsyncThunk.test.ts
@@ -595,6 +595,32 @@ describe('conditional skipping of asyncThunks', () => {
)
... | Async `condition` in `createAsyncThunk`
I need my thunk to detect that another instance of the same operation is already running and to fulfill the promise (without dispatching any actions) only after that other instance is done. The code that dispatches the thunk doesn't care who started the operation, it just needs i... | Unfortunately, that could be seen as a breaking change.
Right now, `pending` is dispatched synchronously.
That guarantee would get lost. It *might* be possible to work around it somehow so it gets only async if the condition returns a promise, but I fear that would turn `cAT` in an even more unreadable monstrosit... | 2021-09-10T10:42:36Z | 1.6 |
reduxjs/redux-toolkit | 1,520 | reduxjs__redux-toolkit-1520 | [
"1519"
] | 9e772d2bb9434755af0142ee276954338a990e98 | diff --git a/packages/toolkit/src/query/react/buildHooks.ts b/packages/toolkit/src/query/react/buildHooks.ts
--- a/packages/toolkit/src/query/react/buildHooks.ts
+++ b/packages/toolkit/src/query/react/buildHooks.ts
@@ -406,16 +406,17 @@ const queryStatePreSelector = (
lastResult: UseQueryStateDefaultResult<any>
): ... | diff --git a/packages/toolkit/src/query/tests/buildHooks.test.tsx b/packages/toolkit/src/query/tests/buildHooks.test.tsx
--- a/packages/toolkit/src/query/tests/buildHooks.test.tsx
+++ b/packages/toolkit/src/query/tests/buildHooks.test.tsx
@@ -44,9 +44,7 @@ const api = createApi({
}
return {
- data: arg... | isLoading briefly flips back to `true`
> Also: is only for the first fetch of a hook. If you are changing query args, it will never go back to true again. I'm not entirely sure what behaviour you would want there.
@phryneas hi, you say will never go back to true. But when I test the pagination example,when I set p... | 2021-09-17T11:48:54Z | 1.6 | |
python-attrs/attrs | 1,417 | python-attrs__attrs-1417 | [
"1416"
] | 19943b775d40c018e844f2cb1728442f58112a3b | diff --git a/src/attr/_make.py b/src/attr/_make.py
--- a/src/attr/_make.py
+++ b/src/attr/_make.py
@@ -448,7 +448,7 @@ def _transform_attrs(
attrs = base_attrs + own_attrs
if field_transformer is not None:
- attrs = field_transformer(cls, attrs)
+ attrs = tuple(field_transformer(cls, attrs))
... | diff --git a/tests/test_hooks.py b/tests/test_hooks.py
--- a/tests/test_hooks.py
+++ b/tests/test_hooks.py
@@ -217,6 +217,22 @@ class C:
assert "CAttributes" == fields_type.__name__
assert issubclass(fields_type, tuple)
+ def test_hook_generator(self):
+ """
+ Ensure that `attrs.fie... | Creating a Subclassed instance now errors with `got an unexpected keyword argument`
We just noticed this in Airflow CI on upgrading to 25.2.0.
The error is
```
ERROR airflow.models.dagbag.DagBag:dagbag.py:394 Failed to import: /opt/airflow/airflow/example_dags/example_dynamic_task_mapping.py
Traceback (most recent... | https://github.com/python-attrs/attrs/pull/1401 might have caused it
Might do, yes, but the minimal example is not failing, so it's some quirk of what we are doing in Airflow
cc @jamesmurphy-mc
pls provide a repro and I'll see if I can do anything before leaving for my vacation tomorrow afternoon
I updated the example... | 2025-03-12T16:48:42Z | 25.2 |
python-attrs/attrs | 1,410 | python-attrs__attrs-1410 | [
"1354"
] | 6bde3618237cdae312e4e7fb006690be2a3ee0f6 | diff --git a/src/attr/_make.py b/src/attr/_make.py
--- a/src/attr/_make.py
+++ b/src/attr/_make.py
@@ -2491,7 +2491,7 @@ def from_counting_attr(cls, name: str, ca: _CountingAttr, type=None):
if type is None:
type = ca.type
elif ca.type is not None:
- msg = "Type annotation and ... | diff --git a/tests/test_annotations.py b/tests/test_annotations.py
--- a/tests/test_annotations.py
+++ b/tests/test_annotations.py
@@ -62,7 +62,7 @@ class C:
x: int = attr.ib(type=int)
assert (
- "Type annotation and type argument cannot both be present",
+ "Type annota... | unhelpful message "ValueError: Type annotation and type argument cannot both be present"
Getting this message because I both have the type annotation and type defined on a custom attribute class which is reasonable considering the ambiguity.
However I think the message itself could be more helpful by displaying the ... | 2025-02-22T10:44:17Z | 25.1 | |
python-attrs/attrs | 1,383 | python-attrs__attrs-1383 | [
"1313"
] | 103d51f6efa36efcc7be4adecfd571da3f63291c | diff --git a/src/attr/__init__.py b/src/attr/__init__.py
--- a/src/attr/__init__.py
+++ b/src/attr/__init__.py
@@ -10,7 +10,7 @@
from . import converters, exceptions, filters, setters, validators
from ._cmp import cmp_using
from ._config import get_run_validators, set_run_validators
-from ._funcs import asdict, asso... | diff --git a/tests/test_functional.py b/tests/test_functional.py
--- a/tests/test_functional.py
+++ b/tests/test_functional.py
@@ -4,6 +4,7 @@
End-to-end tests.
"""
+import copy
import inspect
import pickle
@@ -16,6 +17,7 @@
import attr
+from attr._compat import PY_3_13_PLUS
from attr._make import NOTHING... | `copy.replace` support
Python 3.13 introduced the `__replace__` dunder, exposed via [`copy.replace`](https://docs.python.org/3.13/library/copy.html#copy.replace), as a [generalised method](https://discuss.python.org/t/generalize-replace-function/28511) through which to replace fields in immutable dataclass-likes. Woul... | Yeah, that sounds super cool! | 2024-12-14T12:23:52Z | 24.2 |
python-attrs/attrs | 1,329 | python-attrs__attrs-1329 | [
"1326"
] | f520d9a89f1fde6fdc5310ffe6c5d4c7467fb10b | diff --git a/src/attr/_compat.py b/src/attr/_compat.py
--- a/src/attr/_compat.py
+++ b/src/attr/_compat.py
@@ -15,6 +15,7 @@
PY_3_10_PLUS = sys.version_info[:2] >= (3, 10)
PY_3_12_PLUS = sys.version_info[:2] >= (3, 12)
PY_3_13_PLUS = sys.version_info[:2] >= (3, 13)
+PY_3_14_PLUS = sys.version_info[:2] >= (3, 14)
... | diff --git a/tests/test_3rd_party.py b/tests/test_3rd_party.py
--- a/tests/test_3rd_party.py
+++ b/tests/test_3rd_party.py
@@ -8,12 +8,17 @@
from hypothesis import given
+from attr._compat import PY_3_14_PLUS
+
from .strategies import simple_classes
cloudpickle = pytest.importorskip("cloudpickle")
+@pyte... | Latest release breaks hypothesis tests in CPython main branch
See https://github.com/python/cpython/issues/122686. Pinning to "attrs<=23.2.0" - a workaround.
| I’m afk, can I have a
[_Short, Self Contained, Correct, Example_](http://sscce.org) please?
Sorry, I didn't deep debugging (yet). If that helps, tracebacks from above job looks like:
```
[...]
File "/home/runner/work/cpython/cpython-builddir/hypovenv/lib/python3.14/site-packages/hypothesis/internal/conjecture/d... | 2024-08-06T10:03:58Z | 24.1 |
python-attrs/attrs | 1,172 | python-attrs__attrs-1172 | [
"1133"
] | 8f4e7e921bbe68e938989385a563a9af28b71f38 | diff --git a/src/attr/__init__.py b/src/attr/__init__.py
--- a/src/attr/__init__.py
+++ b/src/attr/__init__.py
@@ -9,6 +9,7 @@
from . import converters, exceptions, filters, setters, validators
from ._cmp import cmp_using
+from ._compat import Protocol
from ._config import get_run_validators, set_run_validators
f... | diff --git a/tests/test_compat.py b/tests/test_compat.py
--- a/tests/test_compat.py
+++ b/tests/test_compat.py
@@ -4,6 +4,8 @@
import pytest
+import attr
+
@pytest.fixture(name="mp")
def _mp():
@@ -50,3 +52,13 @@ def test_immutable(self, mp):
with pytest.raises(AttributeError, match="no attribute 's... | AttrsInstance is only a Protocol in mypy
`__init__.pyi` defines AttrsInstance as follows:
```
class AttrsInstance(AttrsInstance_, Protocol):
pass
```
So the following typechecks correctly:
```
import attr
from typing import Protocol
class Foo(attr.AttrsInstance, Protocol):
def attribute(self) -> i... | Ah. Looks like a workaround is to do:
```
class Foo(Protocol):
__attrs_attrs__: ClassVar[Any]
def attribute(self) -> int:
...
```
Is this anything we can fix in attrs?
I think just the small change I said, I can make a PR. But probably not until next week.
It should just be:
```
from typing ... | 2023-08-04T15:22:28Z | 23.1 |
python-attrs/attrs | 1,267 | python-attrs__attrs-1267 | [
"709"
] | 0f045cd231f01716c9c81ac78fa2c237c0dd1933 | diff --git a/src/attr/__init__.py b/src/attr/__init__.py
--- a/src/attr/__init__.py
+++ b/src/attr/__init__.py
@@ -15,6 +15,7 @@
from ._make import (
NOTHING,
Attribute,
+ Converter,
Factory,
attrib,
attrs,
@@ -39,6 +40,7 @@ class AttrsInstance(Protocol):
__all__ = [
"Attribute",
... | diff --git a/tests/test_annotations.py b/tests/test_annotations.py
--- a/tests/test_annotations.py
+++ b/tests/test_annotations.py
@@ -277,25 +277,27 @@ def strlen(y: str) -> int:
def identity(z):
return z
- assert attr.converters.pipe(int2str).__annotations__ == {
+ assert attr.co... | Allow three-argument converters (like validators/on_setattr)
I'd like to move the discussion from [converter decorator PR](https://github.com/python-attrs/attrs/pull/404) to this issue.
I think converters are semantically closer to `on_setattr` and `validator` than `default`. E.g. `attr.ib(converter=...)` allows you... | Maybe, converters and validators can (or event should) be merged (similarly to [click callbacks](https://click.palletsprojects.com/en/7.x/options/#callbacks-for-validation))?
```python
def int_validator(self, attrib, value):
return int(value) # Validates and converts at the same time :-)
```
I guess that ... | 2024-03-17T12:19:06Z | 23.2 |
python-attrs/attrs | 1,009 | python-attrs__attrs-1009 | [
"1004"
] | 5ecc39749a98c7ec3fc63b8cbaa82de5eb17c173 | diff --git a/src/attr/_make.py b/src/attr/_make.py
--- a/src/attr/_make.py
+++ b/src/attr/_make.py
@@ -922,7 +922,7 @@ def slots_getstate(self):
"""
Automatically created by attrs.
"""
- return tuple(getattr(self, name) for name in state_attr_names)
+ return ... | diff --git a/tests/test_slots.py b/tests/test_slots.py
--- a/tests/test_slots.py
+++ b/tests/test_slots.py
@@ -9,6 +9,8 @@
import types
import weakref
+from unittest import mock
+
import pytest
import attr
@@ -743,3 +745,58 @@ def f(self):
assert B(11).f == 121
assert B(17).f == 289
+
+
+@attr.s(slo... | Current default implementation of __getstate__ and __setstate__ could be made safer
This is a known "sharp edge" of pickle, but attrs could make this a bit safer by slightly modifying the default implementation of `__getstate__` and `__setstate__`. The problem is that due to returning a tuple in the default implementat... | Have you tried replacing the tuple by the dict and see how much it breaks? Performance difference should be benign, since we save ourselves zipping.
I wanted to get some thoughts on the feasibility of making the change at all first. Let me put together a patch and see how much it breaks, and we can take it from there. ... | 2022-08-16T16:34:33Z | 22.1 |
python-attrs/attrs | 1,319 | python-attrs__attrs-1319 | [
"1284"
] | 689a0e64012d1e576ebd99e786a254bc537582c6 | diff --git a/src/attr/_make.py b/src/attr/_make.py
--- a/src/attr/_make.py
+++ b/src/attr/_make.py
@@ -2207,15 +2207,17 @@ def _attrs_to_init_script(
# leading comma & kw_only args
args += f"{', ' if args else ''}*, {', '.join(kw_only_args)}"
pre_init_kw_only_args = ", ".join(
- [f... | diff --git a/tests/test_make.py b/tests/test_make.py
--- a/tests/test_make.py
+++ b/tests/test_make.py
@@ -694,6 +694,25 @@ def __attrs_pre_init__(self2, y):
assert 12 == getattr(c, "z", None)
+ @pytest.mark.usefixtures("with_and_without_validation")
+ def test_pre_init_kw_only_work_with_defaults(sel... | `kw_only` with `default` breaks `__attrs_pre_init__` call
The following code raises SyntaxError
```python
from attrs import define, field
@define
class A:
a: int = field(kw_only=True, default=3)
def __attrs_pre_init__(self, _):
pass
```
```python
Traceback (most recent call last):
File ... | 2024-08-02T07:12:18Z | 23.2 | |
python-attrs/attrs | 1,122 | python-attrs__attrs-1122 | [
"937"
] | 5a7d978d8a7050961f62159c63fd2b7ad7b1c7d2 | diff --git a/src/attr/validators.py b/src/attr/validators.py
--- a/src/attr/validators.py
+++ b/src/attr/validators.py
@@ -270,15 +270,16 @@ def optional(validator):
which can be set to ``None`` in addition to satisfying the requirements of
the sub-validator.
- :param validator: A validator (or a list of... | diff --git a/tests/test_validators.py b/tests/test_validators.py
--- a/tests/test_validators.py
+++ b/tests/test_validators.py
@@ -384,7 +384,12 @@ def test_repr(self, ifoo):
@pytest.mark.parametrize(
- "validator", [instance_of(int), [always_pass, instance_of(int)]]
+ "validator",
+ [
+ instance_o... | Optional validator should handle a tuple of validators
See relevant discussion in this discussion:
https://github.com/python-attrs/attrs/pull/925#discussion_r827665676
| 2023-04-05T09:13:22Z | 22.2 | |
python-attrs/attrs | 969 | python-attrs__attrs-969 | [
"910"
] | a7e82b5c4121633cff792ed1cbc371843d590960 | diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -39,6 +39,7 @@
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
+ "Programming Language :: Python :: 3.11",
"Programming Language :: Python :: Implementatio... | diff --git a/tests/test_annotations.py b/tests/test_annotations.py
--- a/tests/test_annotations.py
+++ b/tests/test_annotations.py
@@ -94,6 +94,10 @@ class C:
assert 1 == len(attr.fields(C))
assert_init_annotations(C, x=typing.List[int])
+ @pytest.mark.skipif(
+ sys.version_info[:2] < (3, ... | Fix set_closure_cell on 3.11
The fix for 3.11 compatibility (https://github.com/python-attrs/attrs/issues/907).
Maybe hold off on merging until a discussion on BPO.
| I guess we'll have to finish this up before 3.11? :-/
I don't think the other failing tests were related to this, but other 3.11 incompatibilities. Since the beta is out I can revisit this | 2022-06-09T12:31:11Z | 21.4 |
python-attrs/attrs | 806 | python-attrs__attrs-806 | [
"804"
] | 24a2c1e7a5b1b1b979a647de2ef36a35ff4c39a1 | diff --git a/src/attr/_funcs.py b/src/attr/_funcs.py
--- a/src/attr/_funcs.py
+++ b/src/attr/_funcs.py
@@ -319,8 +319,7 @@ def evolve(inst, **changes):
Create a new instance, based on *inst* with *changes* applied.
:param inst: Instance of a class with ``attrs`` attributes.
- :param changes: Keyword chan... | diff --git a/tests/test_funcs.py b/tests/test_funcs.py
--- a/tests/test_funcs.py
+++ b/tests/test_funcs.py
@@ -598,43 +598,50 @@ class C(object):
assert evolve(C(1), a=2).a == 2
- def test_recursive(self):
+ def test_regression_attrs_classes(self):
"""
- evolve() recursively evolves n... | `attr.evolve` no longer supports setting an attr object as attribute
Hi,
I don't know if this is an intentional side-effect of #759, but `attr.evolve` no longer works in the non-recursive recursive case if the argument is an attr class.
Here is a snippet to reproduce it:
```py
import attr
@attr.s
class Cl... | same here. Issue is in attr._funcs.evolve at:
```
for a in attrs:
...
elif has(value):
# Evolve nested attrs classes
changes[init_name] = evolve(value, **changes[init_name])
```
`value` - is old value (param1 from example above)
`changes[init_name]` - is new value (o... | 2021-05-06T12:26:12Z | 21.1 |
python-attrs/attrs | 760 | python-attrs__attrs-760 | [
"593"
] | 78335e9b49eff2eaf2dc31d0bcc3caa0169cfc60 | diff --git a/src/attr/_make.py b/src/attr/_make.py
--- a/src/attr/_make.py
+++ b/src/attr/_make.py
@@ -286,6 +286,36 @@ def attrib(
)
+def _compile_and_eval(script, globs, locs=None, filename=""):
+ """
+ "Exec" the script with the given global (globs) and local (locs) variables.
+ """
+ bytecode =... | diff --git a/tests/test_annotations.py b/tests/test_annotations.py
--- a/tests/test_annotations.py
+++ b/tests/test_annotations.py
@@ -578,3 +578,32 @@ class B:
assert typing.List[B] == attr.fields(A).a.type
assert A == attr.fields(B).a.type
+
+ def test_init_type_hints(self):
+ """
+ ... | Deferred type annotations are evaluated in the wrong execution context
To reproduce, run the following program:
```python
import attr
from typing import List, get_type_hints
@attr.s
class C:
x = attr.ib(type='List[int]')
print(get_type_hints(C.__init__))
```
#### Expected result
```
{'return': <cla... | I'm not sure that's something we can achieve TBH.
I'm having the same problem. Is there any workaround in which the original `__init__.__globals__` can be accessed somehow?
Also, is there any way to know if a `__init__` method was created by `attrs`? (i.e. `is_attrs_init(C.__innit_)`)
PS. You can workaround it ... | 2021-02-16T17:13:15Z | 20.3 |
python-attrs/attrs | 830 | python-attrs__attrs-830 | [
"813",
"813"
] | 2ca7aada707167cda9b3c8bbc2fd195e4f1aa422 | diff --git a/src/attr/converters.py b/src/attr/converters.py
--- a/src/attr/converters.py
+++ b/src/attr/converters.py
@@ -109,3 +109,44 @@ def default_if_none_converter(val):
return default
return default_if_none_converter
+
+
+def to_bool(val):
+ """
+ Convert "boolean" strings (e.g., from e... | diff --git a/tests/test_converters.py b/tests/test_converters.py
--- a/tests/test_converters.py
+++ b/tests/test_converters.py
@@ -4,14 +4,12 @@
from __future__ import absolute_import
-from distutils.util import strtobool
-
import pytest
import attr
from attr import Factory, attrib
-from attr.converters imp... | Python 3.10 deprecation in tests due to distutils
The function is simple enough to be vendored for tests.
```
tests/test_converters.py:7
/root/checked_repos/attrs/tests/test_converters.py:7: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PE... | I‘d add this as
```python
def to_bool(val: Any) -> bool:
"""
Convert "boolean" strings (e.g., from env. vars.) to real booleans.
Values mapping to :code:`True`:
- :code:`True`
- :code:`"true"` / :code:`"t"`
- :code:`"yes"` / :code:`"y"`
- :code:`"on"`
- :code:`"1"`
- :... | 2021-07-07T19:40:01Z | 21.2 |
python-attrs/attrs | 886 | python-attrs__attrs-886 | [
"835"
] | 8ae0bd904d6147ce37750fa7ec336f951c14495c | diff --git a/src/attr/_make.py b/src/attr/_make.py
--- a/src/attr/_make.py
+++ b/src/attr/_make.py
@@ -59,6 +59,8 @@
# Unique object for unequivocal getattr() defaults.
_sentinel = object()
+_ng_default_on_setattr = setters.pipe(setters.convert, setters.validate)
+
class _Nothing(object):
"""
@@ -722,13 +72... | diff --git a/tests/test_functional.py b/tests/test_functional.py
--- a/tests/test_functional.py
+++ b/tests/test_functional.py
@@ -17,7 +17,7 @@
import attr
-from attr._compat import PY2, TYPE
+from attr._compat import PY2, PY36, TYPE
from attr._make import NOTHING, Attribute
from attr.exceptions import FrozenIn... | Clarification - Converters vs on_setattr / Convert automatically when setting
attrs version: 21.2.0
Using the documentation [on Converters](https://www.attrs.org/en/stable/init.html#converters) it was not immediately clear that converters only work on instantiation of a new attrs-enhanced class. (Or I totally misse... | Marking as documentation because `on_setattr` seems to lack narrative docs, and running converters and validators on set as well as init time is probably a common enough use case to warrant some text.
I'm not sure where to put narrative information…should we open a new chapter for it?
I just ran into this behavior that... | 2021-12-13T13:23:03Z | 21.2 |
python-attrs/attrs | 763 | python-attrs__attrs-763 | [
"716"
] | 44ac46114603f8fa7c1142dd338da16c5373d8df | diff --git a/conftest.py b/conftest.py
--- a/conftest.py
+++ b/conftest.py
@@ -23,3 +23,10 @@ def pytest_configure(config):
"tests/test_next_gen.py",
]
)
+if sys.version_info[:2] >= (3, 10):
+ collect_ignore.extend(
+ [
+ "tests/test_mypy.yml",
+ "tests/test_ho... | diff --git a/tests/test_annotations.py b/tests/test_annotations.py
--- a/tests/test_annotations.py
+++ b/tests/test_annotations.py
@@ -4,6 +4,7 @@
Python 3.6+ only.
"""
+import sys
import types
import typing
@@ -11,10 +12,21 @@
import attr
-from attr._make import _classvar_prefixes
+from attr._make import ... | Python 3.10 compatibility
Hello.
We have already started testing RPM packages in Fedora with Python 3.10a2 and attrs is currently not compatible.
The problem is caused by the implementation of [PEP 563](https://www.python.org/dev/peps/pep-0563/#abstract) — type annotations are now stored as strings which cause as... | Do we need to call `attr.resolve_types` first in the test?
Do I understand it correctly that we are waiting for https://github.com/python-attrs/attrs/issues/593 here?
Yes. :(
FTR, when issue 593 is fixed now, I can use `attr.resolve_types(C)` in the `test_basic_annotations` and that makes the previously mentioned `asse... | 2021-02-19T10:58:43Z | 20.3 |
python-attrs/attrs | 684 | python-attrs__attrs-684 | [
"682"
] | dfb2ee284d6229d8bffe6cba6be66a747116cd27 | diff --git a/src/attr/_make.py b/src/attr/_make.py
--- a/src/attr/_make.py
+++ b/src/attr/_make.py
@@ -2185,6 +2185,8 @@ class Attribute(object):
.. versionadded:: 20.1.0 *inherited*
.. versionadded:: 20.1.0 *on_setattr*
+ .. versionchanged:: 20.2.0 *inherited* is not taken into account for
+ equa... | diff --git a/tests/test_make.py b/tests/test_make.py
--- a/tests/test_make.py
+++ b/tests/test_make.py
@@ -691,6 +691,26 @@ def test_sugar_callable(self):
class C(object):
x = attr.ib(factory=Factory(list))
+ def test_inherited_does_not_affect_hashing_and_equality(self):
+ """
... | Inherited attributes of subclasses no longer compare equal to the equivalent attributes of base class
A change between 19.3.0 → 20.1.0 which doesn't seem to be deliberate, but may be related to #635 is that inherited attributes no longer compare equal to the attributes of the base class. Here is a MWE:
```python
im... | Yeah for all practical purposes, I think we've got it wrong ATM. And I think hashing should also not take it into account. Technically it's wrong but in practice I think it makes it useless. | 2020-09-02T05:54:30Z | 20.1 |
python-attrs/attrs | 712 | python-attrs__attrs-712 | [
"703"
] | 6b4a1f1ce65162afe54e7101b263859bf8b2177e | diff --git a/src/attr/_compat.py b/src/attr/_compat.py
--- a/src/attr/_compat.py
+++ b/src/attr/_compat.py
@@ -91,7 +91,7 @@ def metadata_proxy(d):
res.data.update(d) # We blocked update, so we have to do it like this.
return res
- def just_warn(*args, **kw): # pragma: nocover
+ def just_war... | diff --git a/tests/test_next_gen.py b/tests/test_next_gen.py
--- a/tests/test_next_gen.py
+++ b/tests/test_next_gen.py
@@ -4,6 +4,8 @@
import re
+from functools import partial
+
import pytest
import attr
@@ -238,3 +240,32 @@ class B:
@attr.define(on_setattr=attr.setters.validate)
clas... | Frozen Exceptions cannot be thrown from Exception Handler in PyPy
Consider the following code, which generates some random exception, which is then rethrown as a custom attrs exception class (in this case suppressing the context using [PEP 409](https://www.python.org/dev/peps/pep-0409/)'s `from None`):
```python
imp... | 2020-11-04T09:05:46Z | 20.2 | |
python-attrs/attrs | 660 | python-attrs__attrs-660 | [
"645"
] | 428bbcf0d3901b83f96951157351e3716df3a04f | diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -50,9 +50,6 @@
EXTRAS_REQUIRE["dev"] = (
EXTRAS_REQUIRE["tests"] + EXTRAS_REQUIRE["docs"] + ["pre-commit"]
)
-EXTRAS_REQUIRE["azure-pipelines"] = EXTRAS_REQUIRE["tests"] + [
- "pytest-azurepipelines"
-]
######################################... | diff --git a/tests/test_dunders.py b/tests/test_dunders.py
--- a/tests/test_dunders.py
+++ b/tests/test_dunders.py
@@ -68,6 +68,7 @@ def _add_init(cls, frozen):
cache_hash=False,
base_attr_map={},
is_exc=False,
+ has_global_on_setattr=False,
)
return cls
diff --git a/tests/... | [RFC] __setattr__ hooks
There's two things that people keep asking for:
1. validation on setting attributes
2. freezing single attributes
Those two features have something in common: they require `attrs` to write a `__setattr__` method.
I actually had 1 done when I implemented validators but I took it out aga... | I agree not doing validation on attribute set but doing them in `__init__` is probably not reasonable and should be changed.
As for the implementation, it'd be ideal if we generated a smart `__setattr__` like we generate a smart `__init__`. If I were doing it I'd write a function basically containing a chain of `if ... | 2020-07-10T05:48:56Z | 19.3 |
python-attrs/attrs | 607 | python-attrs__attrs-607 | [
"324"
] | 94ad4f39172929a9696670eb03a9151feda63e03 | diff --git a/src/attr/_make.py b/src/attr/_make.py
--- a/src/attr/_make.py
+++ b/src/attr/_make.py
@@ -218,7 +218,7 @@ def attrib(
.. deprecated:: 19.2.0 *cmp* Removal on or after 2021-06-01.
.. versionadded:: 19.2.0 *eq* and *order*
"""
- eq, order = _determine_eq_order(cmp, eq, order)
+ eq, order... | diff --git a/tests/test_make.py b/tests/test_make.py
--- a/tests/test_make.py
+++ b/tests/test_make.py
@@ -5,6 +5,7 @@
from __future__ import absolute_import, division, print_function
import copy
+import functools
import gc
import inspect
import itertools
@@ -29,6 +30,7 @@
_ClassBuilder,
_CountingAttr,... | Auto-detect user-written methods
Currently, if you want to implement a method yourself, you have to remember to do two things:
```python
@attr.s(repr=False)
class C:
def __repr__(self):
return "whatever"
```
I’ve seen quite a few people be confused/frustrated by that.
***
I think unless `th... | 👍
Same with `__init__`? (I ask because the mypy plugin will have to deal with that too.)
The idea is to support it for all of them. It gets a bit hairy when we get to comparison because it’s several ones. Would we stop completely? Or just not replace one of them?
With comparison methods, perhaps [total_ordering](... | 2020-01-03T13:24:16Z | 19.3 |
python-attrs/attrs | 563 | python-attrs__attrs-563 | [
"543"
] | 8174b03b962165278dd65508bf0f947c98a1190a | diff --git a/src/attr/_make.py b/src/attr/_make.py
--- a/src/attr/_make.py
+++ b/src/attr/_make.py
@@ -912,20 +912,20 @@ def wrap(cls):
raise TypeError(
"Invalid value for hash. Must be True, False, or None."
)
- elif hash is False or (hash is None and cmp is False):
+... | diff --git a/tests/test_dark_magic.py b/tests/test_dark_magic.py
--- a/tests/test_dark_magic.py
+++ b/tests/test_dark_magic.py
@@ -515,9 +515,8 @@ class C(object):
@pytest.mark.parametrize("frozen", [True, False])
def test_auto_exc(self, slots, frozen):
"""
- Classes with auto_exc=True have a ... | auto_exc's hashing behavior and its documentation do not match
The [documentation](https://github.com/python-attrs/attrs/blob/25a02bbc7b5309acebda20101125372d42c978db/src/attr/_make.py#L846) for `auto_exc` says:
```
- the values for *cmp* and *hash* are ignored and the instances compare
and hash by the i... | Oh god, are there any docs on Exception hashability? This looks bonkers:
```python
In [7]: hash(Exception()) == hash(Exception())
Out[7]: True
In [8]: hash(Exception(1)) == hash(Exception(1))
Out[8]: True
In [9]: hash(Exception(1)) == hash(Exception(2))
Out[9]: True
In [10]: hash(TypeError(1)) == hash(T... | 2019-08-18T06:46:16Z | 19.1 |
python-attrs/attrs | 586 | python-attrs__attrs-586 | [
"585"
] | 3432df571117386cd7f58db3222ed1dd7fa35d7b | diff --git a/src/attr/_make.py b/src/attr/_make.py
--- a/src/attr/_make.py
+++ b/src/attr/_make.py
@@ -509,7 +509,7 @@ def _patch_original_class(self):
for name in self._attr_names:
if (
name not in base_names
- and getattr(cls, name, _sentinel) != _... | diff --git a/tests/test_annotations.py b/tests/test_annotations.py
--- a/tests/test_annotations.py
+++ b/tests/test_annotations.py
@@ -282,3 +282,18 @@ class C:
with pytest.raises(AttributeError):
C.y
+
+ def test_non_comparable_defaults(self):
+ """
+ Regression test for #585: ... | Couldn't use numpy arrays as defaults on attrs 19.2
The following code stops working when upgrading from attrs 19.1 to 19.2:
```
@attr.s(auto_attribs=True)
class NumParams:
N = 3
alpha = np.zeros((N, Ng))
```
Seems that change #556 requires that default attributes should implement `__eq__`, which is ... | the issue can be resolved by switching the sentinel check from equality to is | 2019-10-14T19:58:16Z | 19.2 |
python-attrs/attrs | 489 | python-attrs__attrs-489 | [
"482"
] | 1a90857109794f27e4cf5914bb9ae4617993e880 | diff --git a/src/attr/_make.py b/src/attr/_make.py
--- a/src/attr/_make.py
+++ b/src/attr/_make.py
@@ -529,6 +529,26 @@ def _patch_original_class(self):
for name, value in self._cls_dict.items():
setattr(cls, name, value)
+ # Attach __setstate__. This is necessary to clear the hash code
+... | diff --git a/tests/test_dunders.py b/tests/test_dunders.py
--- a/tests/test_dunders.py
+++ b/tests/test_dunders.py
@@ -5,6 +5,7 @@
from __future__ import absolute_import, division, print_function
import copy
+import pickle
import pytest
@@ -453,6 +454,83 @@ def __hash__(self):
assert 2 == uncached_ins... | cache_hash can give the wrong hash code for deserialized objects
I just realized a bug in the code I wrote for hash code caching (#426). Because the hash code cache field gets serialized and deserialized by Pickle, when you deserialize a `cache_hash=True` `attrs` object, the hashcode will be the hashcode the object ha... | 2019-01-22T20:01:01Z | 18.2 | |
python-attrs/attrs | 556 | python-attrs__attrs-556 | [
"523"
] | 4a1b3a1436c375c72f80866c6ca145ff0e69086f | diff --git a/src/attr/_make.py b/src/attr/_make.py
--- a/src/attr/_make.py
+++ b/src/attr/_make.py
@@ -42,6 +42,9 @@
_empty_metadata_singleton = metadata_proxy({})
+# Unique object for unequivocal getattr() defaults.
+_sentinel = object()
+
class _Nothing(object):
"""
@@ -504,7 +507,7 @@ def _patch_origina... | diff --git a/tests/test_annotations.py b/tests/test_annotations.py
--- a/tests/test_annotations.py
+++ b/tests/test_annotations.py
@@ -265,3 +265,20 @@ class C(Base):
x: int
assert 1 == C(1).x
+
+ def test_removes_none_too(self):
+ """
+ Regression test for #523: make sure defau... | Attrs deletes any non-None class attributes
Currently, `attrs` will delete any non-`None` class attributes when `_ClassBuilder._delete_attribs` is `True` (i.e. when attributes are specified via class attributes, not directly via `these` field).
According to comment on [_make.py:502](https://github.com/python-attrs/att... | Gosh I'm traveling but isn't the problem just that we need to use a proper/unique sentinel value instead of None here?!
There is totally a bug here, because None and non-None fields should obviously be treated differently.
Removing only `attr.ib`s would work, however the values those fields have are semantically sup... | 2019-07-21T06:23:16Z | 19.1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.