instance_id stringlengths 21 53 | repo stringclasses 188
values | language stringclasses 1
value | pull_number int64 20 148k | title stringlengths 6 144 | body stringlengths 0 83.4k | created_at stringdate 2015-09-25 03:17:17 2025-07-10 16:50:35 | problem_statement stringlengths 188 240k | hints_text stringlengths 0 145k | resolved_issues listlengths 1 6 | base_commit stringlengths 40 40 | commit_to_review dict | reference_review_comments listlengths 1 62 | merged_commit stringlengths 40 40 | merged_patch stringlengths 297 9.87M | metadata dict |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
pytest-dev__pytest-10608@5635bb3 | pytest-dev/pytest | Python | 10,608 | Fix option error | Close #10592
if the cmdline contains both the `--cache-show` and `--help` option will cause the internal error . But if contains the `--collect-only` and `--help` will just output the help message.
the root cause is inside `pytest_cmdline_main` of `cacheprovider` , it will really execute the `wrap_session` , but... | 2022-12-24T03:38:51Z | py.test --cache-show --help triggers an internal error
Hi,
When using `py.test-3 --cache-show --help` or `python3 -m pytest --cache-show --help`, I can reliably trigger an internal error.
The full stack trace is:
```
========================================== test session starts ==============================... | looks like it hasn't handle the exception when fail to parse the options in `config/__init__.py` ,line 1370
```python
except PrintHelp:
pass
```
so it will cause the `config.args_source` is not assigned
one suggestion is just raise the `PrintHelp` exception to the outside caller , handle it in the function `... | [
{
"body": "Hi,\r\n\r\nWhen using `py.test-3 --cache-show --help` or `python3 -m pytest --cache-show --help`, I can reliably trigger an internal error.\r\n\r\nThe full stack trace is:\r\n\r\n```\r\n========================================== test session starts ==========================================\r\nplatfo... | b31db4809be18b43ba714b80b10285b463cc9315 | {
"head_commit": "5635bb3572175a75c2267f8236149e0b83e96aa4",
"head_commit_message": "fix pre-commit",
"patch_to_review": "diff --git a/AUTHORS b/AUTHORS\nindex a4ca9926760..4a87b89e74c 100644\n--- a/AUTHORS\n+++ b/AUTHORS\n@@ -377,6 +377,7 @@ Xixi Zhao\n Xuan Luong\n Xuecong Liao\n Yoav Caspi\n+Yuliang Shao\n Yus... | [
{
"diff_hunk": "@@ -0,0 +1 @@\n+Fix the bug \"--cache-show --help\" triggers an internal error",
"line": null,
"original_line": 1,
"original_start_line": null,
"path": "changelog/10592.bugfix.rst",
"start_line": null,
"text": "@user1:\n```suggestion\r\nFixed crash if `--cache-show` and `... | 8bc96d4aa86873e37d354278c7620bc1887f796d | diff --git a/AUTHORS b/AUTHORS
index a4ca9926760..4a87b89e74c 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -377,6 +377,7 @@ Xixi Zhao
Xuan Luong
Xuecong Liao
Yoav Caspi
+Yuliang Shao
Yusuke Kadowaki
Yuval Shimon
Zac Hatfield-Dodds
diff --git a/changelog/10592.bugfix.rst b/changelog/10592.bugfix.rst
new file mode 100644
... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} |
pytest-dev__pytest-10664@ee57a2a | pytest-dev/pytest | Python | 10,664 | Check if config args and args_source exist | Closes #10626
<!--
Thanks for submitting a PR, your contribution is really appreciated!
Here is a quick checklist that should be present in PRs.
- [ ] Include documentation when adding new features.
- [ ] Include new tests or update existing tests when applicable.
- [X] Allow maintainers to push and squash w... | 2023-01-14T19:37:48Z | Exception on `pytest --fixture --help`
## minimal example
```python-traceback
$ pytest --fixtures --help
=============== test session starts ===============
platform darwin -- Python 3.11.0, pytest-7.2.0, pluggy-1.0.0
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR> File "/private/tmp/foo/.ve... | Can I take this issue up? @Zac-HD
@Pierre-Sassoulas can you give me a **short guidance** on how to start contributing. I have already done the setup and followed the contribution page. I just wanted to have a guidance on start so I can proceed on my own.
Really Grateful.
Thank You
Do you have a particular question, ... | [
{
"body": "## minimal example\r\n\r\n```python-traceback\r\n$ pytest --fixtures --help\r\n=============== test session starts ===============\r\nplatform darwin -- Python 3.11.0, pytest-7.2.0, pluggy-1.0.0\r\nINTERNALERROR> Traceback (most recent call last):\r\nINTERNALERROR> File \"/private/tmp/foo/.venv/lib... | 4d4ed42c34fbd6b30bff1bbdf664aeac3300a83a | {
"head_commit": "ee57a2ad451e813b99ac49e8ead1657f57b8d420",
"head_commit_message": "Check if config args and args_source exist",
"patch_to_review": "diff --git a/AUTHORS b/AUTHORS\nindex 7cf1748e606..f345c0cab93 100644\n--- a/AUTHORS\n+++ b/AUTHORS\n@@ -290,6 +290,7 @@ Prashant Sharma\n Pulkit Goyal\n Punyashlok... | [
{
"diff_hunk": "@@ -0,0 +1 @@\n+Check if ``Config.args`` and ``Config.args_source`` exist.",
"line": null,
"original_line": 1,
"original_start_line": null,
"path": "changelog/10626.bugfix.rst",
"start_line": null,
"text": "@user1:\n```suggestion\r\nFix crash if ``--fixtures`` and ``--hel... | 656fafc7434fbf5debe97f7db268b07cd4becbf0 | diff --git a/AUTHORS b/AUTHORS
index 7cf1748e606..f345c0cab93 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -290,6 +290,7 @@ Prashant Sharma
Pulkit Goyal
Punyashloka Biswal
Quentin Pradet
+q0w
Ralf Schmitt
Ralph Giles
Ram Rachum
diff --git a/changelog/10626.bugfix.rst b/changelog/10626.bugfix.rst
new file mode 100644
ind... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} |
pytest-dev__pytest-10758@3e90bf5 | pytest-dev/pytest | Python | 10,758 | Fix different behavior with unittest when warlus operator | The `AssertionRewriter` class did not handle the assertions with the `ast.NamedExpr` (aka 'walrus operator'), that changed the value of a variable used in the assertion (an example can be seen in the related issue or in the tests added).
This caused different behavior from unittest/python and pytest.
This PR aim... | 2023-02-22T21:43:37Z | Walrus operator causes different behavior in PyTest.
I am currently testing the following function but find that the function passes the test in the normal Python terminal but fails in a PyTest run. The walrus operator is relatively new and not many people use it. I think that there may be an inconsistency in the execu... | It's very likely a missed case in the asset rewrite
Hi, I did some tests on this since I was curious about how this works.
I created a module like this
```
def my_func(before, after):
return before == after
def change_value(value):
return value.lower()
def test_walrus_conversion():
a = "Hel... | [
{
"body": "I am currently testing the following function but find that the function passes the test in the normal Python terminal but fails in a PyTest run. The walrus operator is relatively new and not many people use it. I think that there may be an inconsistency in the execution environment.\r\n\r\n```\r\nim... | d5dda84ef346b83e0b634a92e00c62a8a10e0061 | {
"head_commit": "3e90bf573f4415e6b34b9187f625ef265d634aeb",
"head_commit_message": "add version check for py<38",
"patch_to_review": "diff --git a/AUTHORS b/AUTHORS\nindex 0395feceb60..448b71d3a8a 100644\n--- a/AUTHORS\n+++ b/AUTHORS\n@@ -12,6 +12,7 @@ Adam Uhlir\n Ahn Ki-Wook\n Akiomi Kamakura\n Alan Velasco\n+... | [
{
"diff_hunk": "@@ -1265,6 +1265,163 @@ def test_simple_failure():\n result.stdout.fnmatch_lines([\"*E*assert (1 + 1) == 3\"])\n \n \n+@pytest.mark.skipif(\n+ sys.version_info < (3, 8), reason=\"walrus operator not available in py<38\"\n+)\n+class TestIssue10743:\n+ def test_assertion_walrus_opera... | ea18dd80bcf0b8d332aa395822eefdfbcb5b060f | diff --git a/AUTHORS b/AUTHORS
index 0395feceb60..448b71d3a8a 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -12,6 +12,7 @@ Adam Uhlir
Ahn Ki-Wook
Akiomi Kamakura
Alan Velasco
+Alessio Izzo
Alexander Johnson
Alexander King
Alexei Kozlenok
diff --git a/changelog/10743.bugfix.rst b/changelog/10743.bugfix.rst
new file mode 1... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} |
onnx__onnx-5741@ef609cb | onnx/onnx | Python | 5,741 | Fix corner case where output size need to reduce by one in MaxPool | ### Description
fix https://github.com/onnx/onnx/issues/5711 where output size shall not increase fully to padding part of the input region in ceil mode
### Motivation and Context
bug fix | 2023-11-08T05:38:57Z | MaxPool should be corrected and documented properly
# Bug Report
### Is the issue related to model conversion?
Yes and No
### Describe the bug
When I run the single node model with kernel_size 1*1, the ceil_mode docent make any sense. The output shape should always be floor.
### System information
- OS Plat... | It is true this is a bug in converter. I think ONNX shall have test cases to cover this and Torch exporter and ORT shall implement the correct behavior.
~~Hi @liqunfu @gramalingam ,~~
~~https://github.com/pytorch/pytorch/issues/113155~~
~~This is the same issue as https://github.com/microsoft/onnxruntime/issues... | [
{
"body": "# Bug Report\r\n\r\n### Is the issue related to model conversion?\r\nYes and No\r\n\r\n### Describe the bug\r\nWhen I run the single node model with kernel_size 1*1, the ceil_mode docent make any sense. The output shape should always be floor.\r\n\r\n### System information\r\n- OS Platform and Distri... | 8a6b70f0adcff5409b8cd65883bbbea7d6c4f4e1 | {
"head_commit": "ef609cb78a3d55fbd11ffc601051da73433e9755",
"head_commit_message": "bumpup lintrunner-adapter version\n\nSigned-off-by: Liqun Fu <liqfu@microsoft.com>",
"patch_to_review": "diff --git a/docs/Changelog.md b/docs/Changelog.md\nindex 9baf467e095..daf07f1b303 100644\n--- a/docs/Changelog.md\n+++ b/do... | [
{
"diff_hunk": "@@ -87,6 +87,10 @@ def _max_pool( # type: ignore\n + 1\n )\n )\n+ if (output_spatial_shape[i] - 1) * strides[i] >= input_spatial_shape[\n+ i\n+ ] + new_pads[i][0]:",
"line": null,
... | d5ee3590ab3eaa040d78533727c650749ca42030 | diff --git a/docs/Changelog.md b/docs/Changelog.md
index 4ffb6d1acb9..eb9d2035cbc 100644
--- a/docs/Changelog.md
+++ b/docs/Changelog.md
@@ -14497,7 +14497,7 @@ This version of the operator has been available since version 12 of the default
```
output_spatial_shape[i] = ceil((input_spatial_shape[i] + pad_shape[... | {
"difficulty": "medium",
"estimated_review_effort": 4,
"problem_domain": "Bug Fixes"
} |
onnx__onnx-5617@509c58a | onnx/onnx | Python | 5,617 | Clarify `cond` to `If` must contain a single element | ### Description
Clarify `cond` to `If` must contain a single element. Previously it is unclear what the condition can be.
Fix reference runtime accordingly.
### Motivation and Context
Fixes https://github.com/onnx/onnx/issues/5520 | 2023-09-22T22:42:11Z | Non scalar as condition to If op
# Ask a Question
### Question
<!-- -->
I write a onnx If op case, the condition input is np.array([1, 2, 0, 3]).astype(bool), the output is then_branch, if input is np.array([0, 2, 0, 3]).astype(bool), the output is else_branch, so from result, it looks like the first element decid... | When do we expect the cond in if is not a scalar Boolean?
> When do we expect the cond in if is not a scalar Boolean?
in real case, the front operator may give a non scalar boolean tensor to If operator, so I want to know onnx if operator how to handle nonscalar boolean tensor
Possible to just take the boolean out? ... | [
{
"body": "# Ask a Question\r\n\r\n### Question\r\n<!-- -->\r\nI write a onnx If op case, the condition input is np.array([1, 2, 0, 3]).astype(bool), the output is then_branch, if input is np.array([0, 2, 0, 3]).astype(bool), the output is else_branch, so from result, it looks like the first element decides Tru... | 47eca61267b5da76324d54d349f9dc2b712e74f0 | {
"head_commit": "509c58ad66e3832312aba71ff531b5f42c525fb4",
"head_commit_message": "Update onnx/reference/ops/op_if.py\n\nSigned-off-by: Justin Chu <justinchuby@users.noreply.github.com>",
"patch_to_review": "diff --git a/docs/Changelog.md b/docs/Changelog.md\nindex ffb2175d7e7..93f36c5f512 100644\n--- a/docs/Ch... | [
{
"diff_hunk": "@@ -23,28 +26,20 @@ def need_context(self) -> bool:\n \"\"\"\n return True\n \n- def _run(self, cond, context=None, else_branch=None, then_branch=None, attributes=None): # type: ignore\n- if len(cond.shape) > 0:\n- try:\n- evaluated_condition ... | 8fa3d98e3fbcee427ae9aaed1f98559c228055fb | diff --git a/docs/Changelog.md b/docs/Changelog.md
index ffb2175d7e7..93f36c5f512 100644
--- a/docs/Changelog.md
+++ b/docs/Changelog.md
@@ -1579,7 +1579,7 @@ This version of the operator has been available since version 1 of the default O
<dl>
<dt><tt>cond</tt> : B</dt>
-<dd>Condition for the if</dd>
+<dd>Conditio... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} |
pydantic__pydantic-10621@b2b75a3 | pydantic/pydantic | Python | 10,621 | Support usage of `type` with `typing.Self` and type aliases | <!-- Thank you for your contribution! -->
<!-- Unless your change is trivial, please create an issue to discuss the change before creating a PR -->
## Change Summary
Fix errors caused by these:
```py
TypeAdapter(type[Self])
type MyInt = int
TypeAdapter(type[MyInt])
```
<!-- Please give a short summary ... | 2024-10-14T12:09:34Z | `type[Self]` raises TypeError in pydantic-core
### Initial Checks
- [X] I confirm that I'm using Pydantic V2
### Description
### Traceback
```
Traceback (most recent call last):
File "C:\Users\kchon\OneDrive\Desktop\pydantic\new.py", line 7, in <module>
class A(BaseModel):
File "C:\Users\kchon\OneDriv... | [
{
"body": "### Initial Checks\n\n- [X] I confirm that I'm using Pydantic V2\n\n### Description\n\n### Traceback\r\n\r\n```\r\nTraceback (most recent call last):\r\n File \"C:\\Users\\kchon\\OneDrive\\Desktop\\pydantic\\new.py\", line 7, in <module>\r\n class A(BaseModel):\r\n File \"C:\\Users\\kchon\\OneDr... | 7bb0e0affb8c16dd84580b443ea65f52c418273f | {
"head_commit": "b2b75a3e6c95c1047d31c9287163743157f00094",
"head_commit_message": "Apply suggestions from code review\n\nCo-authored-by: Victorien <65306057+Viicos@users.noreply.github.com>",
"patch_to_review": "diff --git a/pydantic/_internal/_generate_schema.py b/pydantic/_internal/_generate_schema.py\nindex ... | [
{
"diff_hunk": "@@ -866,7 +870,10 @@ def _get_args_resolving_forward_refs(self, obj: Any) -> tuple[Any, ...] | None:\n def _get_args_resolving_forward_refs(self, obj: Any, required: bool = False) -> tuple[Any, ...] | None:\n args = get_args(obj)\n if args:\n- args = tuple([self._r... | 12a9c265217d2a6a9c8f9bd05202cf3444c397c7 | diff --git a/pydantic/_internal/_generate_schema.py b/pydantic/_internal/_generate_schema.py
index 82b78722785..05058342aab 100644
--- a/pydantic/_internal/_generate_schema.py
+++ b/pydantic/_internal/_generate_schema.py
@@ -767,6 +767,12 @@ def _unpack_refs_defs(self, schema: CoreSchema) -> CoreSchema:
re... | {
"difficulty": "medium",
"estimated_review_effort": 4,
"problem_domain": "Bug Fixes"
} | |
pydantic__pydantic-10602@9a2ad3c | pydantic/pydantic | Python | 10,602 | Add benchmarks for schema generation with recursive models | <!-- Thank you for your contribution! -->
<!-- Unless your change is trivial, please create an issue to discuss the change before creating a PR -->
## Change Summary
<!-- Please give a short summary of the changes. -->
A suite of benchmarks for schema generation was added when recursive models were present.
... | 2024-10-11T02:45:25Z | Expand breadth of benchmarks
We have a robust benchmark test suite in `pydantic-core`, but are lacking similar coverage in `pydantic`.
Specifically, I'm interested in expanding this test suite in relation to our core schema build times, as we're looking to improve performance there in the short term. Secondarily, I'... | Do you have a plan on what general areas we want to focus on increasing benchmark coverage? (i.e. serialization, deserialization, import, validation, etc)
Any of these would be great. I'd say the most pressing category is model schema generation, but we'd more than welcome additional benchmarks for cases of validation ... | [
{
"body": "We have a robust benchmark test suite in `pydantic-core`, but are lacking similar coverage in `pydantic`.\r\n\r\nSpecifically, I'm interested in expanding this test suite in relation to our core schema build times, as we're looking to improve performance there in the short term. Secondarily, I'm inte... | 2b2dffcc5cf8cb01116a87c1c8072a6ee63ba159 | {
"head_commit": "9a2ad3c2cf73a0100db411254aa7d854ad5986ab",
"head_commit_message": "fix: use Dict instead of dict",
"patch_to_review": "diff --git a/tests/benchmarks/test_model_schema_generation.py b/tests/benchmarks/test_model_schema_generation.py\nindex 5dc52b37936..359baa820b6 100644\n--- a/tests/benchmarks/t... | [
{
"diff_hunk": "@@ -307,3 +307,115 @@ class PydanticTypeModel(DeferredModel):\n field: field_type\n \n benchmark(rebuild_model, PydanticTypeModel)\n+\n+\n+@pytest.mark.benchmark(group='model_schema_generation')\n+def test_simple_recursive_model_schema_generation(benchmark):\n+ class Foo(DeferredM... | 1a83e244c45c21cf935312caa1b3906b79bff745 | diff --git a/tests/benchmarks/shared.py b/tests/benchmarks/shared.py
index 8faa1d7ff0c..d84192bafe9 100644
--- a/tests/benchmarks/shared.py
+++ b/tests/benchmarks/shared.py
@@ -231,3 +231,11 @@ class Foo:
FutureDate,
PastDatetime,
]
+
+
+class DeferredModel(BaseModel):
+ model_config = {'defer_build': Tru... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Test Suite / CI Enhancements"
} |
pydantic__pydantic-10601@7855225 | pydantic/pydantic | Python | 10,601 | Improve email regexp on edge cases | - Drastically improves performance on cases like `"<" + " " * N`
- Last spaces are not needed anyway because this group is stripped later. Also spaces will be caught by `.` anyway.
<!-- Thank you for your contribution! -->
<!-- Unless your change is trivial, please create an issue to discuss the change before crea... | 2024-10-10T20:54:55Z | Email parsing slowdown on edgecases
### Initial Checks
- [X] I confirm that I'm using Pydantic V2
### Description
I found that current pydantic-level regexp is not optimal and may cause unexpected slowdowns on some edgecases. Email strings like `< ` (+many spaces).
POC below shows it. You can run it with... | [
{
"body": "### Initial Checks\n\n- [X] I confirm that I'm using Pydantic V2\n\n### Description\n\nI found that current pydantic-level regexp is not optimal and may cause unexpected slowdowns on some edgecases. Email strings like `< ` (+many spaces). \r\n\r\nPOC below shows it. You can run it with comman... | c772b43edb952c5fe54bb28da5124b10d5470caf | {
"head_commit": "7855225abbf86c4168832d66f67fd367abcc3569",
"head_commit_message": "Improve email regexp on edge cases\n\n- Drastically improves performance on cases like `\"<\" + \" \" * N`\n- Last spaces are not needed anyway because this group is\nstripped later. Also spaces will be caught by `.` anyway.",
"p... | [
{
"diff_hunk": "@@ -722,7 +722,7 @@ def _build_pretty_email_regex() -> re.Pattern[str]:\n name_chars = r'[\\w!#$%&\\'*+\\-/=?^_`{|}~]'\n unquoted_name_group = rf'((?:{name_chars}+\\s+)*{name_chars}+)'\n quoted_name_group = r'\"((?:[^\"]|\\\")+)\"'\n- email_group = r'<\\s*(.+)\\s*>'\n+ email_gr... | e35c507dca80ce44a96c12dbdae9c686e8d36236 | diff --git a/pydantic/networks.py b/pydantic/networks.py
index 256f2bf1e4d..a8ed1e248d3 100644
--- a/pydantic/networks.py
+++ b/pydantic/networks.py
@@ -722,7 +722,7 @@ def _build_pretty_email_regex() -> re.Pattern[str]:
name_chars = r'[\w!#$%&\'*+\-/=?^_`{|}~]'
unquoted_name_group = rf'((?:{name_chars}+\s+)*... | {
"difficulty": "low",
"estimated_review_effort": 2,
"problem_domain": "Performance Optimizations"
} | |
pydantic__pydantic-10597@7dda23b | pydantic/pydantic | Python | 10,597 | Add note to documentation of `PlainValidator` regarding JSON schemas | Closes https://github.com/pydantic/pydantic/issues/10528 | 2024-10-10T15:35:32Z | Annotated field schemas broken after v2.9.0
### Initial Checks
- [X] I confirm that I'm using Pydantic V2
### Description
Following example shows how `Annotated` fields lost their schema `type` and `format` after v2.9.0
I can not see a mention of a such breaking change in changelog.
### Example Code
```Python
f... | @MarkusSintonen,
Thanks for reporting this. We're looking into this now!
Hi @MarkusSintonen,
Turns out this was an oversight when we implemented https://github.com/pydantic/pydantic/issues/8208 through https://github.com/pydantic/pydantic/pull/10094.
We expected JSON Schemas for fields with `PlainValidator` to... | [
{
"body": "### Initial Checks\n\n- [X] I confirm that I'm using Pydantic V2\n\n### Description\n\nFollowing example shows how `Annotated` fields lost their schema `type` and `format` after v2.9.0\r\n\r\nI can not see a mention of a such breaking change in changelog.\n\n### Example Code\n\n```Python\nfrom dateti... | 09ade35da9f6795ef455fe16a86792df6305a36e | {
"head_commit": "7dda23b8bda2d24a4ec6b7c366c7bd526af3f142",
"head_commit_message": "docs formatting",
"patch_to_review": "diff --git a/pydantic/functional_validators.py b/pydantic/functional_validators.py\nindex 603400c7978..cda3f28e507 100644\n--- a/pydantic/functional_validators.py\n+++ b/pydantic/functional_v... | [
{
"diff_hunk": "@@ -163,25 +163,45 @@ class PlainValidator:\n \n A metadata class that indicates that a validation should be applied **instead** of the inner validation logic.\n \n+ !!! note:\n+ Before v2.9, `PlainValidator` wasn't always compatible with JSON Schema generation for `mode='validatio... | bac8b2c2a06b99c94bffcff1b50e529778c61498 | diff --git a/pydantic/functional_validators.py b/pydantic/functional_validators.py
index 603400c7978..aafc9ba4c7a 100644
--- a/pydantic/functional_validators.py
+++ b/pydantic/functional_validators.py
@@ -163,6 +163,11 @@ class PlainValidator:
A metadata class that indicates that a validation should be applied *... | {
"difficulty": "low",
"estimated_review_effort": 1,
"problem_domain": "Bug Fixes"
} |
pydantic__pydantic-10595@2008818 | pydantic/pydantic | Python | 10,595 | Expose public `sort` method for JSON schema generation | Closes https://github.com/pydantic/pydantic/issues/7580
At first, thought we might have to add a flag to fix this. The way I feel about adding flags at this point is about how [edna (from The Incredibles) feels about capes](https://www.youtube.com/watch?v=YL3w73MAuIM&ab_channel=EntertainmentAccess).
Luckily, was ... | 2024-10-10T14:28:56Z | Order of keys differs in schema output
### Initial Checks
- [X] I confirm that I'm using Pydantic V2
### Description
When a model is specified as a Field and the values are instantiated , the keys are output in sorted order. I would expect that the order of the keys be maintained.
See sample code below. The outpu... | update , i checked the code and the source seems to be
https://github.com/pydantic/pydantic/blob/8f3ac4e30845957d79a12e8963fa37bfa0c9b811/pydantic/json_schema.py#L439
it would be nice to have a flag that also allows non sorted schema output.
https://github.com/pydantic/pydantic/blob/8f3ac4e30845957d79a12e8963... | [
{
"body": "### Initial Checks\n\n- [X] I confirm that I'm using Pydantic V2\n\n### Description\n\nWhen a model is specified as a Field and the values are instantiated , the keys are output in sorted order. I would expect that the order of the keys be maintained.\r\n\r\nSee sample code below. The output of the c... | eb4110e4b1eff77cb3ea7ed487baa045d4b05890 | {
"head_commit": "20088187bb40a87219c637a25650f26308452480",
"head_commit_message": "typo",
"patch_to_review": "diff --git a/docs/concepts/json_schema.md b/docs/concepts/json_schema.md\nindex e889ccb0fd6..63cfb3297af 100644\n--- a/docs/concepts/json_schema.md\n+++ b/docs/concepts/json_schema.md\n@@ -1414,6 +1414,... | [
{
"diff_hunk": "@@ -556,6 +556,38 @@ def new_handler_func(\n json_schema = populate_defs(schema, json_schema)\n return json_schema\n \n+ def sort(self, value: JsonSchemaValue, parent_key: str | None = None) -> JsonSchemaValue:\n+ \"\"\"Override this method to customize the sorting ... | 12cc428d65120a6990ebcdf7fe1c9dec84eac1f4 | diff --git a/docs/concepts/json_schema.md b/docs/concepts/json_schema.md
index e889ccb0fd6..63cfb3297af 100644
--- a/docs/concepts/json_schema.md
+++ b/docs/concepts/json_schema.md
@@ -1414,6 +1414,68 @@ print(validation_schema)
"""
```
+### JSON schema sorting
+
+By default, Pydantic recursively sorts JSON schemas... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} |
pydantic__pydantic-10490@223b42a | pydantic/pydantic | Python | 10,490 | Fix annotation application issue with non numeric constraints | Fix https://github.com/pydantic/pydantic/issues/10459
Sort of reverting my refactor from https://github.com/pydantic/pydantic/pull/9999. I think the smaller functions (though redundant) make this much more readable. | 2024-09-25T19:07:36Z | TypeError when using BeforeValidator
### Initial Checks
- [X] I confirm that I'm using Pydantic V2
### Description
Since pydantic 2.9.0 (this did _not_ happen in 2.8.2), using a `BeforeValidator()` _before_ constraints from `annotated_types` raises a `TypeError`. I tested this with 2.8.2, 2.9.0 and 2.9.2, and the is... | Looks like an issue with annotation application, will look into this today! | [
{
"body": "### Initial Checks\n\n- [X] I confirm that I'm using Pydantic V2\n\n### Description\n\nSince pydantic 2.9.0 (this did _not_ happen in 2.8.2), using a `BeforeValidator()` _before_ constraints from `annotated_types` raises a `TypeError`. I tested this with 2.8.2, 2.9.0 and 2.9.2, and the issue was intr... | c9190eedd8c536cd1445876c4a078c29b04d3aa1 | {
"head_commit": "223b42a2c6d85e9613db1940e376710bfbc9328b",
"head_commit_message": "revert and fix",
"patch_to_review": "diff --git a/pydantic/_internal/_known_annotated_metadata.py b/pydantic/_internal/_known_annotated_metadata.py\nindex b34ece10d96..73a9d2e729d 100644\n--- a/pydantic/_internal/_known_annotated... | [
{
"diff_hunk": "@@ -253,57 +252,92 @@ def forbid_inf_nan_check(x: Any) -> Any:\n return x\n \n \n-_InputType = typing.TypeVar('_InputType')\n+def _safe_repr(v: Any) -> int | float | str:\n+ \"\"\"The context argument for `PydanticKnownError` requires a number or str type, so we do a simple repr() coercio... | 0d7c68e2ea1cec9de5da11c062918700993229e1 | diff --git a/pydantic/_internal/_known_annotated_metadata.py b/pydantic/_internal/_known_annotated_metadata.py
index b34ece10d96..73a9d2e729d 100644
--- a/pydantic/_internal/_known_annotated_metadata.py
+++ b/pydantic/_internal/_known_annotated_metadata.py
@@ -279,7 +279,7 @@ def _apply_constraint_with_incompatibility_... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} |
pytest-dev__pytest-10356@c42bb36 | pytest-dev/pytest | Python | 10,356 | fix #7792: consider marks from the mro | fixes #7792
closes #9105 as superseeded
adding extra reviewers as this can be seen as breaking change wrt the contents of the pytestmark attribute
it may be necessary (and a good idea) to start to deprecate pytestmark as name and start using a private name as a follow up | 2022-10-08T06:20:42Z | Consider MRO when obtaining marks for classes
When using pytest markers in two baseclasses `Foo` and `Bar`, inheriting from both of those baseclasses will lose the markers of one of those classes. This behavior is present in pytest 3-6, and I think it may as well have been intended. I am still filing it as a bug becaus... | ronny has already refactored this multiple times iirc, but I wonder if it would make sense to store markers as `pytestmark_foo` and `pytestmark_bar` on the class instead of in one `pytestmark` array, that way you can leverage regular inheritance rules
Thanks for bringing this to attention, pytest show walk the mro of a... | [
{
"body": "When using pytest markers in two baseclasses `Foo` and `Bar`, inheriting from both of those baseclasses will lose the markers of one of those classes. This behavior is present in pytest 3-6, and I think it may as well have been intended. I am still filing it as a bug because I am not sure if this edg... | 3c1534944cbd34e8a41bc9e76818018fadefc9a1 | {
"head_commit": "c42bb36009445e0cf1915dd5d1b762639a710675",
"head_commit_message": "fixup: mark mro test reformatt",
"patch_to_review": "diff --git a/changelog/7792.bugfix.rst b/changelog/7792.bugfix.rst\nnew file mode 100644\nindex 00000000000..00e09ebe849\n--- /dev/null\n+++ b/changelog/7792.bugfix.rst\n@@ -0,... | [
{
"diff_hunk": "@@ -355,12 +355,29 @@ def __call__(self, *args: object, **kwargs: object):\n return self.with_args(*args, **kwargs)\n \n \n-def get_unpacked_marks(obj: object) -> Iterable[Mark]:\n+def get_unpacked_marks(\n+ obj: Union[object, type],\n+ consider_mro: bool = True,",
"line": 361,... | c543e0c4e83f63943efb0cb06b6c94990c4eb0a9 | diff --git a/changelog/7792.bugfix.rst b/changelog/7792.bugfix.rst
new file mode 100644
index 00000000000..8f65637896d
--- /dev/null
+++ b/changelog/7792.bugfix.rst
@@ -0,0 +1,5 @@
+Marks are now inherited according to the full MRO in test classes. Previously, if a test class inherited from two or more classes, only ma... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} |
pytest-dev__pytest-9956@238a5ca | pytest-dev/pytest | Python | 9,956 | Give warning when test function return other than None | <!--
Thanks for submitting a PR, your contribution is really appreciated!
Here is a quick checklist that should be present in PRs.
- [ ] Include documentation when adding new features.
- [X] Include new tests or update existing tests when applicable.
- [X] Allow maintainers to push and squash when merging my c... | 2022-05-13T20:51:44Z | Test functions that return non-None should raise a warning/error
Consider this test:
```python
# The function we're testing
def foo(a: int, b: int) -> int:
return a * 3 + b
@pytest.mark.parametrize(['a', 'b', 'result'], [
[1, 2, 5],
[2, 3, 8],
[5, 3, 18],
])
def test_foo(a, b, result):
return f... | Hi @maxrothman,
Thanks for the suggestion. I appreciate where you are coming from, but I don't think this is a good idea:
* It is somewhat implicit to me that returning `False` from a test function would cause the test to fail. Also, it would fail with what message? `assert` statements are the bread and butter of... | [
{
"body": "Consider this test:\r\n\r\n```python\r\n# The function we're testing\r\ndef foo(a: int, b: int) -> int:\r\n return a * 3 + b\r\n\r\n@pytest.mark.parametrize(['a', 'b', 'result'], [\r\n [1, 2, 5],\r\n [2, 3, 8],\r\n [5, 3, 18],\r\n])\r\ndef test_foo(a, b, result):\r\n return foo(a, b) == result\r... | cc0fbbefa0f8a6b390e89ef0d4d64dd78783a5c1 | {
"head_commit": "238a5cae9c6dd31ea14e557b6c7542ac77b7bc89",
"head_commit_message": "Adding myself",
"patch_to_review": "diff --git a/AUTHORS b/AUTHORS\nindex 86a814a137b..6cecb0d56f8 100644\n--- a/AUTHORS\n+++ b/AUTHORS\n@@ -63,6 +63,7 @@ Ceridwen\n Charles Cloud\n Charles Machalow\n Charnjit SiNGH (CCSJ)\n+Cheu... | [
{
"diff_hunk": "@@ -42,6 +42,13 @@ class PytestCollectionWarning(PytestWarning):\n __module__ = \"pytest\"\n \n \n+@final\n+class PytestReturnNotNoneWarning(PytestWarning):",
"line": null,
"original_line": 46,
"original_start_line": null,
"path": "src/_pytest/warning_types.py",
"start_li... | 78e0b67ca75142057d4d22a2cc51b947c9a1df04 | diff --git a/AUTHORS b/AUTHORS
index 86a814a137b..6cecb0d56f8 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -63,6 +63,7 @@ Ceridwen
Charles Cloud
Charles Machalow
Charnjit SiNGH (CCSJ)
+Cheuk Ting Ho
Chris Lamb
Chris NeJame
Chris Rose
diff --git a/changelog/7337.improvement.rst b/changelog/7337.improvement.rst
new file m... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "New Feature Additions"
} |
pytest-dev__pytest-9921@1689b38 | pytest-dev/pytest | Python | 9,921 | Fix representation of tuples in approx | closes #9917
* Refactored `_recursive_list_map` to work on all sequences, and renamed it to `recursive_sequence_map`
Behavior now works as expected. The example originally given in the issue now works as follows:
```
def test_ab():
> assert a == pytest.approx(b, abs=0.01)
E assert ((1+0j), (2... | 2022-05-06T05:40:33Z | pytest.approx fails to print representation of tuples
Hi,
This looks like a bug in pytest.approx
a = (1+0j, 2+0j)
b = (1, 2.2)
def test_ab():
assert a == pytest.approx(b, abs=0.01)
E AssertionError: assert ((1+0j), (2+0j)) == approx((1 ± 1....2 ± 1.0e-02))
E (pytest_assertion plugin: repr... | I was able to reproduce this bug with pytest=7.1.2 and python=3.10.4.
It seems that the intended behavior on line 329 of `_pytest/python_api.py` is for a collection of `ApproxScalar`s to be returned via mapping `self._approx_scalar` over an arbitrary depth collection of scalars.
But in this case, `_recursive_list... | [
{
"body": "Hi,\r\nThis looks like a bug in pytest.approx\r\n\r\na = (1+0j, 2+0j)\r\nb = (1, 2.2)\r\n\r\ndef test_ab():\r\n assert a == pytest.approx(b, abs=0.01)\r\n\r\nE AssertionError: assert ((1+0j), (2+0j)) == approx((1 ± 1....2 ± 1.0e-02))\r\nE (pytest_assertion plugin: representation of d... | 4ddf48b0a369ede4ea9a922f4a1defc9087814c9 | {
"head_commit": "1689b38860c12e37d844c4a01512d5a27e386289",
"head_commit_message": "fix (docs): Fix wording in changelog",
"patch_to_review": "diff --git a/AUTHORS b/AUTHORS\nindex 1a8c5306f75..ef0b125d135 100644\n--- a/AUTHORS\n+++ b/AUTHORS\n@@ -357,5 +357,6 @@ Yoav Caspi\n Yuval Shimon\n Zac Hatfield-Dodds\n ... | [
{
"diff_hunk": "@@ -133,9 +133,11 @@ def _check_type(self) -> None:\n # raise if there are any non-numeric elements in the sequence.\n \n \n-def _recursive_list_map(f, x):\n- if isinstance(x, list):\n- return [_recursive_list_map(f, xi) for xi in x]\n+def _recursive_sequence_map(f, x):\n+ \... | 89fc472c3d148ea97c79e27df5e6c07fe7781e47 | diff --git a/AUTHORS b/AUTHORS
index 1a8c5306f75..ef0b125d135 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -357,5 +357,6 @@ Yoav Caspi
Yuval Shimon
Zac Hatfield-Dodds
Zachary Kneupper
+Zachary OBrien
Zoltán Máté
Zsolt Cserna
diff --git a/changelog/9917.bugfix.rst b/changelog/9917.bugfix.rst
new file mode 100644
index 000... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} |
pydantic__pydantic-10440@269f69b | pydantic/pydantic | Python | 10,440 | Improve error handling for in-evaluable refs for discriminator application | This was supposed to close https://github.com/pydantic/pydantic/issues/8271, but right now it just improves the associated error.
My current hunch is that we need to do an apply discriminators step at the end of json schema building, like we do for core schemas, if we want this to work 😭. Not sure how worth the inv... | 2024-09-18T16:08:21Z | OpenAPI discriminator field disapeared with pydantic v2.5
### Initial Checks
- [X] I confirm that I'm using Pydantic V2
### Description
Hello,
We are using pydantic V2 to generate the openapi schema.
We bumped pydantic from 2.3.0 to 2.5.2 and the discriminator field disappeared in the openapi.yaml.
2.3.... | @BaptisteSaves,
Thanks for reporting this. Looks like a bug! Marking with `good first issue` and `help wanted` in case anyone wants to pick this up to help with our `2.6.0 release`!
@sydney-runkle I would like to take this issue. Can you point me to where I should start looking ?
@StrawHatDrag0n,
Fantastic 😄! My... | [
{
"body": "### Initial Checks\r\n\r\n- [X] I confirm that I'm using Pydantic V2\r\n\r\n### Description\r\n\r\nHello,\r\n\r\nWe are using pydantic V2 to generate the openapi schema.\r\nWe bumped pydantic from 2.3.0 to 2.5.2 and the discriminator field disappeared in the openapi.yaml.\r\n\r\n2.3.0 openapi.yaml\r\... | 01daafaab0aae71d2fb57c42461b3d021a3c56d4 | {
"head_commit": "269f69b5abe46e047c6c5d6eb1008d79777b8f33",
"head_commit_message": "add helpful error, at least",
"patch_to_review": "diff --git a/pydantic/json_schema.py b/pydantic/json_schema.py\nindex b0653e0318b..34ddcf4ed64 100644\n--- a/pydantic/json_schema.py\n+++ b/pydantic/json_schema.py\n@@ -466,7 +466... | [
{
"diff_hunk": "@@ -466,7 +466,7 @@ def populate_defs(core_schema: CoreSchema, json_schema: JsonSchemaValue) -> Json\n core_ref = CoreRef(core_schema['ref']) # type: ignore[typeddict-item]\n defs_ref, ref_json_schema = self.get_cache_defs_ref_schema(core_ref)\n j... | 113414a7e8a260e02dd6513a685d7599024cb95f | diff --git a/pydantic/json_schema.py b/pydantic/json_schema.py
index b0653e0318b..958b23d9d9f 100644
--- a/pydantic/json_schema.py
+++ b/pydantic/json_schema.py
@@ -112,7 +112,7 @@ def update_json_schema(schema: JsonSchemaValue, updates: dict[str, Any]) -> Json
return schema
-JsonSchemaWarningKind = Literal['s... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} |
pydantic__pydantic-10417@131b419 | pydantic/pydantic | Python | 10,417 | Allow arbitrary refs in JSON schema `examples` | Fix https://github.com/pydantic/pydantic/issues/9981
Skip ref counting and processing for the custom `examples` block in JSON schema. | 2024-09-16T16:55:33Z | Using $ref" in examples raises KeyError on .model_json_schema() generation
### Initial Checks
- [X] I confirm that I'm using Pydantic V2
### Description
Using {"$ref": "value"} in Field example raises KeyError on `.model_json_schema()` generation.
I'm not sure if this is json-schema spec problem or pydantic... | Yep, marking this as a dupe of https://github.com/pydantic/pydantic/issues/9783.
Thanks for your question @vgavro!
Hey here!
@sydney-runkle, I just tested a similar code at the beta pydantic version.
But I still have the `KeyError`, even though it's supposed to be resolved?
The example from #9783 works for me o... | [
{
"body": "### Initial Checks\r\n\r\n- [X] I confirm that I'm using Pydantic V2\r\n\r\n### Description\r\n\r\nUsing {\"$ref\": \"value\"} in Field example raises KeyError on `.model_json_schema()` generation.\r\n\r\nI'm not sure if this is json-schema spec problem or pydantic problem (is it REQUIRED to resolve ... | a764871df98c8932e9b7bc10d861053d110a99e4 | {
"head_commit": "131b419080a3637c32606e6466fb8388ebfadde6",
"head_commit_message": "skip json schema val for custom ref",
"patch_to_review": "diff --git a/pydantic/json_schema.py b/pydantic/json_schema.py\nindex c48e781ba3f..b0653e0318b 100644\n--- a/pydantic/json_schema.py\n+++ b/pydantic/json_schema.py\n@@ -21... | [
{
"diff_hunk": "@@ -6554,3 +6554,20 @@ class Model(BaseModel):\n some_field: str = Field(alias='_some_field')\n \n assert Model.model_json_schema()['properties']['_some_field']['title'] == 'Some Field'\n+\n+\n+@pytest.mark.skip_json_schema_validation(reason='Custom ref used.')\n+def test_arbitrary_r... | 0660eeeeeedd20d1962d69fbdc799e01556d35f3 | diff --git a/pydantic/json_schema.py b/pydantic/json_schema.py
index c48e781ba3f..b0653e0318b 100644
--- a/pydantic/json_schema.py
+++ b/pydantic/json_schema.py
@@ -2172,7 +2172,9 @@ def _add_json_refs(schema: Any) -> None:
if not json_ref.startswith(('http://', 'https://')):
... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} |
pydantic__pydantic-10374@3d7e595 | pydantic/pydantic | Python | 10,374 | Make sure `inspect.iscoroutinefunction` works on coroutines decorated with `@validate_call` | <!-- Thank you for your contribution! -->
<!-- Unless your change is trivial, please create an issue to discuss the change before creating a PR -->
## Change Summary
Add judgement for validate_call decorator. Now we can get `True` return from `inpect.iscoroutinefunction()`.
## Related issue number
fix #103... | 2024-09-10T20:53:10Z | Support async functions with `@validate_call` decorator
### Initial Checks
- [X] I confirm that I'm using Pydantic V2
### Description
I'm writing a project using `asgiref`.
When I use `async_to_sync`, I got a error ` UserWarning: async_to_sync was passed a non-async-marked callable`.
I think it's due to `@vali... | Maybe `pydantic._internal._validate_call.ValidateCallWrapper` need some changes to adapt async function(coroutine)?
Yeah. I don't think it's likely that we'll support async functions in the short term, but we can leave this open as a potential feature.
> Yeah. I don't think it's likely that we'll support async function... | [
{
"body": "### Initial Checks\n\n- [X] I confirm that I'm using Pydantic V2\n\n### Description\n\nI'm writing a project using `asgiref`.\r\n\r\nWhen I use `async_to_sync`, I got a error ` UserWarning: async_to_sync was passed a non-async-marked callable`.\r\n\r\nI think it's due to `@validate_call` decorator be... | 204e109691c69583e656c6e16a62ad79da2f59b9 | {
"head_commit": "3d7e595cf77e825fae876365ce953c6d9329b75a",
"head_commit_message": "fix validate_call decorator #10370",
"patch_to_review": "diff --git a/pydantic/validate_call_decorator.py b/pydantic/validate_call_decorator.py\nindex fef84af912c..480cd1f88dc 100644\n--- a/pydantic/validate_call_decorator.py\n++... | [
{
"diff_hunk": "@@ -59,9 +60,17 @@ def validate(function: AnyCallableT) -> AnyCallableT:\n def wrapper_function(*args, **kwargs):\n return validate_call_wrapper(*args, **kwargs)\n \n+ @functools.wraps(function)\n+ async def async_wrapper_function(*args, **kwargs):\n+ ... | d15271537bdc5a24912641626310c6a272dbe65f | diff --git a/pydantic/validate_call_decorator.py b/pydantic/validate_call_decorator.py
index fef84af912c..509a7463c5e 100644
--- a/pydantic/validate_call_decorator.py
+++ b/pydantic/validate_call_decorator.py
@@ -3,6 +3,7 @@
from __future__ import annotations as _annotations
import functools
+import inspect
from t... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} |
onnx__onnx-5200@7360a95 | onnx/onnx | Python | 5,200 | Add `os.PathLike` when filepath as `str` is expected | ### Description
closes #5182 by adding `os.PathLike` to type unions and using `os.fspath` at some points.
### Motivation and Context
#### Context
`onnx` file handling accepts only `IO[bytes] | str`. If passing Python `pathlib.Path`, static type checkers such as `pyright` and `pylance` emit errors which is inc... | 2023-05-04T17:11:08Z | [Feature request] Add possibility to pass `pathlib.Path` where filepath is expected
### System information
name : onnx
version : 1.13.1
description : Open Neural Network Exchange
dependencies
- numpy >=1.16.6
- protobuf >=3.20.2,<4
- typing-e... | We can use `os.fspath` for this when the input is `os.PathLike`. Note we should not use `str`. Contribution is appreciated! I would consider:
1. Add `os.PathLike` to the type union.
2. Use `os.fspath` in cases we need to take the path as a raw string (unlikely needed because we are using open() for reading files. W... | [
{
"body": "### System information\n\n name : onnx \r\n version : 1.13.1 \r\n description : Open Neural Network Exchange \r\n\r\ndependencies\r\n - numpy >=1.16.6\r\n - protobuf >=3.20.2,<4\r\n - typing-extensions >=3.6.2.1\r\n\r\nrequired by\r\n - onnx... | 72c2578c3d6e14fcf0e87db1c8379304c7f49561 | {
"head_commit": "7360a95e938d0d9e2dce7813efa4530e8c087787",
"head_commit_message": "Merge branch 'main' into main",
"patch_to_review": "diff --git a/.gitignore b/.gitignore\nindex 0391f113905..84df2918ed3 100644\n--- a/.gitignore\n+++ b/.gitignore\n@@ -110,3 +110,6 @@ docs/docsgen/source/onnx-api/modules/\n docs... | [
{
"diff_hunk": "",
"line": null,
"original_line": null,
"original_start_line": null,
"path": "onnx/utils.py",
"start_line": null,
"text": "@user1:\nthe future import is needed in this file as well"
},
{
"diff_hunk": "@@ -295,15 +298,16 @@ def save_model(\n \n def save_tensor(\n ... | 14b4b7c4d55f370e5ed2c39ff085dcf7aeccaf79 | diff --git a/.gitignore b/.gitignore
index 0391f113905..84df2918ed3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -110,3 +110,6 @@ docs/docsgen/source/onnx-api/modules/
docs/docsgen/source/operators/
docs/docsgen/**/*.onnx
docs/docsgen/**/*.pb
+
+# PyEnv files
+.python-version
\ No newline at end of file
diff --git a/... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "New Feature Additions"
} |
pydantic__pydantic-10121@4396bb3 | pydantic/pydantic | Python | 10,121 | Do not compute JSON Schema default when plain serializers are used with `when_used` set to `'json-unless-none'` and the default value is `None` | Fixes #10118
<!-- Thank you for your contribution! -->
<!-- Unless your change is trivial, please create an issue to discuss the change before creating a PR -->
## Change Summary
<!-- Please give a short summary of the changes. -->
## Related issue number
<!-- WARNING: please use "fix #123" style refere... | 2024-08-13T10:02:50Z | `PlainSerializer` not respecting `when_used` field during generation of json schema
### Initial Checks
- [X] I confirm that I'm using Pydantic V2
### Description
We've a `PlainSerializer` e.g.:
```python
Decimal = Annotated[
_Decimal, PlainSerializer(lambda x: float(x), return_type=float, when_used='j... | [
{
"body": "### Initial Checks\r\n\r\n- [X] I confirm that I'm using Pydantic V2\r\n\r\n### Description\r\n\r\nWe've a `PlainSerializer` e.g.:\r\n\r\n```python\r\nDecimal = Annotated[\r\n _Decimal, PlainSerializer(lambda x: float(x), return_type=float, when_used='json-unless-none')\r\n]\r\n\r\nclass MyModel(B... | f0d8f6593e95d787fa0b5f5f375632c52cdabd6d | {
"head_commit": "4396bb3cd89e7ef284130845f9f758ba8f946799",
"head_commit_message": "Do not compute JSON Schema default when plain serializers are used with `when_used` set to `'json-unless-none'` and the default value is `None`",
"patch_to_review": "diff --git a/pydantic/json_schema.py b/pydantic/json_schema.py\... | [
{
"diff_hunk": "@@ -1043,17 +1043,30 @@ def default_schema(self, schema: core_schema.WithDefaultSchema) -> JsonSchemaVal\n # return json_schema\n \n # we reflect the application of custom plain, no-info serializers to defaults for\n- # json schemas viewed in serialization mode\n+ ... | eb1570b3f25995bdf9624315cca9eafea1398822 | diff --git a/pydantic/json_schema.py b/pydantic/json_schema.py
index 30cd16cdc73..1474e23846d 100644
--- a/pydantic/json_schema.py
+++ b/pydantic/json_schema.py
@@ -1043,17 +1043,30 @@ def default_schema(self, schema: core_schema.WithDefaultSchema) -> JsonSchemaVal
# return json_schema
# we refl... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} | |
pydantic__pydantic-10339@3019ec0 | pydantic/pydantic | Python | 10,339 | Fix `IncEx` type alias definition | <!-- Thank you for your contribution! -->
<!-- Unless your change is trivial, please create an issue to discuss the change before creating a PR -->
## Change Summary
Fixes https://github.com/pydantic/pydantic/issues/10333
Requires https://github.com/pydantic/pydantic-core/pull/1443
Ideally we would import `_... | 2024-09-06T13:14:42Z | Type alias for model_dump include/exclude is broken
### Initial Checks
- [X] I confirm that I'm using Pydantic V2
### Description
Version 2.9.0 changed the `IncEx` type alias to the following:
`IncEx: TypeAlias = Union[Set[int], Set[str], Dict[int, 'IncEx'], Dict[str, 'IncEx'], None]`
This is not correct for t... | @tommasolevato,
Thanks for reporting. Indeed, looks like an issue in v2.9.0, we'll work to roll out a fix shortly. | [
{
"body": "### Initial Checks\n\n- [X] I confirm that I'm using Pydantic V2\n\n### Description\n\nVersion 2.9.0 changed the `IncEx` type alias to the following:\r\n\r\n`IncEx: TypeAlias = Union[Set[int], Set[str], Dict[int, 'IncEx'], Dict[str, 'IncEx'], None]`\r\n\r\nThis is not correct for the `include` and `e... | e0604253bd56abf1bf0660fa2c6779a3cff98c46 | {
"head_commit": "3019ec044627a8a6508d923859f72e8c1cbdb6ea",
"head_commit_message": "Fix `IncEx` type alias definition",
"patch_to_review": "diff --git a/pydantic/main.py b/pydantic/main.py\nindex 4b3d8eff730..8f231c335a7 100644\n--- a/pydantic/main.py\n+++ b/pydantic/main.py\n@@ -16,10 +16,8 @@\n Dict,\n ... | [
{
"diff_hunk": "@@ -74,6 +65,11 @@\n \n __all__ = 'BaseModel', 'create_model'\n \n+# Keep these type aliases available at runtime:\n+TupleGenerator: TypeAlias = Generator[Tuple[str, Any], None, None]\n+# Keep this type alias in sync with the stub definition in `pydantic-core`:\n+IncEx: TypeAlias = 'set[int] | s... | 5ab7f38443766d52803f54405a860e628789e4b4 | diff --git a/pdm.lock b/pdm.lock
index f88c5abf5b1..e0fbb38d96a 100644
--- a/pdm.lock
+++ b/pdm.lock
@@ -5,7 +5,7 @@
groups = ["default", "docs", "email", "linting", "memray", "mypy", "testing", "testing-extra", "timezone"]
strategy = []
lock_version = "4.5.0"
-content_hash = "sha256:3a584a7e92099980d8871eb23c554963... | {
"difficulty": "medium",
"estimated_review_effort": 2,
"problem_domain": "Bug Fixes"
} |
pydantic__pydantic-10082@65a1f22 | pydantic/pydantic | Python | 10,082 | Docs update and warning frozen defined both | ## Change Summary
This PR addresses an issue where defining `frozen` both in the `@dataclass` decorator and `config=ConfigDict(frozen=True)` led to confusing and inconsistent behavior.
The changes made in this PR aim to clarify the expected behavior and provide better guidance to users.
- docs change
```
It... | 2024-08-08T05:28:56Z | Dataclass ConfigDict frozen doesn't work as expected
### Initial Checks
- [X] I confirm that I'm using Pydantic V2
### Description
There are two apparent ways to make a dataclass frozen. Coming from using ordinary class-based Pydantic models to dataclass-based ones, I found myself providing ConfigDict(frozen=T... | A docs update would be awesome, thanks!
Hi @sydney-runkle,
I'd like to work on this. Can I work on this?
Hi @sydney-runkle,
Thank you for assigning me!
I would like to discuss a policy for revising the documentation.
Currently, after reading the docs, I'm considering proposing the following policy:
- Defin... | [
{
"body": "### Initial Checks\r\n\r\n- [X] I confirm that I'm using Pydantic V2\r\n\r\n### Description\r\n\r\nThere are two apparent ways to make a dataclass frozen. Coming from using ordinary class-based Pydantic models to dataclass-based ones, I found myself providing ConfigDict(frozen=True) to the dataclass ... | 61f027cab5004823d1e000a03e5c20eabcfba733 | {
"head_commit": "65a1f2287b36614f2bda499ef6e90ece2575eb98",
"head_commit_message": "Delete test file",
"patch_to_review": "diff --git a/pydantic/dataclasses.py b/pydantic/dataclasses.py\nindex 2467493dbe5..51d3cba957b 100644\n--- a/pydantic/dataclasses.py\n+++ b/pydantic/dataclasses.py\n@@ -6,6 +6,7 @@\n import ... | [
{
"diff_hunk": "@@ -232,6 +233,13 @@ def create_dataclass(cls: type[Any]) -> type[PydanticDataclass]:\n else:\n frozen_ = config_wrapper.frozen or False\n \n+ # It's not recommended to define both, as the setting from the dataclass decorator will take priority.\n+ if frozen is ... | f6b276345974ce50580b293cddc6abd58287d2a5 | diff --git a/pydantic/dataclasses.py b/pydantic/dataclasses.py
index 2467493dbe5..29ea8962398 100644
--- a/pydantic/dataclasses.py
+++ b/pydantic/dataclasses.py
@@ -6,6 +6,7 @@
import sys
import types
from typing import TYPE_CHECKING, Any, Callable, Generic, NoReturn, TypeVar, overload
+from warnings import warn
... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Documentation Updates"
} |
pytest-dev__pytest-9249@ee61e48 | pytest-dev/pytest | Python | 9,249 | Support forwardslash characters in identifiers | Closes #8377.
<!--
Thanks for submitting a PR, your contribution is really appreciated!
Here is a quick checklist that should be present in PRs.
- [X] Include documentation when adding new features.
- [X] Include new tests or update existing tests when applicable.
- [X] Allow maintainers to push and squash wh... | 2021-10-29T13:58:57Z | test ids with `/`s cannot be selected with `-k`
By default pytest 6.2.2 parametrize does user arguments to generate IDs, but some of these ids cannot be used with `-k` option because you endup with errors like `unexpected character "/"` when trying to do so.
The solution for this bug is to assure that auto-generate... | The test ids are not invalid, keyword expressions are simply not able to express slashes
It's not clear to me if that should be added
I am not sure either, but I wanted to underline the issue, hoping that we can find a way to improve the UX. The idea is what what we display should also be easily used to run a test or... | [
{
"body": "By default pytest 6.2.2 parametrize does user arguments to generate IDs, but some of these ids cannot be used with `-k` option because you endup with errors like `unexpected character \"/\"` when trying to do so.\r\n\r\nThe solution for this bug is to assure that auto-generated IDs are sanitized so ... | 1824349f74298112722396be6f84a121bc9d6d63 | {
"head_commit": "ee61e4887fdd738481e867120a387f94a16f7a72",
"head_commit_message": "Merge branch 'pytest-dev:main' into main",
"patch_to_review": "diff --git a/changelog/8377.bugfix.rst b/changelog/8377.bugfix.rst\nnew file mode 100644\nindex 00000000000..eab4135e93f\n--- /dev/null\n+++ b/changelog/8377.bugfix.r... | [
{
"diff_hunk": "@@ -0,0 +1,2 @@\n+The test selection options ``pytest -k`` and ``pytest -m`` now support matching\n+names containing forwardslash (``\\/``)characters.",
"line": null,
"original_line": 2,
"original_start_line": null,
"path": "changelog/8377.bugfix.rst",
"start_line": null,
... | 98dafc14989ec1d772bf2952ccad1d440ccf3f5d | diff --git a/changelog/8377.bugfix.rst b/changelog/8377.bugfix.rst
new file mode 100644
index 00000000000..3df54a949af
--- /dev/null
+++ b/changelog/8377.bugfix.rst
@@ -0,0 +1,2 @@
+The test selection options ``pytest -k`` and ``pytest -m`` now support matching
+names containing forward slash (``/``) characters.
diff -... | {
"difficulty": "low",
"estimated_review_effort": 2,
"problem_domain": "Bug Fixes"
} |
pytest-dev__pytest-9064@74ee51c | pytest-dev/pytest | Python | 9,064 | #9062 - Allow `--stepwise-skip` to implicitly enable `--stepwise` | The ``StepwisePlugin`` plugin instance was only registered with pluggy when ``--stepwise`` was explicitly provided, this could be confusing where users would / could pass ``--stepwise-skip`` in isolation and observe no expected behaviour.
* ``--stepwise-skip`` can now work alone, implicitly enabling ``--stepwise``
... | 2021-08-30T17:54:14Z | `--stepwise-skip` has no effect without `--stepwise`
- [x] a detailed description of the bug or problem you are having
The flag `--stepwise` will "exit on test failure and continue from last failing test".
The flag `--stepwise-skip` is supposed to "ignore the first failing test but stop on the next failing test".
... | Agreed, thanks for catching and reporting it. 👍
Thanks, i'll fix this up (I was in and around that plugin a while ago) | [
{
"body": "- [x] a detailed description of the bug or problem you are having\r\n\r\nThe flag `--stepwise` will \"exit on test failure and continue from last failing test\".\r\nThe flag `--stepwise-skip` is supposed to \"ignore the first failing test but stop on the next failing test\".\r\nHowever, it does nothi... | 014fa61e0db9f9ebdedf57e1ab8f30df30c7c469 | {
"head_commit": "74ee51cf6db0c1fe96a5f8921d54137bd8e83a65",
"head_commit_message": "#9062 - Allow `--stepwise-skip` to implicitly enable `--stepwise`",
"patch_to_review": "diff --git a/changelog/9062.improvement.rst b/changelog/9062.improvement.rst\nnew file mode 100644\nindex 00000000000..7fcaf0408a1\n--- /dev/... | [
{
"diff_hunk": "@@ -0,0 +1 @@\n+``--stepwise-skip`` now implicitly enables ``--stepwise`` and can be used on it's own.",
"line": null,
"original_line": 1,
"original_start_line": null,
"path": "changelog/9062.improvement.rst",
"start_line": null,
"text": "@user1:\n```suggestion\r\n``--ste... | f2973b3f61d7ee553250d61453239b5a98cbca31 | diff --git a/changelog/9062.improvement.rst b/changelog/9062.improvement.rst
new file mode 100644
index 00000000000..bfc7cf00a46
--- /dev/null
+++ b/changelog/9062.improvement.rst
@@ -0,0 +1 @@
+``--stepwise-skip`` now implicitly enables ``--stepwise`` and can be used on its own.
diff --git a/doc/en/how-to/cache.rst b/... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} |
pydantic__pydantic-10100@37ae205 | pydantic/pydantic | Python | 10,100 | Fix `mro` of generic subclass | <!-- Thank you for your contribution! -->
<!-- Unless your change is trivial, please create an issue to discuss the change before creating a PR -->
## Change Summary
Override `ModelMetaclass.mro` such that indexed generic type can be inserted into `__mro__` of its subclasses.
For example:
```py
class A(Base... | 2024-08-11T11:16:16Z | Nested generic inheritance
### Initial Checks
- [X] I confirm that I'm using Pydantic V2
### Description
Is there a way for `MyClassSubBool` to be recognized as an instance of `MyClass[bool]` , apart from inheriting the functionality from `MyClassSub`?
If I use multiple inheritance in `class MyClassSubBool(... | I simplified your example code to make it easier to understand. Overall I think this is a reasonable request, it is accepted from a type checking perspective. | [
{
"body": "### Initial Checks\r\n\r\n- [X] I confirm that I'm using Pydantic V2\r\n\r\n### Description\r\n\r\nIs there a way for `MyClassSubBool` to be recognized as an instance of `MyClass[bool]` , apart from inheriting the functionality from `MyClassSub`?\r\n\r\nIf I use multiple inheritance in `class MyClass... | 287c266cc39a5a9f1cafa6b7f5e37d8050bb493a | {
"head_commit": "37ae205f8c55c3e84db1ac5a3e9e6a13946485a1",
"head_commit_message": "update",
"patch_to_review": "diff --git a/pydantic/_internal/_model_construction.py b/pydantic/_internal/_model_construction.py\nindex 886e6fd5f47..06689b64240 100644\n--- a/pydantic/_internal/_model_construction.py\n+++ b/pydant... | [
{
"diff_hunk": "@@ -241,6 +243,61 @@ def __getattr__(self, item: str) -> Any:\n return private_attributes[item]\n raise AttributeError(item)\n \n+ def mro(cls):\n+ original_mro = super().mro()\n+\n+ if cls.__bases__ == (object,):\n+ return ... | dc7cd944dcd860e5d45c3c6d5b36179d79af4f0d | diff --git a/pydantic/_internal/_model_construction.py b/pydantic/_internal/_model_construction.py
index 015bcdf56e4..92bd93ae394 100644
--- a/pydantic/_internal/_model_construction.py
+++ b/pydantic/_internal/_model_construction.py
@@ -133,6 +133,8 @@ def wrapped_model_post_init(self: BaseModel, context: Any, /) -> No... | {
"difficulty": "high",
"estimated_review_effort": 4,
"problem_domain": "Code Refactoring / Architectural Improvement"
} |
onnx__onnx-4180@a57cd25 | onnx/onnx | Python | 4,180 | Add documentation about functions to IR.md | Signed-off-by: Ganesan Ramalingam <grama@microsoft.com>
Add documentation about functions to IR.md
| 2022-05-02T17:56:17Z | Add more documentation for model local function
# Feature Request
### System information
ONNX version (you are using): 1.11
### What is the problem that this feature solves?
ONNX has introduced model local function for a while and brought a few enhancements about it recently. Going forward it will be more and m... | Created PR https://github.com/onnx/onnx/pull/4180 | [
{
"body": "# Feature Request\r\n\r\n### System information\r\nONNX version (you are using): 1.11\r\n\r\n### What is the problem that this feature solves?\r\nONNX has introduced model local function for a while and brought a few enhancements about it recently. Going forward it will be more and more useful and po... | 12c318eb6f1b4ee1b392182ace554ccc62e743ab | {
"head_commit": "a57cd25338fbd644265fa73f4f8b4e95a66cfce2",
"head_commit_message": "Merge branch 'main' into function-doc",
"patch_to_review": "diff --git a/docs/IR.md b/docs/IR.md\nindex 3729b3bb88b..21712866f11 100644\n--- a/docs/IR.md\n+++ b/docs/IR.md\n@@ -171,6 +171,41 @@ The ‘status’ property indicates whe... | [
{
"diff_hunk": "@@ -171,6 +171,41 @@ The ‘status’ property indicates whether the syntax, semantics, or presence o\n \n There are two distinct ways to pass information to operators – inputs and attributes. Inputs represent graph inputs or values computed elsewhere in the graph, while attributes are used for valu... | 392e5d3a438d0e3e0dc45048a74adb11212954fc | diff --git a/docs/IR.md b/docs/IR.md
index 3729b3bb88b..d14246834ce 100644
--- a/docs/IR.md
+++ b/docs/IR.md
@@ -171,6 +171,41 @@ The ‘status’ property indicates whether the syntax, semantics, or presence o
There are two distinct ways to pass information to operators – inputs and attributes. Inputs represent graph i... | {
"difficulty": "low",
"estimated_review_effort": 1,
"problem_domain": "Documentation Updates"
} |
onnx__onnx-4720@becb501 | onnx/onnx | Python | 4,720 | Expose check_function in Python API | ### Description
<!-- - Describe your changes. -->
- Expose check_function in Python API.
- Add a test
- Add more functions in API doc on Web.
### Motivation and Context
<!-- - Why is this change required? What problem does it solve? -->
<!-- - If it fixes an open issue, please link to the issue here. -->
Clos... | 2022-12-23T01:58:47Z | [Feature request] ONNX checker checks function proto validity
### System information
_No response_
### What is the problem that this feature solves?
ONNX checker currently checks model proto validity with check_model_proto. I would be very helpful to have a similar API that checks for function proto validity.
Th... | Hi @justinchuby,
Thanks for proposing this. Currently ONNX only provides [check_function](https://github.com/onnx/onnx/blob/main/onnx/checker.cc#L867-L956) in C++. Does the current check meet your requirement? If it is useful, we can also expose a Python API for it.
A Python api would be great/necessary for unit testi... | [
{
"body": "### System information\n\n_No response_\n\n### What is the problem that this feature solves?\n\nONNX checker currently checks model proto validity with check_model_proto. I would be very helpful to have a similar API that checks for function proto validity.\r\n\r\nThis greatly helps testing function ... | d776f5b21d84a6f8eb7d95caddc40f72c56eea27 | {
"head_commit": "becb501852a6423516f7fecd91103a45e2ab425e",
"head_commit_message": "add a test and doc\n\nSigned-off-by: Chun-Wei Chen <jacky82226@gmail.com>",
"patch_to_review": "diff --git a/docs/docsgen/source/api/checker.rst b/docs/docsgen/source/api/checker.rst\nindex 3fbb08a55ad..95fba77a499 100644\n--- a/... | [
{
"diff_hunk": "@@ -5,6 +5,36 @@ onnx.checker\n .. contents::\n :local:\n \n+check_value_info",
"line": 14,
"original_line": 8,
"original_start_line": null,
"path": "docs/docsgen/source/api/checker.rst",
"start_line": null,
"text": "@user1:\n`C.CheckerContext` should be exposed as w... | e19bd4ababc87a9618c0f13223aa0b76d8fe4761 | diff --git a/docs/docsgen/source/api/checker.rst b/docs/docsgen/source/api/checker.rst
index 3fbb08a55ad..0a300a9feeb 100644
--- a/docs/docsgen/source/api/checker.rst
+++ b/docs/docsgen/source/api/checker.rst
@@ -5,6 +5,42 @@ onnx.checker
.. contents::
:local:
+CheckerContext
+++++++++++++++
+
+.. autoclass:: C... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "New Feature Additions"
} |
pydantic__pydantic-9787@65e39b6 | pydantic/pydantic | Python | 9,787 | Respect use_enum_values on Literal types | <!-- Thank you for your contribution! -->
<!-- Unless your change is trivial, please create an issue to discuss the change before creating a PR -->
## Change Summary
Following the logic for enum schema generation, I added `no_info_after_validator_function` to the literal schema when `use_enum_values` is set.
To... | 2024-06-28T09:56:37Z | validate_default has no effect when attribute type is Literal
### Initial Checks
- [X] I confirm that I'm using Pydantic V2
### Description
When an field has an Enum value as its default value, then it is translated to a str when both `use_enum_values` and `validate_default` are set True, as is expected from t... | @kwint,
Thanks for reporting this. Definitely looks like a bug. Going to mark this as a good first issue - should be fixable within `pydantic` alone.
If anyone is interested in taking a stab at this, feel free to ping me when you'd like a review or if you have questions!
Hi @sydney-runkle, I'd be happy to tackl... | [
{
"body": "### Initial Checks\r\n\r\n- [X] I confirm that I'm using Pydantic V2\r\n\r\n### Description\r\n\r\nWhen an field has an Enum value as its default value, then it is translated to a str when both `use_enum_values` and `validate_default` are set True, as is expected from the documentation.\r\n\r\nHoweve... | a002e6977d463da80321be91214459f704f14bc0 | {
"head_commit": "65e39b67a071671ce4d756b8c8781ea7d20fccc2",
"head_commit_message": "Added tests",
"patch_to_review": "diff --git a/pydantic/_internal/_generate_schema.py b/pydantic/_internal/_generate_schema.py\nindex b81de006d00..b519ffa9bec 100644\n--- a/pydantic/_internal/_generate_schema.py\n+++ b/pydantic/_... | [
{
"diff_hunk": "@@ -1248,7 +1248,14 @@ def _literal_schema(self, literal_type: Any) -> CoreSchema:\n \"\"\"Generate schema for a Literal.\"\"\"\n expected = _typing_extra.all_literal_values(literal_type)\n assert expected, f'literal \"expected\" cannot be empty, obj={literal_type}'\n- ... | a4ed77d6026d57ab7e5fb20002a9558b70de12c3 | diff --git a/pydantic/_internal/_generate_schema.py b/pydantic/_internal/_generate_schema.py
index b81de006d00..c73f498e7e0 100644
--- a/pydantic/_internal/_generate_schema.py
+++ b/pydantic/_internal/_generate_schema.py
@@ -1248,7 +1248,14 @@ def _literal_schema(self, literal_type: Any) -> CoreSchema:
"""Gene... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} |
pydantic__pydantic-9760@9b39331 | pydantic/pydantic | Python | 9,760 | `validate_call` type params fix | Closes https://github.com/pydantic/pydantic/issues/9536
Fix https://github.com/pydantic/pydantic/issues/9744 | 2024-06-25T22:30:24Z | "NameError: name 'T' is not defined" when using "from __future__ import annotations" with generic function
### Initial Checks
- [X] I confirm that I'm using Pydantic V2
### Description
Pydantic gives the below error when using **from __future__ import annotations** with generic functions
```
C:\code\venv\Scripts... | @hb2638,
Thanks for reporting this issue. @alexmojaki, any idea what's going on here?
This is not uniquely a pydantic problem, and it's not related to `eval_type_backport`:
```python
from __future__ import annotations
import typing
def foo[T]() -> T: ...
print(typing.get_type_hints(foo))
```
```pytb... | [
{
"body": "### Initial Checks\n\n- [X] I confirm that I'm using Pydantic V2\n\n### Description\n\nPydantic gives the below error when using **from __future__ import annotations** with generic functions\r\n\r\n```\r\nC:\\code\\venv\\Scripts\\python.exe C:\\code\\devtools\\foo.py \r\nTraceback (most recent call l... | 04f3a464b5d72c6e7679b2ed63bcacb161b767da | {
"head_commit": "9b3933187acc7212226e74c843043e431266bdf8",
"head_commit_message": "remove change to string annotation",
"patch_to_review": "diff --git a/pydantic/_internal/_typing_extra.py b/pydantic/_internal/_typing_extra.py\nindex 43bcc07b354..4526cf29e73 100644\n--- a/pydantic/_internal/_typing_extra.py\n++... | [
{
"diff_hunk": "@@ -803,3 +804,44 @@ def foo(bar: 'list[int | str]') -> 'list[int | str]':\n 'input': {'not a str or int'},\n },\n ]\n+\n+\n+@pytest.mark.skipif(sys.version_info < (3, 12), reason='requires Python 3.12+ for PEP 695 syntax with generics')\n+def test_validate_call_with_pep_... | 8e76348c6d41969e8e9477c9af35d2cb8ee356d4 | diff --git a/pydantic/_internal/_typing_extra.py b/pydantic/_internal/_typing_extra.py
index 43bcc07b354..4526cf29e73 100644
--- a/pydantic/_internal/_typing_extra.py
+++ b/pydantic/_internal/_typing_extra.py
@@ -307,6 +307,7 @@ def get_function_type_hints(
globalns = add_module_globals(function)
type_hints... | {
"difficulty": "medium",
"estimated_review_effort": 4,
"problem_domain": "Bug Fixes"
} |
pytest-dev__pytest-8365@0c25413 | pytest-dev/pytest | Python | 8,365 | Fixed an issue where `getpass.getuser()` contained illegal characters for file directories | closes #8317. It is possible that `getpass.getuser()` can be illegal characters not appropriate for a directory name (platform dependent etc). This PR addresses that by attempting it normally and backing off to use the default `-of-unknown` when it occurs. This is consistent when `getuser()` is not Truthy.
Apprec... | 2021-02-22T20:26:35Z | tmpdir creation fails when the username contains illegal characters for directory names
`tmpdir`, `tmpdir_factory` and `tmp_path_factory` rely on `getpass.getuser()` for determining the `basetemp` directory. I found that the user name returned by `getpass.getuser()` may return characters that are not allowed for direct... | Thanks for the report @pborsutzki! | [
{
"body": "`tmpdir`, `tmpdir_factory` and `tmp_path_factory` rely on `getpass.getuser()` for determining the `basetemp` directory. I found that the user name returned by `getpass.getuser()` may return characters that are not allowed for directory names. This may lead to errors while creating the temporary direc... | 4964b468c83c06971eb743fbc57cc404f760c573 | {
"head_commit": "0c25413eb243a900c69721b1a9d60ae5b7cee26e",
"head_commit_message": "retry writing pytest-of dir when invalid chars are in directory name",
"patch_to_review": "diff --git a/src/_pytest/tmpdir.py b/src/_pytest/tmpdir.py\nindex 29c7e19d7b4..50c1caa6c1d 100644\n--- a/src/_pytest/tmpdir.py\n+++ b/src/... | [
{
"diff_hunk": "@@ -445,3 +446,32 @@ def test(tmp_path):\n # running a second time and ensure we don't crash\n result = pytester.runpytest(\"--basetemp=tmp\")\n assert result.ret == 0\n+\n+\n+@pytest.mark.usefixtures(\"invalid_get_user\")\n+def test_tmpdir_factory_handles_invalid_dir_characters(\n+ ... | 26d3d7743a860c0898c035961536fe36d9ff12e7 | diff --git a/changelog/8317.bugfix.rst b/changelog/8317.bugfix.rst
new file mode 100644
index 00000000000..7312880a11f
--- /dev/null
+++ b/changelog/8317.bugfix.rst
@@ -0,0 +1 @@
+Fixed an issue where illegal directory characters derived from ``getpass.getuser()`` raised an ``OSError``.
diff --git a/src/_pytest/tmpdir.... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} |
pydantic__pydantic-9303@3524749 | pydantic/pydantic | Python | 9,303 | Fix Outputted Model JSON Schema for Sequence type | <!-- Thank you for your contribution! -->
<!-- Unless your change is trivial, please create an issue to discuss the change before creating a PR -->
## Change Summary
<!-- Please give a short summary of the changes. -->
Fixing an issue where the outputted JSON Schema, for the Sequence type, used `minLength` rath... | 2024-04-23T09:18:46Z | When using min_length on Sequence field, outputted JSON schema is `minLength` instead of `minItems` for array type
### Initial Checks
- [X] I confirm that I'm using Pydantic V2
### Description
```python
class Example(BaseModel):
array: Sequence[int] = Field(default_factory=list, min_length=1)
Example.model_js... | @skylander86,
Thanks for reporting this! We can fix in a 2.7 patch release soon. Adding to the corresponding milestone!
Ok I don't think this is actually a 2.7 issue (can reproduce in 2.6.4).
Removing this from the 2.7 milestone, great first issue if someone wants to pick this up!
Hi, I can take this. | [
{
"body": "### Initial Checks\n\n- [X] I confirm that I'm using Pydantic V2\n\n### Description\n\n```python\r\nclass Example(BaseModel):\r\n array: Sequence[int] = Field(default_factory=list, min_length=1)\r\n\r\nExample.model_json_schema()\r\n```\r\nThe above returns a JSON schema\r\n```python\r\n{'properties... | 26129479a06960af9d02d3a948e51985fe59ed4b | {
"head_commit": "35247497d798e887cdc50c29bd47d92c04742eef",
"head_commit_message": "add tests for model json schema from sequence with min/max length",
"patch_to_review": "diff --git a/pydantic/_internal/_known_annotated_metadata.py b/pydantic/_internal/_known_annotated_metadata.py\nindex 83d85b3b12a..d87bf05bcc... | [
{
"diff_hunk": "@@ -102,6 +102,22 @@\n CONSTRAINTS_TO_ALLOWED_SCHEMAS[constraint].update(('enum',))\n \n \n+def _is_sequence_metadata(schema: CoreSchema) -> bool:\n+ \"\"\"Checks if the schema is a sequence schema.\n+\n+ Args:\n+ schema: The core schema.\n+\n+ Returns:\n+ True if the ... | eb615cb15f46d18b2bdf941e1a8174ab2bb5eab4 | diff --git a/pydantic/_internal/_generate_schema.py b/pydantic/_internal/_generate_schema.py
index b88dd8b2b19..64b8f17d06a 100644
--- a/pydantic/_internal/_generate_schema.py
+++ b/pydantic/_internal/_generate_schema.py
@@ -1442,6 +1442,7 @@ def _sequence_schema(self, sequence_type: Any) -> core_schema.CoreSchema:
... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} |
pyro-ppl__pyro-2271@b7eda7f | pyro-ppl/pyro | Python | 2,271 | bugfix #2270 | Resolves #2270
Using torch.where seems to resolve the issues related to using the Delta distribution as a component in the MaskedMixture. | 2020-01-20T06:43:17Z | MaskedMixture distribution doesn't work properly when Delta distribution is used as a component
### Issue Description
MaskedMixture fails when Delta distribution is used as a component distribution. In particular, sampling from MaskedMixture outputs wrong values and also alters the Delta distribution used as a compone... | @ordabayevy your fix looks great! Do you want to submit that as a PR? You can add a regression test if you want, but I'm ok with just the fix and existing tests.
@fritzo I submitted a PR with the fix. I am not sure how to do a regression test. This is my first time submitting a bugfix (and contributing) to an open proj... | [
{
"body": "### Issue Description\r\nMaskedMixture fails when Delta distribution is used as a component distribution. In particular, sampling from MaskedMixture outputs wrong values and also alters the Delta distribution used as a component.\r\n\r\n### Code Snippet\r\n```py\r\nimport sys\r\nimport torch\r\nimpor... | 460f421ac36face9e6fcfefbcba358639d38a6fb | {
"head_commit": "b7eda7fdf752f05d9ab84b13c8bf3b1b43835982",
"head_commit_message": "reshape mask (fehiepsi)",
"patch_to_review": "diff --git a/pyro/distributions/mixture.py b/pyro/distributions/mixture.py\nindex 096c8137c2..36c46bc0be 100644\n--- a/pyro/distributions/mixture.py\n+++ b/pyro/distributions/mixture.... | [
{
"diff_hunk": "@@ -102,14 +102,17 @@ def expand(self, batch_shape):\n \n def sample(self, sample_shape=torch.Size()):\n mask = self.mask.expand(sample_shape + self.batch_shape) if sample_shape else self.mask\n- result = self.component0.sample(sample_shape)\n- result[mask] = self.compo... | a71c300d9ac5221c2562edd71e321e28dbc591c6 | diff --git a/pyro/distributions/mixture.py b/pyro/distributions/mixture.py
index 096c8137c2..76e1f0361f 100644
--- a/pyro/distributions/mixture.py
+++ b/pyro/distributions/mixture.py
@@ -101,15 +101,19 @@ def expand(self, batch_shape):
return type(self)(mask, component0, component1)
def sample(self,... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} |
pydantic__pydantic-9279@943c91f | pydantic/pydantic | Python | 9,279 | Fix `strict` application to `function-after` with `use_enum_values` | Fix https://github.com/pydantic/pydantic/issues/9257
Selected Reviewer: @samuelcolvin | 2024-04-18T15:35:41Z | Error: RuntimeError: Unable to apply constraint strict to schema function-after
### Initial Checks
- [X] I confirm that I'm using Pydantic V2
### Description
The following code, error reported after execution:
`
Traceback (most recent call last):
File "E:\store\Testing\testing\test8.py", line 10, in <module>
... | @Ryaningli,
Ah, thanks for the report. Definitely looks like a bug, likely related to the migration of our enum validation to `rust`. Will look into a fix for this for a patch release!
Looks like it's only a problem when we have `use_enum_values` in the config. | [
{
"body": "### Initial Checks\n\n- [X] I confirm that I'm using Pydantic V2\n\n### Description\n\nThe following code, error reported after execution:\r\n\r\n`\r\nTraceback (most recent call last):\r\n File \"E:\\store\\Testing\\testing\\test8.py\", line 10, in <module>\r\n class Foo(BaseModel):\r\n File \"... | 3c15a8bebabe731949766e4e93121b02f2a802fb | {
"head_commit": "943c91ffe94bc056384ce6819cfd2375e9cd5d1d",
"head_commit_message": "return instead of continue",
"patch_to_review": "diff --git a/pydantic/_internal/_known_annotated_metadata.py b/pydantic/_internal/_known_annotated_metadata.py\nindex ee7f7b248b2..4897183fd2c 100644\n--- a/pydantic/_internal/_kno... | [
{
"diff_hunk": "@@ -195,6 +195,12 @@ def apply_known_metadata(annotation: Any, schema: CoreSchema) -> CoreSchema | No\n raise ValueError(f'Unknown constraint {constraint}')\n allowed_schemas = CONSTRAINTS_TO_ALLOWED_SCHEMAS[constraint]\n \n+ # if it becomes necessary to handle more th... | 9f375c4e699c86db598007f5ea8c0da3a22259d4 | diff --git a/pydantic/_internal/_known_annotated_metadata.py b/pydantic/_internal/_known_annotated_metadata.py
index ee7f7b248b2..83d85b3b12a 100644
--- a/pydantic/_internal/_known_annotated_metadata.py
+++ b/pydantic/_internal/_known_annotated_metadata.py
@@ -195,6 +195,12 @@ def apply_known_metadata(annotation: Any, ... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} |
pydantic__pydantic-9170@0b99f81 | pydantic/pydantic | Python | 9,170 | Add warning when set "alias" in low level annontated field | <!-- Thank you for your contribution! -->
<!-- Unless your change is trivial, please create an issue to discuss the change before creating a PR -->
## Change Summary
Add warning message when user setup annotated field with `alias` kwarg at low level. #7828.
## Related issue number
<!-- WARNING: please use ... | 2024-04-05T05:57:38Z | Warn when `Field(alias=...)` is used as nested `Annotated` metadata
### Initial Checks
- [X] I confirm that I'm using Pydantic V2
### Description
Consider the following models:
```python
class AnnotatedOptional(BaseModel):
field: Annotated[Optional[int], Field(alias='field_alias', gt=0)]
class Optional... | In regard to `gt` in `OptionalAnnotated`, it makes sense since this constraint is only applicable to the wrapped `int` type, that is, `Optional[Annotated[int, Field(gt=0)]]` is roughly translated to `PositiveInteger | NoneType`. `alias` is a different beast — it is a property of the field as a whole, not a property of... | [
{
"body": "### Initial Checks\n\n- [X] I confirm that I'm using Pydantic V2\n\n### Description\n\nConsider the following models:\r\n\r\n```python\r\nclass AnnotatedOptional(BaseModel):\r\n field: Annotated[Optional[int], Field(alias='field_alias', gt=0)]\r\n\r\n\r\nclass OptionalAnnotated(BaseModel):\r\n ... | 75012318fbb65036fbb38c2d04869f38ca4e15d6 | {
"head_commit": "0b99f81df76498b6f00079c5d837af3e6e2ee8d9",
"head_commit_message": "refactor warning alias into separated function",
"patch_to_review": "diff --git a/pydantic/_internal/_fields.py b/pydantic/_internal/_fields.py\nindex 6e5e9330612..613ed3f7852 100644\n--- a/pydantic/_internal/_fields.py\n+++ b/py... | [
{
"diff_hunk": "@@ -226,6 +226,7 @@ def collect_model_fields( # noqa: C901\n # Nothing stops us from just creating a new FieldInfo for this type hint, so we do this.\n field_info = FieldInfo.from_annotation(ann_type)\n else:\n+ _warning_if_annotate_hav... | b4ff2c5152b04346d33eb0726efc8b98665c35b9 | diff --git a/pydantic/_internal/_fields.py b/pydantic/_internal/_fields.py
index 6e5e9330612..fd9ed4bf9ed 100644
--- a/pydantic/_internal/_fields.py
+++ b/pydantic/_internal/_fields.py
@@ -226,6 +226,7 @@ def collect_model_fields( # noqa: C901
# Nothing stops us from just creating a new FieldInfo ... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} |
pydantic__pydantic-9004@f58744d | pydantic/pydantic | Python | 9,004 | Handle a case when model_config is defined as a model property | <!-- Thank you for your contribution! -->
<!-- Unless your change is trivial, please create an issue to discuss the change before creating a PR -->
## Change Summary
The PR aims to solve behavior when `pydantic` allows to define `model_config` as a model property with no default value. It leads to confusing behavi... | 2024-03-13T18:15:35Z | It is possible to instantiate model with `model_config` field without exceptions
### Initial Checks
- [X] I confirm that I'm using Pydantic V2
### Description
Hello!
I am aware that `model_config` should be `ConfigDict()` and this is class/instance attribute as written in documentation.
I was trying to f... | @tribunsky-kir,
I'd agree that the error messages (or warning messages) could be improved in the above cases. I'll leave this issue open as an opportunity to improve those.
There is not currently support for having a field named `model_config`, and I don't think that is something we're likely to support in the ne... | [
{
"body": "### Initial Checks\r\n\r\n- [X] I confirm that I'm using Pydantic V2\r\n\r\n### Description\r\n\r\nHello!\r\n\r\nI am aware that `model_config` should be `ConfigDict()` and this is class/instance attribute as written in documentation.\r\n\r\nI was trying to fix this behavior for my local very specifi... | 325ddf65af3ce01619b6ed028a6322d71f3c3c49 | {
"head_commit": "f58744d9531cdf77b89a6cc9acb26a1fe79bb351",
"head_commit_message": "issue-8469: adds a test of model_config usage in dataclasses",
"patch_to_review": "diff --git a/docs/errors/usage_errors.md b/docs/errors/usage_errors.md\nindex 27155c949a0..1dccd4d1d89 100644\n--- a/docs/errors/usage_errors.md\n... | [
{
"diff_hunk": "@@ -116,6 +116,13 @@ def for_model(cls, bases: tuple[type[Any], ...], namespace: dict[str, Any], kwar\n config_class_from_namespace = namespace.get('Config')\n config_dict_from_namespace = namespace.get('model_config')\n \n+ raw_annotations = namespace.get('__annotations__... | 2149ee1b68e0b0d144404a7a43eea14c9665fb8a | diff --git a/docs/errors/usage_errors.md b/docs/errors/usage_errors.md
index 27155c949a0..dc08a3d1922 100644
--- a/docs/errors/usage_errors.md
+++ b/docs/errors/usage_errors.md
@@ -1089,4 +1089,19 @@ pydantic.errors.PydanticUserError: Dataclass field bar has init=False and init_v
"""
```
+## `model_config` is used ... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} |
pyro-ppl__pyro-2285@16f7fde | pyro-ppl/pyro | Python | 2,285 | Implement GaussianHMM.posterior().rsample() | Resolves #2182
1. Adds a method `GaussianHMM.posterior(likelihood)` that produces a new `GaussianHMM` instance incorporating the original `GaussianHMM` thought of as a prior, and the `likelihood` distribution (a MVN or Independent(Normal)).
2. Implements a parallel-scan forward-filter backward-rsample algorithm `_... | 2020-01-26T07:28:01Z | FR parallel-scan GaussianHMM.rsample()
`GaussianHMM.rsample()` would enable a powerful class of guides for time-series models with non-Gaussian likelihoods. Consider for example a guide:
```py
from pyro.distributions import GaussianHMM
from pyro.ops.gaussian import Gaussian
def model(data):
p_z = GaussianHMM... | [
{
"body": "`GaussianHMM.rsample()` would enable a powerful class of guides for time-series models with non-Gaussian likelihoods. Consider for example a guide:\r\n```py\r\nfrom pyro.distributions import GaussianHMM\r\nfrom pyro.ops.gaussian import Gaussian\r\n\r\ndef model(data):\r\n p_z = GaussianHMM(*my_pri... | 73af4ff4a6b72e06b1542d98579f4c45f95cd4c9 | {
"head_commit": "16f7fdeb63b37bd287d175a821d82fc68fdbe861",
"head_commit_message": "Add test of posterior sampling",
"patch_to_review": "diff --git a/pyro/distributions/hmm.py b/pyro/distributions/hmm.py\nindex 8593a566b3..9d4d50cd41 100644\n--- a/pyro/distributions/hmm.py\n+++ b/pyro/distributions/hmm.py\n@@ -3... | [
{
"diff_hunk": "@@ -405,6 +465,38 @@ def filter(self, value):\n return MultivariateNormal(loc, precision_matrix=precision,\n validate_args=self._validate_args)\n \n+ def posterior(self, likelihood):\n+ \"\"\"\n+ Create a new :class:`GaussianHMM` incorpo... | 181342b480bde59f05f9f9ce567260e2ae99b377 | diff --git a/pyro/distributions/hmm.py b/pyro/distributions/hmm.py
index 89fffbadd8..c553e9a6e4 100644
--- a/pyro/distributions/hmm.py
+++ b/pyro/distributions/hmm.py
@@ -3,7 +3,6 @@
import torch
from torch.distributions import constraints
-from torch.distributions.utils import lazy_property
from pyro.distributi... | {
"difficulty": "high",
"estimated_review_effort": 4,
"problem_domain": "New Feature Additions"
} | |
pytest-dev__pytest-7939@0a1882b | pytest-dev/pytest | Python | 7,939 | #7938 - [Plugin: Stepwise][Enhancements] Refactoring, smarter registration & --sw-skip functionality | Hi team, hope you are all keeping well. While trying to advance my knowledge of the project I have been understanding plugins a little bit. Here is a small PR to tidy up some of the stepwise plugin code for consistency. Some of the most important changes are:
- Stop registering the plugin if stepwise itself is n... | 2020-10-25T11:04:34Z | [Feature] Allow a --sw-skip shorthand cli arg like --sw itself permits
The stepwise plugin exposes a shorthand option for the stepwise itself, however it requires a longer arg only for skip, I think these should be consistent and should offer shorthand versions for both.
```python
def pytest_addoption(parser: Parse... | [
{
"body": "The stepwise plugin exposes a shorthand option for the stepwise itself, however it requires a longer arg only for skip, I think these should be consistent and should offer shorthand versions for both.\r\n\r\n```python\r\ndef pytest_addoption(parser: Parser) -> None:\r\n group = parser.getgroup(\"g... | 65e6e39b76c236999fc53823892c26367a85a8f8 | {
"head_commit": "0a1882baecb0ab61514ea06fae18aa6c61b6ede9",
"head_commit_message": "add changelog for #7938",
"patch_to_review": "diff --git a/changelog/7938.improvement.rst b/changelog/7938.improvement.rst\nnew file mode 100644\nindex 00000000000..8aea0f2418e\n--- /dev/null\n+++ b/changelog/7938.improvement.rst... | [
{
"diff_hunk": "@@ -8,53 +9,70 @@\n from _pytest.main import Session\n from _pytest.reports import TestReport\n \n+if TYPE_CHECKING:\n+ from _pytest.cacheprovider import Cache\n+\n+STEPWISE_CACHE_DIR = \"cache/stepwise\"\n+NO_PREVIOUSLY_FAILED_WONT_SKIP = \"no previously failed tests, not skipping.\"\n+PREVI... | dd3199cee2d37269bf4365a8b30ec1a3f09ec482 | diff --git a/changelog/7938.improvement.rst b/changelog/7938.improvement.rst
new file mode 100644
index 00000000000..ffe612d0da6
--- /dev/null
+++ b/changelog/7938.improvement.rst
@@ -0,0 +1 @@
+New ``--sw-skip`` argument which is a shorthand for ``--stepwise-skip``.
diff --git a/src/_pytest/stepwise.py b/src/_pytest/s... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "New Feature Additions"
} | |
onnx__onnx-4270@fe8156b | onnx/onnx | Python | 4,270 | Improve mapping and add more tests for make_tensor | **Describe your changes**
- Refactor mapping
- Deprecate TENSOR_TYPE_TO_STORAGE_TENSOR_TYPE
- Use functions instead of more maps to prevent confusions and save binary size
- Add more tests (test_make_tensor) for more tensor types
**Motivation and Context**
- Relevant to https://github.com/onnx/onnx/issues/4261... | 2022-06-13T20:53:46Z | provide a nicer API for accessing the proper member of TensorProto
Currently code like this is repeated several times:
```py
field = mapping.STORAGE_TENSOR_TYPE_TO_FIELD[
mapping.TENSOR_TYPE_TO_STORAGE_TENSOR_TYPE[data_type]]
getattr(tensor, field)
```
This is repetitive and can be encapsulated in a helpe... | [
{
"body": "Currently code like this is repeated several times:\r\n\r\n```py\r\nfield = mapping.STORAGE_TENSOR_TYPE_TO_FIELD[\r\n mapping.TENSOR_TYPE_TO_STORAGE_TENSOR_TYPE[data_type]]\r\ngetattr(tensor, field)\r\n```\r\n\r\nThis is repetitive and can be encapsulated in a helper function.\r\nAlso the name \"s... | f0d607478424ab9a8d3751a6e15d48c817350f8b | {
"head_commit": "fe8156bc7e806591a0f26f026bb29dc8fb48d5c5",
"head_commit_message": "fix mypy typecheck failures\n\nSigned-off-by: Chun-Wei Chen <jacky82226@gmail.com>",
"patch_to_review": "diff --git a/onnx/helper.py b/onnx/helper.py\nindex 21396aa3075..3c890487ec3 100644\n--- a/onnx/helper.py\n+++ b/onnx/helper... | [
{
"diff_hunk": "@@ -77,3 +68,24 @@\n int(OptionalProto.MAP): 'map_value',\n int(OptionalProto.OPTIONAL): 'optional_value'\n }\n+\n+\n+def to_np_type(tensor_type: str) -> Any:",
"line": null,
"original_line": 73,
"original_start_line": null,
"path": "onnx/mapping.py",
"start_line": nu... | 640f6ded448c7c520be115601c2883148f51b382 | diff --git a/docs/Operators.md b/docs/Operators.md
index 57fa539b43d..7e9e3cd337c 100644
--- a/docs/Operators.md
+++ b/docs/Operators.md
@@ -2978,7 +2978,7 @@ for from_type, to_type in test_cases:
)
elif "STRING" != from_type:
input = np.random.random_sample(shape).astype(
- TENSOR... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Code Refactoring / Architectural Improvement"
} | |
pydantic__pydantic-8950@05e2423 | pydantic/pydantic | Python | 8,950 | Fix schema build for nested dataclasses / TypedDicts with discriminators | Revisit the changes made in https://github.com/pydantic/pydantic/pull/7646, which introduced a few bugs for edge cases when building schemas for nested dataclasses / TypedDicts with discriminators.
Fix https://github.com/pydantic/pydantic/issues/8271
Fix https://github.com/pydantic/pydantic/issues/8628
Selected Re... | 2024-03-05T15:29:46Z | OpenAPI discriminator field disapeared with pydantic v2.5
### Initial Checks
- [X] I confirm that I'm using Pydantic V2
### Description
Hello,
We are using pydantic V2 to generate the openapi schema.
We bumped pydantic from 2.3.0 to 2.5.2 and the discriminator field disappeared in the openapi.yaml.
2.3.... | @BaptisteSaves,
Thanks for reporting this. Looks like a bug! Marking with `good first issue` and `help wanted` in case anyone wants to pick this up to help with our `2.6.0 release`!
@sydney-runkle I would like to take this issue. Can you point me to where I should start looking ?
@StrawHatDrag0n,
Fantastic 😄! My... | [
{
"body": "### Initial Checks\r\n\r\n- [X] I confirm that I'm using Pydantic V2\r\n\r\n### Description\r\n\r\nHello,\r\n\r\nWe are using pydantic V2 to generate the openapi schema.\r\nWe bumped pydantic from 2.3.0 to 2.5.2 and the discriminator field disappeared in the openapi.yaml.\r\n\r\n2.3.0 openapi.yaml\r\... | b09e06cedd18fe8f3bd5983682e81ffe72bb63e9 | {
"head_commit": "05e2423510db14ba575508888a1f06b8de6bfab0",
"head_commit_message": "fix tests for 3.8 and 3.9",
"patch_to_review": "diff --git a/pydantic/_internal/_discriminated_union.py b/pydantic/_internal/_discriminated_union.py\nindex c40117d34e2..1d0f6989b30 100644\n--- a/pydantic/_internal/_discriminated_... | [
{
"diff_hunk": "@@ -185,16 +187,27 @@ def apply(self, schema: core_schema.CoreSchema) -> core_schema.CoreSchema:\n - If discriminator fields have different aliases.\n - If discriminator field not of type `Literal`.\n \"\"\"\n- self.definitions.update(collect_defini... | 5c151c5a7ef0bcebbb5f81e33c4398fc5e1b5077 | diff --git a/pydantic/_internal/_discriminated_union.py b/pydantic/_internal/_discriminated_union.py
index c40117d34e2..684adb16ac8 100644
--- a/pydantic/_internal/_discriminated_union.py
+++ b/pydantic/_internal/_discriminated_union.py
@@ -36,10 +36,14 @@ def set_discriminator_in_metadata(schema: CoreSchema, discrimin... | {
"difficulty": "high",
"estimated_review_effort": 4,
"problem_domain": "Bug Fixes"
} |
pydantic__pydantic-8928@dc0917e | pydantic/pydantic | Python | 8,928 | More helpful error re wrong `model_json_schema` usage | Fix https://github.com/pydantic/pydantic/issues/8896
Selected Reviewer: @davidhewitt | 2024-03-01T15:11:49Z | AssertionError when calling BaseModel.schema_json()
### Initial Checks
- [X] I confirm that I'm using Pydantic V2
### Description
Pyndantic is asking me to report this trivial bug, so I do :smiley:
```
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/holger-local/.local/l... | @hsteinhaus,
Thanks for reporting this. `schema_json()`, or the new (not deprecated) version of said function `model_json_schema()` are meant to be called on subclasses of `BaseModel`, not `BaseModel` itself.
Marking this as resolved.
@sydney-runkle Yes, it is completely clear that calling `model_json_schema()` d... | [
{
"body": "### Initial Checks\n\n- [X] I confirm that I'm using Pydantic V2\n\n### Description\n\nPyndantic is asking me to report this trivial bug, so I do :smiley: \r\n\r\n```\r\nTraceback (most recent call last):\r\n File \"<stdin>\", line 1, in <module>\r\n File \"/home/holger-local/.local/lib/python3.12/... | db0f80904d5603f5d329b48c5ffccbc60a1dc20a | {
"head_commit": "dc0917e6cb8eb7487f21c1bddfe1d21ffca829af",
"head_commit_message": "more descriptive error",
"patch_to_review": "diff --git a/pydantic/json_schema.py b/pydantic/json_schema.py\nindex 33cdb6eb801..b4814353c37 100644\n--- a/pydantic/json_schema.py\n+++ b/pydantic/json_schema.py\n@@ -2176,9 +2176,14... | [
{
"diff_hunk": "@@ -2176,9 +2176,14 @@ def model_json_schema(\n Returns:\n The generated JSON Schema.\n \"\"\"\n+ from .main import BaseModel\n+\n schema_generator_instance = schema_generator(by_alias=by_alias, ref_template=ref_template)\n if isinstance(cls.__pydantic_validator__, _mo... | 1794dcd6a51e6b7284f892eb345bc9b5cfc15d95 | diff --git a/pydantic/json_schema.py b/pydantic/json_schema.py
index 33cdb6eb801..544cb2aa37f 100644
--- a/pydantic/json_schema.py
+++ b/pydantic/json_schema.py
@@ -2176,9 +2176,14 @@ def model_json_schema(
Returns:
The generated JSON Schema.
"""
+ from .main import BaseModel
+
schema_generat... | {
"difficulty": "low",
"estimated_review_effort": 2,
"problem_domain": "Bug Fixes"
} |
pydantic__pydantic-8947@7273619 | pydantic/pydantic | Python | 8,947 | Update create_model() to support typing.Annotated as input | <!-- Thank you for your contribution! -->
<!-- Unless your change is trivial, please create an issue to discuss the change before creating a PR -->
## Change Summary
At the moment, dynamic model creation does not support taking input of typing.Annotated but instead only tuple(<type>, <default value>), taking in ... | 2024-03-05T07:57:48Z | create_model fails to use type annotation of typing.Annotated
### Initial Checks
- [X] I confirm that I'm using Pydantic V2
### Description
Using `create_model` fails with an "A non-annotated attribute" error when using an annotation created with typing.Annotated. This same annotation works as expected when us... | @trippersham,
Thanks for suggesting this. I'm going to mark this as a feature request - this isn't something we've supported in the past afaik, so it's something we'll have to add.
Also marking as `help wanted` if anyone wants to work on this 😄.
Thanks @sydney-runkle for the re-categorization. I saw this pattern... | [
{
"body": "### Initial Checks\r\n\r\n- [X] I confirm that I'm using Pydantic V2\r\n\r\n### Description\r\n\r\nUsing `create_model` fails with an \"A non-annotated attribute\" error when using an annotation created with typing.Annotated. This same annotation works as expected when used to define a field as a sub... | 5c8afe65a69d9fb127c32fbf288156d7c13da346 | {
"head_commit": "7273619f6464e5c2a3a8522903b4e656e2f71ccb",
"head_commit_message": "Add check to only introduce Annotated support for python3.9 or later",
"patch_to_review": "diff --git a/pydantic/main.py b/pydantic/main.py\nindex 39112eadd1b..51ee881e126 100644\n--- a/pydantic/main.py\n+++ b/pydantic/main.py\n@... | [
{
"diff_hunk": "@@ -1473,6 +1474,26 @@ def create_model( # noqa: C901\n 'Field definitions should be a `(<type>, <default>)`.',\n code='create-model-field-definitions',\n ) from e\n+\n+ elif (\n+ sys.version_info >= (3, 9) and f_def.__cl... | 9dd7a1466a0a16e3d1d96b37b1cee5c0708fdf6f | diff --git a/docs/errors/usage_errors.md b/docs/errors/usage_errors.md
index dc08a3d1922..7e9f70f3cdb 100644
--- a/docs/errors/usage_errors.md
+++ b/docs/errors/usage_errors.md
@@ -628,6 +628,19 @@ except PydanticUserError as exc_info:
assert exc_info.code == 'create-model-field-definitions'
```
+Or when you us... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} |
pydantic__pydantic-8904@3b25873 | pydantic/pydantic | Python | 8,904 | Fix discriminated union schema gen bug | Fix https://github.com/pydantic/pydantic/issues/8709
With this code snippet:
```py
from __future__ import annotations
from typing import Literal, Annotated
from pydantic import Field, TypeAdapter, BaseModel
class NestedState(BaseModel):
state_type: Literal["nested"]
substate: AnyState
# If this... | 2024-02-27T16:30:19Z | Recursive model with discriminated union has exponential time and space complexity for validation
### Initial Checks
- [X] I confirm that I'm using Pydantic V2
### Description
When validating the recursive model given in the example, Pydantic has exponential time and space complexity, meaning that validation t... | @palle-k,
Thanks for reporting this. @davidhewitt, could you please take a look at this performance issue when you have a chance? Thank you!
It looks like there's a potential schema-building bug here.
The core schema looks like this:
```
{'definitions': [{'cls': <class '__main__.NestedState'>,
... | [
{
"body": "### Initial Checks\r\n\r\n- [X] I confirm that I'm using Pydantic V2\r\n\r\n### Description\r\n\r\nWhen validating the recursive model given in the example, Pydantic has exponential time and space complexity, meaning that validation time and memory usage may grow indefinitely and rapidly depending on... | 752daaf14181f3d8a410a015482648b8d9d896d1 | {
"head_commit": "3b25873b24e505712adc4635598b037fb53be46d",
"head_commit_message": "fix for earlier python versions",
"patch_to_review": "diff --git a/pydantic/_internal/_discriminated_union.py b/pydantic/_internal/_discriminated_union.py\nindex e3806b8f2fe..6611404e599 100644\n--- a/pydantic/_internal/_discrimi... | [
{
"diff_hunk": "@@ -54,6 +54,7 @@ def inner(s: core_schema.CoreSchema, recurse: _core_utils.Recurse) -> core_schem\n if discriminator is not None:\n if definitions is None:\n definitions = collect_definitions(schema)\n+ definitions = {k: recurse(v, inner) for k... | d35cd68c7c9abc853dd98057ab286a6e63ada60c | diff --git a/pydantic/_internal/_discriminated_union.py b/pydantic/_internal/_discriminated_union.py
index e3806b8f2fe..ae7c7ecb6a8 100644
--- a/pydantic/_internal/_discriminated_union.py
+++ b/pydantic/_internal/_discriminated_union.py
@@ -54,6 +54,12 @@ def inner(s: core_schema.CoreSchema, recurse: _core_utils.Recurs... | {
"difficulty": "medium",
"estimated_review_effort": 4,
"problem_domain": "Performance Optimizations"
} |
pydantic__pydantic-8857@c660b62 | pydantic/pydantic | Python | 8,857 | Improve error message for improper `RootModel` subclasses | Fix https://github.com/pydantic/pydantic/issues/8712
Improve error message in the case where `RootModel` isn't parametrized properly with generics.
Alternative to https://github.com/pydantic/pydantic/pull/8804.
Selected Reviewer: @samuelcolvin | 2024-02-20T15:37:55Z | Weird error message on creating a generic RootModel
### Initial Checks
- [X] I confirm that I'm using Pydantic V2
### Description
When creating a generic `RootModel` without providing the generic to the model in the class inheritance `RootModelRootType` is mentioned in the error message, which is somewhat misleading... | @JensHeinrich,
Thanks for pointing this out. PRs welcome to improve the error message here in the case of subclassing from a non-parametrized `RootModel` class.
Hii @sydney-runkle I'm very interested to work on this! What you suggest? I was thinking into introducing a condition to check if the missing parameter issu... | [
{
"body": "### Initial Checks\n\n- [X] I confirm that I'm using Pydantic V2\n\n### Description\n\nWhen creating a generic `RootModel` without providing the generic to the model in the class inheritance `RootModelRootType` is mentioned in the error message, which is somewhat misleading.\r\n\r\nI would expect `Ro... | 5d09b4754d4abcdfefaae554de4dae36124a683c | {
"head_commit": "c660b62221042644adb1707966c648126fdefae7",
"head_commit_message": "minor test fix",
"patch_to_review": "diff --git a/pydantic/_internal/_model_construction.py b/pydantic/_internal/_model_construction.py\nindex e41d74ab4bd..bfa8ee88add 100644\n--- a/pydantic/_internal/_model_construction.py\n+++ ... | [
{
"diff_hunk": "@@ -137,22 +137,34 @@ def wrapped_model_post_init(self: BaseModel, __context: Any) -> None:\n parent_parameters = getattr(cls, '__pydantic_generic_metadata__', {}).get('parameters', ())\n parameters = getattr(cls, '__parameters__', None) or parent_parameters\n ... | 16e3989f8fc1e265f312e2fb83521077bcb4ae98 | diff --git a/pydantic/_internal/_model_construction.py b/pydantic/_internal/_model_construction.py
index e41d74ab4bd..818efb127a1 100644
--- a/pydantic/_internal/_model_construction.py
+++ b/pydantic/_internal/_model_construction.py
@@ -137,22 +137,40 @@ def wrapped_model_post_init(self: BaseModel, __context: Any) -> N... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} |
onnx__onnx-3792@d2c5d05 | onnx/onnx | Python | 3,792 | Clarify definition of a tensor in IR docs | **Description**
Modify IR.md to include a mathematical definition of a tensor and some edge-case clarifications.
**Motivation and Context**
- Address uncertainties raised here:
- https://github.com/onnx/onnx/issues/3724
- https://github.com/microsoft/onnxruntime-extensions/pull/175#discussion_r733942903
| 2021-10-21T21:41:30Z | Tensor dimensions of size zero
How should a tensor dimension of size zero be interpreted? Is that dimension ignored, or does the tensor have zero elements even if other dimensions are of non-zero size? I could not find this mentioned in the documentation.
The refernce output of backend test 'slice start out of bound... | Hi @kraiskil,
For a tensor whose shape consists zero dimension and non-zero dimension at the same time (e.g., (20, 0, 5)), the tensor has zero elements. And this behavior is similar to NumPy. This kind of tensors exist in some real-world models after Clip node.
But please note that this kind of tensors like (20, 0,... | [
{
"body": "How should a tensor dimension of size zero be interpreted? Is that dimension ignored, or does the tensor have zero elements even if other dimensions are of non-zero size? I could not find this mentioned in the documentation.\r\n\r\nThe refernce output of backend test 'slice start out of bounds' has t... | d4f4c867c12bd0ef1c7b3e27cd111c608a09f8c1 | {
"head_commit": "d2c5d0545876d40cdfa96d05ece05d6a5d071c0d",
"head_commit_message": "Clarify definition of a tensor in IR docs\n\nSigned-off-by: Tom Wildenhain <tomwi@microsoft.com>",
"patch_to_review": "diff --git a/docs/IR.md b/docs/IR.md\nindex 73e96a6098e..ba8afde075d 100644\n--- a/docs/IR.md\n+++ b/docs/IR.m... | [
{
"diff_hunk": "@@ -316,6 +316,29 @@ The following data types are supported by ONNX for inputs and outputs of graphs\n \n Primitive numeric, string, and Boolean types MUST be used as elements of tensors.\n \n+### Tensor Definition\n+\n+Tensors are a generalization of vectors and matrices; whereas vectors have o... | 2585789c835c694de16296c3e55c63b8ea9b30de | diff --git a/docs/IR.md b/docs/IR.md
index 73e96a6098e..67234558759 100644
--- a/docs/IR.md
+++ b/docs/IR.md
@@ -316,6 +316,28 @@ The following data types are supported by ONNX for inputs and outputs of graphs
Primitive numeric, string, and Boolean types MUST be used as elements of tensors.
+### Tensor Definition
... | {
"difficulty": "low",
"estimated_review_effort": 1,
"problem_domain": "Bug Fixes"
} |
onnx__onnx-3806@1b44e37 | onnx/onnx | Python | 3,806 | Enhance shape inference: ParseData/Transpose/QuantizeLinear | **Description**
1. Enhance ParseData check: having raw_data cannot be String
2 Transpose should check repeated perm to prevent issues
3 If third input (y_zero_point) of QuantizeLinear is an empty string, shape inference should still work because y_zero_point is an optional input
**Motivation and Context**
1. Co... | 2021-10-26T01:30:54Z | ONNX checker doesn't check repeated permutation for Transpose operator
# Bug Report
### Is the issue related to model conversion?
If the ONNX checker reports issues with this model then this is most probably related to the converter used to convert the original framework model to ONNX. Please create this bug in the... | Hi @GuanLuo,
Thank you for identifying this issue. I can verify it -- ONNX shape inference for Transpose does not check whether any perm value is repeated: https://github.com/onnx/onnx/blob/master/onnx/defs/tensor/defs.cc#L1157, but NumPy and [ONNXRuntime](https://github.com/microsoft/onnxruntime/blob/0367e1f1c27ab097... | [
{
"body": "# Bug Report\r\n\r\n### Is the issue related to model conversion?\r\nIf the ONNX checker reports issues with this model then this is most probably related to the converter used to convert the original framework model to ONNX. Please create this bug in the appropriate converter's GitHub repo (pytorch,... | d7c546b874c2fde25e2a337f04eb1f6e08abfc62 | {
"head_commit": "1b44e37018ae8d0a18d64a9defa076ed8de4c4c0",
"head_commit_message": "quant-10 as well\n\nSigned-off-by: Chun-Wei Chen <jacky82226@gmail.com>",
"patch_to_review": "diff --git a/onnx/defs/quantization/defs.cc b/onnx/defs/quantization/defs.cc\nindex a5d69a2ed93..ca20b931082 100644\n--- a/onnx/defs/qu... | [
{
"diff_hunk": "@@ -1174,7 +1175,14 @@ ONNX_OPERATOR_SET_SCHEMA(\n oss << \"}\";\n }\n fail_type_inference(oss.str());\n+ } else {\n+ // check if any perm is repeated\n+ if (seen[fromDimIndex]) {\n+ fai... | 6d7c248824895c81170e648914e57d24e6fdb228 | diff --git a/onnx/defs/quantization/defs.cc b/onnx/defs/quantization/defs.cc
index a5d69a2ed93..ca20b931082 100644
--- a/onnx/defs/quantization/defs.cc
+++ b/onnx/defs/quantization/defs.cc
@@ -55,14 +55,14 @@ ONNX_OPERATOR_SET_SCHEMA(
.SetDoc(QuantizeLinear_ver13_doc)
.TypeAndShapeInferenceFunction(
... | {
"difficulty": "medium",
"estimated_review_effort": 4,
"problem_domain": "Bug Fixes"
} |
onnx__onnx-3966@ae7bc28 | onnx/onnx | Python | 3,966 | mypy: update to 0.782 and enable it with Python 3.8 and 3.9 | **Description**
- Update to mypy 0.782
- Fix mypy failures for Python 3.8 and 3.9
- Add Python 3.8 and 3.9 in AzurePipeline to cover this mypy typecheck for Python 3.8 and 3.9
**Motivation**
Closes #3968. Current mypy version 0.760 cannot pass by Python 3.8 and Python 3.9 | 2022-01-24T04:17:24Z | mypy typecheck (mypy version now is 0.760 in main branch) cannot work with Python 3.8 and 3.9
# Bug Report
mypy typecheck (mypy 0.760 in main branch) cannot work with Python 3.8 and 3.9. It will throw few check errors. It is not caught by CI (AzurePipeline) because it only uses Python 3.6 and 3.7 with mypy typecheck.... | [
{
"body": "# Bug Report\r\nmypy typecheck (mypy 0.760 in main branch) cannot work with Python 3.8 and 3.9. It will throw few check errors. It is not caught by CI (AzurePipeline) because it only uses Python 3.6 and 3.7 with mypy typecheck. We should add 3.8 and 3.9 in AzurePipeline to cover it.\r\n\r\n### Reprod... | 83fa57c74edfd13ddac9548b8a12f9e3e2ed05bd | {
"head_commit": "ae7bc28c09ddc7463e5757b97f53c5327197e0f8",
"head_commit_message": "Merge branch 'main' into jcw/mypy3.9",
"patch_to_review": "diff --git a/.azure-pipelines/Windows-CI.yml b/.azure-pipelines/Windows-CI.yml\nindex ef986a77140..7e2eca46595 100644\n--- a/.azure-pipelines/Windows-CI.yml\n+++ b/.azure... | [
{
"diff_hunk": "@@ -159,7 +159,7 @@ def report_csv(self, all_ops, passed, experimental): # type: (List[Text], List[\n if os.path.isfile(nodes_path):\n with open(nodes_path, 'r') as nodes_file:\n reader = csv.DictReader(nodes_file)\n- frameworks = list(reader.f... | 7598deff1f78275093a5ab300b890f4cae1b5636 | diff --git a/.azure-pipelines/Windows-CI.yml b/.azure-pipelines/Windows-CI.yml
index ef986a77140..7e2eca46595 100644
--- a/.azure-pipelines/Windows-CI.yml
+++ b/.azure-pipelines/Windows-CI.yml
@@ -8,6 +8,14 @@ jobs:
vmImage: 'windows-2019'
strategy:
matrix:
+ py39:
+ python.version: '3.9'
+ ... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Test Suite / CI Enhancements"
} | |
onnx__onnx-3684@e7c1c4c | onnx/onnx | Python | 3,684 | Set minimum supported Protobuf version as 3.12 since lower versions do not work | **Description**
- Set minimum supported Protobuf version as 3.12 in requirements.txt
- Mention minimum supported dependencies in ReadMe
- Make CIs test with minimum supported Protobuf
**Motivation and Context**
https://github.com/onnx/onnx/issues/3656 The latest ONNX package doesn't work with some old protobuf p... | 2021-08-26T18:48:12Z | The latest ONNX package doesn't work with some old protobuf package
# Bug Report
The ONNX python dependency doesn't set minimal version on protobuf.
But I just noticed that with protobuf 3.11, there is an exception on loading an onnx model.
E AttributeError: module 'google.protobuf.descriptor' has no attribute '_i... | [
{
"body": "# Bug Report\r\nThe ONNX python dependency doesn't set minimal version on protobuf.\r\nBut I just noticed that with protobuf 3.11, there is an exception on loading an onnx model.\r\nE AttributeError: module 'google.protobuf.descriptor' has no attribute '_internal_create_key' on Windows Platform.\r\... | 208ac9b998556cbc5112cdf1b43e7ef679831560 | {
"head_commit": "e7c1c4c848160ef73742cdae5b5da2800facb193",
"head_commit_message": "set 3.12.0\n\nSigned-off-by: Chun-Wei Chen <jacky82226@gmail.com>",
"patch_to_review": "diff --git a/.github/workflows/manylinux/test_package_i686.sh b/.github/workflows/manylinux/test_package_i686.sh\nindex da9e53b69ef..f4bca307... | [
{
"diff_hunk": "@@ -140,7 +140,15 @@ jobs:\n cd onnx\n python -m pip uninstall -y protobuf onnx && python -m pip install protobuf\n Get-ChildItem -Path dist/*.whl | foreach {python -m pip install --upgrade $_.fullname}\n- pytest \n+ pytest\n+\n+ - name: Verify ONN... | 57dab2be6a0e626da9b55d85481adbb4ade78486 | diff --git a/.github/workflows/manylinux/test_package_i686.sh b/.github/workflows/manylinux/test_package_i686.sh
index da9e53b69ef..ab5084b402a 100644
--- a/.github/workflows/manylinux/test_package_i686.sh
+++ b/.github/workflows/manylinux/test_package_i686.sh
@@ -43,4 +43,9 @@ $PIP_UNINSTALL_COMMAND protobuf onnx && $... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Dependency Updates & Env Compatibility"
} | |
pytest-dev__pytest-7643@2213016 | pytest-dev/pytest | Python | 7,643 | Fix Module.name from full path without drive letter | Fix #7628
| 2020-08-14T00:41:53Z | pytest-6.0.1 does not find custom fixtures, test filename incorrect (just ..\..\)
```
============================= test session starts =============================
platform win32 -- Python 3.7.0, pytest-6.0.1, py-1.9.0, pluggy-0.13.1 -- c:\prog
ram files (x86)\python37-32\python.exe
cachedir: .pytest_cache
metad... | Hi @naugustin - can you share a reproducing example that we can run? The test output helps, but being able to replay your problem locally is a lot better :slightly_smiling_face:
Thank you.
I mimicked my fixture order with simple script. I am able to reproduce it. please find attached the script. Simply unzip under... | [
{
"body": "```\r\n============================= test session starts =============================\r\nplatform win32 -- Python 3.7.0, pytest-6.0.1, py-1.9.0, pluggy-0.13.1 -- c:\\prog\r\nram files (x86)\\python37-32\\python.exe\r\ncachedir: .pytest_cache\r\nmetadata: {'Python': '3.7.0', 'Platform': 'Windows-2008... | 3f0abcc6a5e0ddf1c17d42125421c6816fcf3178 | {
"head_commit": "2213016e40176cdcb1397ad03499ed1881d89ac9",
"head_commit_message": "Fix Module.name from full path without drive letter\n\nFix #7628",
"patch_to_review": "diff --git a/changelog/7628.bugfix.rst b/changelog/7628.bugfix.rst\nnew file mode 100644\nindex 00000000000..9f3480aaa65\n--- /dev/null\n+++ b... | [
{
"diff_hunk": "@@ -770,3 +741,59 @@ def genitems(\n for subnode in rep.result:\n yield from self.genitems(subnode)\n node.ihook.pytest_collectreport(report=rep)\n+\n+\n+def search_pypath(module_name: str) -> str:\n+ \"\"\"Search sys.path for the given a dotted... | b426bb3443b0895f8a84379ff4a9949330012d38 | diff --git a/changelog/7628.bugfix.rst b/changelog/7628.bugfix.rst
new file mode 100644
index 00000000000..9f3480aaa65
--- /dev/null
+++ b/changelog/7628.bugfix.rst
@@ -0,0 +1 @@
+Fix test collection when a full path without a drive letter was passed to pytest on Windows (for example ``\projects\tests\test.py`` instead... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} |
pydantic__pydantic-8702@7e8c749 | pydantic/pydantic | Python | 8,702 | Fix regression in core schema generation for indirect definition references | Closes https://github.com/pydantic/pydantic/issues/8688 | 2024-02-02T01:06:08Z | Discriminator attribute missing from model schema in a forwardref in pydantic 2.6
### Initial Checks
- [X] I confirm that I'm using Pydantic V2
### Description
from the sample code below, the `Submodel` schema is missing the `discriminator` tag for the field `steps` , this is not the case when using version 2.... | @vigneshmanick,
Thanks for reporting this. We'll look into a fix to include in a patch release soon!
Huh, I thought we tried to fix this via: https://github.com/pydantic/pydantic/issues/8271. Looks like indeed it hasn't yet been fixed.
@StrawHatDrag0n, any ideas based on your contribution to the aforementioned fi... | [
{
"body": "### Initial Checks\r\n\r\n- [X] I confirm that I'm using Pydantic V2\r\n\r\n### Description\r\n\r\nfrom the sample code below, the `Submodel` schema is missing the `discriminator` tag for the field `steps` , this is not the case when using version 2.5\r\n\r\n#### 2.5\r\n```\r\nsteps\": {\r\n ... | 29906d744d8bae7a7e5fcba653d3867454a9e1d5 | {
"head_commit": "7e8c749d4bcf1442e876f84ab2bfc63c27d85db4",
"head_commit_message": "Fix regression in core schema generation for indirect definition references",
"patch_to_review": "diff --git a/pydantic/_internal/_core_utils.py b/pydantic/_internal/_core_utils.py\nindex 2c2f027af4e..432de5f5655 100644\n--- a/py... | [
{
"diff_hunk": "@@ -1763,3 +1763,90 @@ class CreateObjectDto(BaseModel):\n 'type': 'object',\n },\n }\n+\n+\n+def test_nested_discriminator() -> None:\n+ \"\"\"\n+ The exact details of the JSON schema produced are not necessarily important; the test was added in response to a\n+ ... | 7fb6726a30820685d84ce6611c8e2f14b91d7b00 | diff --git a/pydantic/_internal/_core_utils.py b/pydantic/_internal/_core_utils.py
index 2c2f027af4e..432de5f5655 100644
--- a/pydantic/_internal/_core_utils.py
+++ b/pydantic/_internal/_core_utils.py
@@ -228,7 +228,7 @@ def _handle_ser_schemas(self, ser_schema: core_schema.SerSchema, f: Walk) -> cor
def handle_de... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} |
onnx__onnx-3550@334e552 | onnx/onnx | Python | 3,550 | update protobuf build options and build instructions | Signed-off-by: Ashwini Khade <askhade@microsoft.com>
**Description**
Updates cmakelist.txt to use ONNX_USE_PROTOBUF_SHARED_LIBS to control Protobuf_USE_STATIC_LIBS options as well as these 2 are tightly coupled.
**Motivation and Context**
Fixes #3345 and #3017
| 2021-06-30T22:08:05Z | ONNX_USE_PROTOBUF_SHARED_LIBS should control Protobuf_USE_STATIC_LIBS
# Bug Report
### Describe the bug
ONNX_USE_PROTOBUF_SHARED_LIBS is set independently of Protobuf_USE_STATIC_LIBS even though the two are dependent on each other. Even the documentation says:
If ONNX_USE_PROTOBUF_SHARED_LIBS is ON then Protobuf... | Hi @sstamenova,
Yes it is something needs to be fixed (already in the backlog) and there will be a PR to merge these two flags. Thank you for bringing this up.
I will send out a fix for this. Thanks! | [
{
"body": "# Bug Report\r\n\r\n### Describe the bug\r\nONNX_USE_PROTOBUF_SHARED_LIBS is set independently of Protobuf_USE_STATIC_LIBS even though the two are dependent on each other. Even the documentation says:\r\n\r\nIf ONNX_USE_PROTOBUF_SHARED_LIBS is ON then Protobuf_USE_STATIC_LIBS must be OFF and USE_MSVC... | 6c77a411215305c1a3f355f8c2e4633c19514690 | {
"head_commit": "334e552fe7e7ff066bb2369ff912d5dd3fc3f728",
"head_commit_message": "update readme\n\nSigned-off-by: Ashwini Khade <askhade@microsoft.com>",
"patch_to_review": "diff --git a/.azure-pipelines/Windows-CI.yml b/.azure-pipelines/Windows-CI.yml\nindex 0a4e3279edf..23724333bda 100644\n--- a/.azure-pipel... | [
{
"diff_hunk": "@@ -50,116 +50,83 @@ Stay up to date with the latest ONNX news. [[Facebook](https://www.facebook.com/\n \n # Installation\n \n-## Binaries\n-\n-A binary build of ONNX is available from [Conda](https://conda.io), in [conda-forge](https://conda-forge.org/):\n-\n+## Official Python packages\n+ONNX ... | ce36d288e385dfe3b825bbf8c660b40d9436d543 | diff --git a/.azure-pipelines/Linux-CI.yml b/.azure-pipelines/Linux-CI.yml
index 73ddf1ed726..01616228aa0 100644
--- a/.azure-pipelines/Linux-CI.yml
+++ b/.azure-pipelines/Linux-CI.yml
@@ -51,7 +51,7 @@ jobs:
git submodule update --init --recursive
mkdir build_source && cd build_source
- cmake ../c... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} |
pyro-ppl__pyro-1462@9d597bd | pyro-ppl/pyro | Python | 1,462 | Fix pickling of dynamically imported torch distributions | Fixes #1456
Note that pickling`torch.Size()` requires pickle protocol >= 2.
`Gumbel` currently fails due to its use of an inverse transform. I believe this can be fixed upstream by adding `__getstate__` and `__setstate__` methods to `InverseTransform`.
## Tested
- Added a `pickle.dumps()` test for all Pyro... | 2018-10-17T20:30:11Z | Make dynamic distribution mixin wrappers in torch.py picklable
We load torch distributions and create distribution mixin classes dynamically in `torch.py`. These distribution instances are not picklable however.
```python
>>> pickle.dumps(Pareto(1., 1.))
Traceback (most recent call last):
File "<stdin>", line 1... | I'd guess we can simply set `type(...).__name__` to e.g. `Pareto` and set that as a module level variable in the `pyro.distributions.torch` module.
@fritzo - This is only an issue if we have distribution classes in PyTorch that we would like to dynamically import.
If `Pareto` is available as a module level variable... | [
{
"body": "We load torch distributions and create distribution mixin classes dynamically in `torch.py`. These distribution instances are not picklable however.\r\n\r\n```python\r\n>>> pickle.dumps(Pareto(1., 1.))\r\nTraceback (most recent call last):\r\n File \"<stdin>\", line 1, in <module>\r\n_pickle.Picklin... | 7076945b9729158c50eceb9facc0f48b4978c731 | {
"head_commit": "9d597bd95bcc1447bfedbfa34c2371ada0fbd972",
"head_commit_message": "Fix pickling of dynamically imported torch distributions",
"patch_to_review": "diff --git a/pyro/distributions/torch.py b/pyro/distributions/torch.py\nindex ea82e5504b..ccd575b1ae 100644\n--- a/pyro/distributions/torch.py\n+++ b/... | [
{
"diff_hunk": "@@ -0,0 +1,80 @@\n+from __future__ import absolute_import, division, print_function\n+\n+import inspect\n+\n+import pytest\n+import six.moves.cPickle as pickle\n+import torch\n+\n+import pyro.distributions as dist\n+from pyro.distributions.torch_distribution import TorchDistributionMixin\n+from ... | 594730a99fff7e430c2a34c8bce285d6faf20d82 | diff --git a/pyro/distributions/torch.py b/pyro/distributions/torch.py
index ea82e5504b..ccd575b1ae 100644
--- a/pyro/distributions/torch.py
+++ b/pyro/distributions/torch.py
@@ -313,11 +313,8 @@ def expand(self, batch_shape):
try:
_PyroDist = locals()[_name]
except KeyError:
-
- class _PyroDi... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} |
onnx__onnx-3539@ede3f49 | onnx/onnx | Python | 3,539 | Add shape inference function for dynamic quantize linear | Signed-off-by: Anna Jung (VMware) <antheaj@vmware.com>
**Description**
- Add shape inference function to dynamic quantize linear
**Motivation and Context**
- Why is this change required? What problem does it solve?
explicitly add shape inference function
- If it fixes an open issue, please link to the issu... | 2021-06-22T15:28:08Z | DynamicQuantizeLinear function does not have shape inference function
# Bug Report
### Is the issue related to model conversion? No
### Describe the bug
DynamicQuantizeLinear function op does not have shape inference function defined. In absence of shape inference, function body is used to get the shape inferenc... | @annajung : Can you pick this up?
Yeah, I'll give it a try! :D
Thanks we are targeting this for ONNX 1.10 release which is planned for July end.
Hi @askhade, started working on this and have a question about if there is a good way to set the dim value for the outputs? Is the right way is to calculate each output in th... | [
{
"body": "# Bug Report\r\n\r\n### Is the issue related to model conversion? No\r\n\r\n### Describe the bug\r\nDynamicQuantizeLinear function op does not have shape inference function defined. In absence of shape inference, function body is used to get the shape inference for the function op and although it wor... | e6ea9356fb4ba62515fa1cc9591eab5130c2e5ab | {
"head_commit": "ede3f4902be3a0a928f59b6f25931812a1af7ffe",
"head_commit_message": "Merge branch 'master' into master",
"patch_to_review": "diff --git a/onnx/defs/quantization/defs.cc b/onnx/defs/quantization/defs.cc\nindex 69ed7d87e7a..7b2f21f6838 100644\n--- a/onnx/defs/quantization/defs.cc\n+++ b/onnx/defs/qu... | [
{
"diff_hunk": "@@ -179,6 +179,20 @@ ONNX_OPERATOR_SET_SCHEMA(\n {{\"Zeropoint\"}, \"Cast\", {\"Rounded_ZeroPoint_FP\"}, {MakeAttribute(\"to\", int64_t(2))}},\n {{\"y_scale\"}, \"Identity\", {\"Scale\"}},\n {{\"y_zero_point\"}, \"Identity\", {\"Zeropoint\"}},\n- {{\"y\... | 2bc843a0d28cfc1db119bebbabfbefe65be4ddfb | diff --git a/onnx/defs/quantization/defs.cc b/onnx/defs/quantization/defs.cc
index 69ed7d87e7a..aa608cf1133 100644
--- a/onnx/defs/quantization/defs.cc
+++ b/onnx/defs/quantization/defs.cc
@@ -179,6 +179,21 @@ ONNX_OPERATOR_SET_SCHEMA(
{{"Zeropoint"}, "Cast", {"Rounded_ZeroPoint_FP"}, {MakeAttribute("to", i... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} |
pydantic__pydantic-8679@5adecc1 | pydantic/pydantic | Python | 8,679 | Fix inheriting annotations in dataclasses | ## Change Summary
We recently modified how we handle making pydantic `Field`s compatible with `dataclass` fields (various changes in 2.6). This fixes an inheritance issue introduced by those changes.
Thanks @alexmojaki for the starter code for the fix!
## Related issue number
Fix https://github.com/pydantic... | 2024-01-30T13:29:11Z | dataclasses lose annotation if Field used in inherited class
### Initial Checks
- [X] I confirm that I'm using Pydantic V2
### Description
pydantic 2.6 (confirmed this works in 2.5).
```
Traceback (most recent call last):
File "pydantic2.6.py", line 9, in <module>
class B(A):
File ".../pydantic/... | @mwalsh161,
Thanks for reporting this. We'll come up with a fix and hopefully get a patch release out tomorrow!
The issue has been introduced in https://github.com/pydantic/pydantic/commit/2e459bb563dbc296c2bcffbfd1a3caf21241b8e0
@hramezani yep, thanks. I'll open a PR early tomorrow morning.
Thanks for the quick tur... | [
{
"body": "### Initial Checks\r\n\r\n- [X] I confirm that I'm using Pydantic V2\r\n\r\n### Description\r\n\r\npydantic 2.6 (confirmed this works in 2.5).\r\n\r\n```\r\nTraceback (most recent call last):\r\n File \"pydantic2.6.py\", line 9, in <module>\r\n class B(A):\r\n File \".../pydantic/dataclasses.py\... | 0404872a7ff406fc9768889c82dab6bb33c5be07 | {
"head_commit": "5adecc19898011960ab9cf6a8743233bc2679921",
"head_commit_message": "fix annotations issue + tests",
"patch_to_review": "diff --git a/pydantic/dataclasses.py b/pydantic/dataclasses.py\nindex bb26540cce7..d9c9c903b1d 100644\n--- a/pydantic/dataclasses.py\n+++ b/pydantic/dataclasses.py\n@@ -93,7 +93... | [
{
"diff_hunk": "@@ -2759,3 +2759,88 @@ def test_disallow_init_false_and_init_var_true() -> None:\n @pydantic.dataclasses.dataclass\n class Foo:\n bar: str = Field(..., init=False, init_var=True)\n+\n+\n+def test_annotations_valid_for_field_inheritance() -> None:\n+ # testing https... | 3f78821533247acea6ed5459f289b17de51a0bac | diff --git a/pydantic/dataclasses.py b/pydantic/dataclasses.py
index bb26540cce7..d9c9c903b1d 100644
--- a/pydantic/dataclasses.py
+++ b/pydantic/dataclasses.py
@@ -93,7 +93,7 @@ def dataclass(
@dataclass_transform(field_specifiers=(dataclasses.field, Field))
-def dataclass(
+def dataclass( # noqa: C901
_cls... | {
"difficulty": "medium",
"estimated_review_effort": 4,
"problem_domain": "Bug Fixes"
} |
pyro-ppl__pyro-1417@2913880 | pyro-ppl/pyro | Python | 1,417 | Add naive_ubersum reference implementation + tests | Addresses #1391
Fixes #1414
This clarifies the semantics of `ubersum()` by adding a simple reference implementation. The `naive_ubersum()` reference implementation is slow but handles both polynomial-time and exponential-time contractions, whereas `ubersum()` currently raises `NotImplementedError` for exponential-t... | 2018-09-27T00:02:48Z | test_contract failing on PyTorch master
Some of our einsum tests (`test_ubersum_sizes`) are failing on PyTorch master:
e.g.
```python
X = torch.randn(2, 1)
Y = torch.randn(1, 3)
Z = torch.randn(3, 4)
ubersum('ab,bc,cd->a,b,c,d', X, Y, Z, batch_dims='ad')
```
throws an exception,
```
if len(ope... | [
{
"body": "Some of our einsum tests (`test_ubersum_sizes`) are failing on PyTorch master:\r\n\r\ne.g.\r\n\r\n```python\r\nX = torch.randn(2, 1)\r\nY = torch.randn(1, 3)\r\nZ = torch.randn(3, 4)\r\nubersum('ab,bc,cd->a,b,c,d', X, Y, Z, batch_dims='ad')\r\n```\r\n\r\nthrows an exception,\r\n\r\n```\r\n if ... | fe07e9ea7a3451a260bfe6755c688ec28a387b88 | {
"head_commit": "29138808d0a1707a8d9b9eeabb6e5c401e711811",
"head_commit_message": "Add naive_ubersum reference implementation and tests",
"patch_to_review": "diff --git a/pyro/ops/contract.py b/pyro/ops/contract.py\nindex 141a650716..c4c6ea7547 100644\n--- a/pyro/ops/contract.py\n+++ b/pyro/ops/contract.py\n@@ ... | [
{
"diff_hunk": "@@ -487,3 +492,97 @@ def ubersum(equation, *operands, **kwargs):\n term = term.permute(*map(dims.index, output))\n results.append(term)\n return tuple(results)\n+\n+\n+def naive_ubersum(equation, *operands, **kwargs):\n+ \"\"\"\n+ Slow reference implementati... | cea6b6aba69f5ef90fb27b83a6a69ba28ef2b8e9 | diff --git a/pyro/ops/contract.py b/pyro/ops/contract.py
index 141a650716..5156747422 100644
--- a/pyro/ops/contract.py
+++ b/pyro/ops/contract.py
@@ -1,11 +1,14 @@
from __future__ import absolute_import, division, print_function
+import itertools
from abc import ABCMeta, abstractmethod
from collections import Ord... | {
"difficulty": "high",
"estimated_review_effort": 4,
"problem_domain": "Bug Fixes"
} | |
onnx__onnx-3280@66ffdc2 | onnx/onnx | Python | 3,280 | Modify existing function in external data helper | Signed-off-by: Anna Jung (VMware) <antheaj@vmware.com>
Update external data helpers to modify an existing function `convert_model_to_external_data` to take a `model_file_path` and `convert_attribute` to convert attributes to external data only when specified to `true` and to save the model when `model_file_path` is ... | 2021-02-17T20:24:41Z | Updates to external data helpers
Add a new API for converting a model to external data. Today the conversion happens in 2 steps
`external_data_helper.convert_model_to_external_data(<model>,
<all_tensors_to_one_file>, <size_threshold>)
save_model(model, output_... | Hi @askhade, thanks for suggesting me to work on this issue!
I have a question about `conver_attributes` parameter in the `save_model_to_external_data`.
Neither of `convert_model_to_external_data` and `save_model` has this input. So wondering what your thoughts are in including this in the combined API `save_model... | [
{
"body": "Add a new API for converting a model to external data. Today the conversion happens in 2 steps\r\n`external_data_helper.convert_model_to_external_data(<model>,\r\n <all_tensors_to_one_file>, <size_threshold>)\r\n save_model(model, output_path)\r\... | 39df720cca9c4a833a3de3a6bc1d4667c1a8e58b | {
"head_commit": "66ffdc28c34813e1dda0d208931c23d43a8868a0",
"head_commit_message": "Modify existing save model api to optionally convert and save as external data\n\nSigned-off-by: Anna Jung (VMware) <antheaj@vmware.com>",
"patch_to_review": "diff --git a/docs/ExternalData.md b/docs/ExternalData.md\nindex 7d35ac... | [
{
"diff_hunk": "@@ -172,18 +172,29 @@ def load_tensor_from_string(s, format=None): # type: (bytes, Optional[Any]) ->\n return _deserialize(s, TensorProto())\n \n \n-def save_model(proto, f, format=None): # type: (Union[ModelProto, bytes], Union[IO[bytes], Text], Optional[Any]) -> None\n+def save_model(pro... | 33a721b1a323588661207c1e552a10d81106be0b | diff --git a/docs/ExternalData.md b/docs/ExternalData.md
index 7d35ac8b84f..c1e53d7bef6 100644
--- a/docs/ExternalData.md
+++ b/docs/ExternalData.md
@@ -22,6 +22,27 @@ load_external_data_for_model(onnx_model, 'data/directory/path/')
# Then the onnx_model has loaded the external data from the specific directory
```
... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "New Feature Additions"
} |
pytest-dev__pytest-7500@97f8a95 | pytest-dev/pytest | Python | 7,500 | Inaccessible lock files now imply temporary directories can't be removed | Fix #7491
| 2020-07-14T23:09:45Z | Cleaning up temporary directories occasionally raises PermissionError
On Windows, I'm finding that *pytest* occasionally raises an exception starting with `PermissionError: [WinError 5] Access is denied` while cleaning up its temporary directories. Below is an example of the output of a test session in which the excep... | Hi @stanwest,
The order should not really matter in that situation, what might be happening is that by first cleaning up the `garbage-*` directories, this is giving more time for whatever is holding the locked directories to release that lock (say a background process), and then it might appear to solve the problem.... | [
{
"body": "On Windows, I'm finding that *pytest* occasionally raises an exception starting with `PermissionError: [WinError 5] Access is denied` while cleaning up its temporary directories. Below is an example of the output of a test session in which the exception arises. The test file contains only the funct... | 358150c30ee77c4b38dd63125d42d071304baf48 | {
"head_commit": "97f8a9537203321629fd4d872881935781c42d8b",
"head_commit_message": "Inaccessible lock files imply temporary directories can't be removed\n\nFix #7491",
"patch_to_review": "diff --git a/changelog/7491.bugfix.rst b/changelog/7491.bugfix.rst\nnew file mode 100644\nindex 00000000000..5b00a5713b5\n---... | [
{
"diff_hunk": "@@ -358,7 +358,7 @@ def test_get_extended_length_path_str():\n \n \n def test_suppress_error_removing_lock(tmp_path):\n- \"\"\"ensure_deletable should not raise an exception if the lock file cannot be removed (#5456)\"\"\"\n+ \"\"\"ensure_deletable should not be resilient if lock file cann... | 5d8f8a1153dffcb415b654280a24c7935b25788c | diff --git a/changelog/7491.bugfix.rst b/changelog/7491.bugfix.rst
new file mode 100644
index 00000000000..5b00a5713b5
--- /dev/null
+++ b/changelog/7491.bugfix.rst
@@ -0,0 +1,2 @@
+:fixture:`tmpdir` and :fixture:`tmp_path` no longer raise an error if the lock to check for
+stale temporary directories is not accessible... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} |
pydantic__pydantic-8642@8ee1de8 | pydantic/pydantic | Python | 8,642 | Add a check on the existence of `__qualname__` | <!-- Thank you for your contribution! -->
<!-- Unless your change is trivial, please create an issue to discuss the change before creating a PR -->
## Change Summary
Add a check on the existence of `__qualname__` in the `namespace` in function `inspect_namespace`, to avoid unexpected `KeyError `when setting a ty... | 2024-01-26T04:05:57Z | Unexpected KeyError occured when calling `create_model` with a `type`-type field which is defined in the same module
### Initial Checks
- [X] I confirm that I'm using Pydantic V2
### Description
When create a model by calling `create_model`, there is no `__qualname__` in the model's `namespace`. According to the fol... | @anci3ntr0ck,
Thanks for reporting this. I think the issue can be solved by simply adding a check on the existence of the `__qualname__` in the namespace, like this:
```py
elif (
isinstance(value, type)
and value.__module__ == namespace['__module__']
and namespace.get('__qualname__')
and valu... | [
{
"body": "### Initial Checks\n\n- [X] I confirm that I'm using Pydantic V2\n\n### Description\n\nWhen create a model by calling `create_model`, there is no `__qualname__` in the model's `namespace`. According to the following code in `pydantic._internal._model_construction`, a KeyError will be raised when addi... | 279277558a9860192508ca3a4cdafe706f2fd1ad | {
"head_commit": "8ee1de8fdd48173542377e6e84c3f1431b9ebf83",
"head_commit_message": "Add a check on the existence of `__qualname__`",
"patch_to_review": "diff --git a/pydantic/_internal/_model_construction.py b/pydantic/_internal/_model_construction.py\nindex 543f73e974d..e41d74ab4bd 100644\n--- a/pydantic/_inter... | [
{
"diff_hunk": "@@ -601,3 +601,10 @@ class Y:\n )\n Z = create_model('Z', y=(module.Y, ...))\n assert Z(y={'x': {}}).y is not None\n+\n+\n+def test_type_field_in_the_same_module():\n+ class A:\n+ pass\n+\n+ create_model('B', a_cls=(type, A))",
"line": null,
"original_line": 610,... | e73cccbb46528d873e31eaf1a24d7367a6126e19 | diff --git a/pydantic/_internal/_model_construction.py b/pydantic/_internal/_model_construction.py
index 543f73e974d..e41d74ab4bd 100644
--- a/pydantic/_internal/_model_construction.py
+++ b/pydantic/_internal/_model_construction.py
@@ -334,6 +334,7 @@ def inspect_namespace( # noqa C901
elif (
is... | {
"difficulty": "low",
"estimated_review_effort": 2,
"problem_domain": "Bug Fixes"
} |
pyro-ppl__pyro-939@e203e4d | pyro-ppl/pyro | Python | 939 | miscellaneous elbo/test cleanup | - fattened docstrings for trace_elbo and tracegraph_elbo
- removed tests/distributions/test_transformed_distribution.py
this shouldn't be needed anymore. please confirm @neerajprad @fritzo
- removed lognormal tests in test_inference.py and test_tracegraph_elbo.py whose main
purpose in life was to test trans... | 2018-03-27T16:29:25Z | tracegraph_elbo related cleanup
- [x] refactor vectorized_map_data_info and related data structures
- [x] refactor way prune_subsample_sites etc. is used to setup a trace for computation
- [x] rethink any needed asserts/warnings in tracegraph_elbo or trace_poutine
- [x] go through test_valid_models and make sure we ... | [
{
"body": "- [x] refactor vectorized_map_data_info and related data structures\r\n- [x] refactor way prune_subsample_sites etc. is used to setup a trace for computation\r\n- [x] rethink any needed asserts/warnings in tracegraph_elbo or trace_poutine\r\n- [x] go through test_valid_models and make sure we have go... | 9ad52ee41c2f17e0287df0114abef918f61cabf9 | {
"head_commit": "e203e4d7e5994be2fb252debac7dfedf5ba9b510",
"head_commit_message": "typo#2",
"patch_to_review": "diff --git a/pyro/infer/trace_elbo.py b/pyro/infer/trace_elbo.py\nindex fc41fe9398..ec79b9bcfa 100644\n--- a/pyro/infer/trace_elbo.py\n+++ b/pyro/infer/trace_elbo.py\n@@ -26,7 +26,22 @@ def _compute_l... | [
{
"diff_hunk": "@@ -170,9 +170,14 @@ class TraceGraph_ELBO(ELBO):\n A TraceGraph implementation of ELBO-based SVI. The gradient estimator\n is constructed along the lines of reference [1] specialized to the case\n of the ELBO. It supports arbitrary dependency structure for the model\n- and guide ... | 2f9eb3a39fa1fde93c2ab295298cca1d1eb98cb2 | diff --git a/pyro/infer/trace_elbo.py b/pyro/infer/trace_elbo.py
index fc41fe9398..8d7a0542fd 100644
--- a/pyro/infer/trace_elbo.py
+++ b/pyro/infer/trace_elbo.py
@@ -26,7 +26,22 @@ def _compute_log_r(model_trace, guide_trace):
class Trace_ELBO(ELBO):
"""
- A trace implementation of ELBO-based SVI
+ A tra... | {
"difficulty": "low",
"estimated_review_effort": 2,
"problem_domain": "Code Refactoring / Architectural Improvement"
} | |
pyro-ppl__pyro-824@0b7ea4a | pyro-ppl/pyro | Python | 824 | Resolve changes in tensor/variable API with PyTorch master | This resolves a few minor issues so as to keep in sync with PyTorch master.
- `tensor[0]` returns a `Variable` scalar instead of a python numeric type. We need to use `.item()` to convert a PyTorch scalar into a python numeric type.
- `.data` returns an instance of type `Variable` and not `torch.Tensor`. Instead of... | 2018-02-27T01:02:01Z | Support PyTorch after Variable+Tensor were merged
Pyro is behind PyTorch master and needs to be updated now that `Tensor` and `Variable` were merged. This is logically orthogonal to the rest of our refactoring, although there will be lots of superficial merge conflicts. | [
{
"body": "Pyro is behind PyTorch master and needs to be updated now that `Tensor` and `Variable` were merged. This is logically orthogonal to the rest of our refactoring, although there will be lots of superficial merge conflicts.",
"number": 815,
"title": "Support PyTorch after Variable+Tensor were me... | 29654dc78323f81ef6e622af9d6ec9776b4a5d55 | {
"head_commit": "0b7ea4ade3debe50853457c41d379e650344ca99",
"head_commit_message": "detach and call numpy",
"patch_to_review": "diff --git a/examples/air/viz.py b/examples/air/viz.py\nindex 21fecf5877..16b5ebd9b4 100644\n--- a/examples/air/viz.py\n+++ b/examples/air/viz.py\n@@ -35,7 +35,7 @@ def draw_one(imgarr,... | [
{
"diff_hunk": "@@ -149,8 +149,8 @@ def test_shape_augmented_beta(alpha, beta):\n z = dist.rsample()\n cost = z.sum()\n (cost + cost.detach() * dist.score_parts(z)[1]).backward()\n- mean_alpha_grad = alphas.grad.data.mean()\n- mean_beta_grad = betas.grad.data.mean()\n+ mean_alpha_grad = alp... | f8eee2941161bec9633f37036def32e2b5299a5e | diff --git a/README.md b/README.md
index 9c5b6270fd..4d4ceaf8ea 100644
--- a/README.md
+++ b/README.md
@@ -54,7 +54,7 @@ pip install .
For recent features you can install Pyro from source.
-First install a recent PyTorch, currently PyTorch commit `853dba8`.
+First install a recent PyTorch, currently PyTorch commit... | {
"difficulty": "medium",
"estimated_review_effort": 2,
"problem_domain": "Code Refactoring / Architectural Improvement"
} | |
pydantic__pydantic-8437@555026f | pydantic/pydantic | Python | 8,437 | Introducing classproperty decorator for model_computed_fields | ## Change Summary
A `classproperty` decorator has been added in order to access `model_computed_fields` as a class attribute and an instance property.
## Related issue number
fix #7986
## Checklist
* [x] The pull request title is a good summary of the changes - it will be used in the changelog
* [x] Unit ... | 2023-12-24T23:00:12Z | should 'model_computed_fields' be a class attribute not an instance property?
### Initial Checks
- [X] I confirm that I'm using Pydantic V2
### Description
Hopefully title is quite self explanatory, but here is a bit of extra detail....
if I have a Model subclass "Schema", then I expected to be able to get ... | @hottwaj,
Thanks for reporting this! This seems like a reasonable change to make - I agree with your logic. Would you like to open a PR to make this change?
Great thanks! I'm keen to submit a PR, but it might take a little time. Will try to get to it soon :)
@sydney-runkle
I could pick this up!
@geospackle Hi... | [
{
"body": "### Initial Checks\r\n\r\n- [X] I confirm that I'm using Pydantic V2\r\n\r\n### Description\r\n\r\nHopefully title is quite self explanatory, but here is a bit of extra detail....\r\n\r\nif I have a Model subclass \"Schema\", then I expected to be able to get to computed_fields via \"model_computed_f... | 19fa86cbfcc7b64c5d59c04c38fa80b497f275a2 | {
"head_commit": "555026fd65d27de6354ae1c12cb92ef99f641ca4",
"head_commit_message": "feat: introduce classproperty decorator for model_computed_fields",
"patch_to_review": "diff --git a/pydantic/main.py b/pydantic/main.py\nindex 59afce4e7c0..eff94bce974 100644\n--- a/pydantic/main.py\n+++ b/pydantic/main.py\n@@ -... | [
{
"diff_hunk": "@@ -58,6 +58,14 @@\n _object_setattr = _model_construction.object_setattr\n \n \n+class classproperty:\n+ def __init__(self, function) -> None:\n+ self.fget = function\n+\n+ def __get__(self, instance, owner) -> Any:\n+ return self.fget(owner)",
"line": null,
"origina... | b36fca86e8b768d128ba0b0e2ce9d504286f4ec1 | diff --git a/pydantic/_internal/_model_construction.py b/pydantic/_internal/_model_construction.py
index e90636f6f37..49da37c449a 100644
--- a/pydantic/_internal/_model_construction.py
+++ b/pydantic/_internal/_model_construction.py
@@ -188,6 +188,11 @@ def wrapped_model_post_init(self: BaseModel, __context: Any) -> No... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Code Refactoring / Architectural Improvement"
} |
pytest-dev__pytest-7332@2cc448a | pytest-dev/pytest | Python | 7,332 | Introduce guidelines for closing stale issues/PRs | Close #7282
(cc @gnikonorov which also participated in the discussion) | 2020-06-07T13:20:22Z | Proposal on how to deal with stale PRs
Hi everyone,
Currently we have a bunch of PRs open (50+), and I notice many of them are "stale", meaning that we have asked for changes and the authors didn't got around to implement them yet after a somewhat long time.
There are many reasons why people don't implement chang... | I like the idea, it would be nice to have a bot that manages staleness, pings and closes
There's https://github.com/probot/stale, which has all configurations we need: customize number of days for ping, closing, and limiting only to PRs.
Any chance this can be added to issues too? I see that it has support for issues,... | [
{
"body": "Hi everyone,\r\n\r\nCurrently we have a bunch of PRs open (50+), and I notice many of them are \"stale\", meaning that we have asked for changes and the authors didn't got around to implement them yet after a somewhat long time.\r\n\r\nThere are many reasons why people don't implement changes: they m... | ceac6736d772c68ebfbde21dcabcd179068f8498 | {
"head_commit": "2cc448ae4762642f2deb4780fa17970a2344b566",
"head_commit_message": "Introduce guidelines for closing stale issues/PRs\n\nClose #7282",
"patch_to_review": "diff --git a/.coveragerc b/.coveragerc\ndeleted file mode 100644\nindex b06629a8a8f..00000000000\n--- a/.coveragerc\n+++ /dev/null\n@@ -1,29 +... | [
{
"diff_hunk": "@@ -359,15 +372,49 @@ actual latest release). The procedure for this is:\n * Delete the PR body, it usually contains a duplicate commit message.\n \n \n-Joining the Development Team\n-----------------------------\n+Handling stale issues/PRs\n+-------------------------\n \n-Anyone who has succ... | 9ebea55f18c0d7abbcc8b7082d56f30125842516 | diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst
index 3d07db63804..d5bd7814417 100644
--- a/CONTRIBUTING.rst
+++ b/CONTRIBUTING.rst
@@ -289,7 +289,7 @@ Here is a simple overview, with pytest-specific bits:
Writing Tests
-----------------------------
+~~~~~~~~~~~~~
Writing tests for plugins or for pytest itself... | {
"difficulty": "low",
"estimated_review_effort": 2,
"problem_domain": "Test Suite / CI Enhancements"
} |
pydantic__pydantic-8511@bba4863 | pydantic/pydantic | Python | 8,511 | fix: Support `pydantic.Field(repr=False)` in dataclasses | ## Change Summary
Fix for https://github.com/pydantic/pydantic/issues/7078
Changes:
- Modified `make_pydantic_fields_compatible` to address `repr`
- Added test for added `repr` support
- Small addition to `tests/test_dataclasses.py:test_default_factory_field` just to be sure nothing broke
First PR here, apo... | 2024-01-07T23:45:41Z | `pydantic.dataclasses.Field` still gives `repr` output even if turned off
### Initial Checks
- [X] I confirm that I'm using Pydantic V2
### Description
I would like to use `pydantic.dataclasses.Field` rather than `dataclasses.field` but the results of `repr=False` are different, which I believe is unexpected
### Ex... | This does look like a bug.
Thanks for reporting it @paddyroddy :)
Would you be interested in open a PR?
I don't really have time at the moment. Maybe in the future
> This does look like a bug.
>
> Thanks for reporting it @paddyroddy :)
>
> Would you be interested in open a PR?
```python
@dataclass_trans... | [
{
"body": "### Initial Checks\n\n- [X] I confirm that I'm using Pydantic V2\n\n### Description\n\nI would like to use `pydantic.dataclasses.Field` rather than `dataclasses.field` but the results of `repr=False` are different, which I believe is unexpected\n\n### Example Code\n\n```Python\nimport dataclasses\r\n... | e4fa099d5adde70acc80238ff810c87a5cec7ebf | {
"head_commit": "bba486364ace1360b271205c8f74a0764a443d0b",
"head_commit_message": "fix: Support `pydantic.Field(repr=False)` in dataclasses\n\nWhy\n\nWhat\n- Modified `make_pydantic_fields_compatible` to address `repr`\n- Added test for `repr` support\n\nNotes",
"patch_to_review": "diff --git a/pydantic/datacla... | [
{
"diff_hunk": "@@ -522,16 +522,27 @@ class User:\n id: int\n other: Dict[str, str] = dataclasses.field(default_factory=lambda: {'John': 'Joey'})\n \n- user = User(id=123)\n- assert user.id == 123\n- # assert user.other == {'John': 'Joey'}\n- fields = user.__pydantic_fields__\n+ @... | 5cdd7a39a5105b3b58473773685a57e275120e29 | diff --git a/pydantic/dataclasses.py b/pydantic/dataclasses.py
index acdf4d6380d..bb26540cce7 100644
--- a/pydantic/dataclasses.py
+++ b/pydantic/dataclasses.py
@@ -143,28 +143,36 @@ def dataclass(
if sys.version_info >= (3, 10):
kwargs = dict(kw_only=kw_only, slots=slots)
-
- def make_pydantic_f... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} |
onnx__onnx-2031@ffcd5f1 | onnx/onnx | Python | 2,031 | Support dynamic 'pads' and 'value' in Pad operator | Change description:
This change is to make two static attributes of the Pad op - 'pads' and 'value' into dynamic inputs to support conversion of some TensorFlow models into ONNX which allow these 2 values to be fed in dynamically to the op. This change is to basically support conversion of such TF models into ONNX.
... | 2019-05-18T02:26:23Z | Meaning of edge and reflect in Pad operator?
The meaning of edge and reflect are not described in the documentation for the Pad operator. There is an example, but please tell us the intended meaning in English if you would.
Thanks
Allow creation of older opset ops/nodes
It will be great if the onnx helper's `make_... | let's keep this issue open to track the pad op spec clarification. | [
{
"body": "The meaning of edge and reflect are not described in the documentation for the Pad operator. There is an example, but please tell us the intended meaning in English if you would.\r\n\r\nThanks",
"number": 1765,
"title": "Meaning of edge and reflect in Pad operator?"
},
{
"body": "It w... | 1316afc9f972f81340faa05763e2898f38bcc3b0 | {
"head_commit": "ffcd5f1d37add325908efe91e74c66882765015f",
"head_commit_message": "Update Changelog.md",
"patch_to_review": "diff --git a/docs/Changelog.md b/docs/Changelog.md\nindex 14e7621e7b9..e2d04e4430b 100644\n--- a/docs/Changelog.md\n+++ b/docs/Changelog.md\n@@ -11461,6 +11461,81 @@ This version of the o... | [
{
"diff_hunk": "@@ -10026,19 +10046,19 @@ expect(node, inputs=[x], outputs=[y],\n for mode in ['edge', 'reflect']:\n node = onnx.helper.make_node(\n 'Pad',\n- inputs=['x'],\n+ inputs=['x', 'pads'],\n outputs=['y'],\n- mode=mode,\n- pads=[0, 0, 1, 1, 0, 0, 1, 1]\n+... | 8c006535bbde0d0c99d8b67e1f20dec9ba01c65d | diff --git a/docs/Changelog.md b/docs/Changelog.md
index db0afbf9696..1c639ed5521 100644
--- a/docs/Changelog.md
+++ b/docs/Changelog.md
@@ -2723,17 +2723,14 @@ This version of the operator has been available since version 1 of the default O
### <a name="Pad-1"></a>**Pad-1**</a>
Given `data` tensor, paddings, mod... | {
"difficulty": "medium",
"estimated_review_effort": 4,
"problem_domain": "Documentation Updates"
} |
pyro-ppl__pyro-258@f1c1ac6 | pyro-ppl/pyro | Python | 258 | Support custom batching in iarange/irange | Closes #169
This aims to implement custom batching strategies in a `poutine.replay`-compatible way, as discussed in #239 .
It currently does not work, since observations override replaying. @eb8680 any ideas how to fix? | 2017-10-13T05:15:10Z | more control over subsampling in map_data
currently, mini-batch indices for map_data subsampling are chosen by pyro. they are also chosen in a stateless way with the consequence that there is non-zero probability that certain data points will never be seen even no matter how many epochs you do. this is bad, especially ... | If the user wants to directly specify batch_indices, they can just not use `map_data` and write what they want directly. Maybe we can add an option to the default `Poutine` to sample without replacement in `map_data`, though.
We could also expose the randomness in `map_data` as a Pyro variable, to enable fancy acti... | [
{
"body": "currently, mini-batch indices for map_data subsampling are chosen by pyro. they are also chosen in a stateless way with the consequence that there is non-zero probability that certain data points will never be seen even no matter how many epochs you do. this is bad, especially for large data sets. th... | 1b0afa8aaf2fab350a9c135c5787f22b6eabe0c0 | {
"head_commit": "f1c1ac656500a84fed0b1ab90208cf91813819d1",
"head_commit_message": "Attempt to implement custom iarange/irange subsampling",
"patch_to_review": "diff --git a/pyro/__init__.py b/pyro/__init__.py\nindex 293e1617ba..92c0b16b75 100644\n--- a/pyro/__init__.py\n+++ b/pyro/__init__.py\n@@ -117,7 +117,7 ... | [
{
"diff_hunk": "@@ -160,27 +160,65 @@ def model(means, stds):\n assert tr.nodes[name][\"scale\"] == 4.0 * 2.0\n \n \n-def test_replay_iarange():\n- pyro.set_rng_seed(0)\n+def iarange_model():\n+ with pyro.iarange('iarange', 20, 5) as batch:\n+ result = list(batch.data)\n+ return resu... | ce81d1c2d10375e8170ba7392d20f1f717f3b02f | diff --git a/pyro/__init__.py b/pyro/__init__.py
index 4943873128..1ea19f7235 100644
--- a/pyro/__init__.py
+++ b/pyro/__init__.py
@@ -146,7 +146,7 @@ def batch_log_pdf(self, x):
@contextlib.contextmanager
-def iarange(name, size, subsample_size=0):
+def iarange(name, size, subsample_size=0, subsample=None):
... | {
"difficulty": "medium",
"estimated_review_effort": 4,
"problem_domain": "New Feature Additions"
} |
onnx__onnx-1519@666d8b7 | onnx/onnx | Python | 1,519 | add eliminate nop monotone argmax pass | fixes #1429 | 2018-10-17T22:53:19Z | Optimization Pass: Monotonic growing function is useless before argmax calculation.
It's standard to use softmax to generate a probability distribution at the end of a model. If we want to get the predicted class we end up with `net(x).softmax(dim=1).argmax(dim=1)`.
In reality though because softmax is a monotonic ... | [
{
"body": "It's standard to use softmax to generate a probability distribution at the end of a model. If we want to get the predicted class we end up with `net(x).softmax(dim=1).argmax(dim=1)`. \r\n\r\nIn reality though because softmax is a monotonic growing operation we can replace the expression with `net(x).... | 7b7b6ec4fdf21039c1e77814d1a1cb7c2d658e9a | {
"head_commit": "666d8b76e325269c67f7f4c8715724625919199e",
"head_commit_message": "Merge branch 'master' into argmax_monotone",
"patch_to_review": "diff --git a/onnx/common/interned_strings.h b/onnx/common/interned_strings.h\nindex 542a02e204b..ce6ed29ea82 100644\n--- a/onnx/common/interned_strings.h\n+++ b/onn... | [
{
"diff_hunk": "@@ -0,0 +1,56 @@\n+// ATTENTION: The code in this file is highly EXPERIMENTAL.\n+// Adventurous users should note that the APIs will probably change.\n+#pragma once\n+\n+#include \"onnx/optimizer/pass.h\"\n+\n+namespace ONNX_NAMESPACE {\n+namespace optimization {\n+\n+const std::unordered_set<No... | 16149b9d692be4ef14bc13149f6d5ab0e026e31d | diff --git a/onnx/common/interned_strings.h b/onnx/common/interned_strings.h
index 542a02e204b..a811392f6ba 100644
--- a/onnx/common/interned_strings.h
+++ b/onnx/common/interned_strings.h
@@ -2,170 +2,167 @@
// Adventurous users should note that the APIs will probably change.
#pragma once
-#include <vector>
#incl... | {
"difficulty": "medium",
"estimated_review_effort": 4,
"problem_domain": "Performance Optimizations"
} | |
pytest-dev__pytest-7266@2b640ff | pytest-dev/pytest | Python | 7,266 | adding towncrier wrapper script so 'tox -e docs' works natively on windows | The problem (natively on a windows system):
Before:
```
C:\workspace\pytest>tox -e docs
c:\python37\lib\site-packages\packaging\requirements.py:57: UserWarning: warn_ungrouped_named_tokens_in_collection: setting results name 'specifier' on And expression collides with '_original_end' on contained expression
... | 2020-05-26T15:37:35Z | tox -e docs not supported out of the box on windows platform
When building docs, we use 'sh' which fails from the pycharm terminal on windows for example. Will investigate if tox can have a platform agnostic command for towncrier that will work for everybody.
```
[testenv:docs]
basepython = python3
usedevelop = ... | @nicoddemus how does someone get the ability to assign 'labels' on issue(s) on the project here at pytest?
@symonk we would either need a wrapper script around towncrier, or a towncrier feature addition to write the draft to a file
on my radar for this week | [
{
"body": "When building docs, we use 'sh' which fails from the pycharm terminal on windows for example. Will investigate if tox can have a platform agnostic command for towncrier that will work for everybody.\r\n\r\n```\r\n[testenv:docs]\r\nbasepython = python3\r\nusedevelop = True\r\ndeps =\r\n -r{toxinid... | 54ae27f081b9d7d164d880d9cbce842cc477772a | {
"head_commit": "2b640ff6bee8c3c39e35e1941e7480dae1401848",
"head_commit_message": "enable tox -e docs natively on windows using a wrapper",
"patch_to_review": "diff --git a/scripts/platform_agnostic_towncrier.py b/scripts/platform_agnostic_towncrier.py\nnew file mode 100644\nindex 00000000000..186d2c4f224\n--- ... | [
{
"diff_hunk": "@@ -0,0 +1,13 @@\n+from subprocess import check_call\n+\n+\n+def main():\n+ \"\"\"\n+ Platform agnostic towncrier to support tox -e docs on a windows based platform natively.\n+ Previously we used 'sh -c' which will not work on pycharm terminal in windows for example.\n+ \"\"\"\n+ ... | 11b7a3bf33f9529ea2bb1c97cff7bf550f847d46 | diff --git a/scripts/towncrier-draft-to-file.py b/scripts/towncrier-draft-to-file.py
new file mode 100644
index 00000000000..81507b40b75
--- /dev/null
+++ b/scripts/towncrier-draft-to-file.py
@@ -0,0 +1,15 @@
+import sys
+from subprocess import call
+
+
+def main():
+ """
+ Platform agnostic wrapper script for to... | {
"difficulty": "low",
"estimated_review_effort": 2,
"problem_domain": "Dependency Updates & Env Compatibility"
} |
pytest-dev__pytest-7257@5ebcb34 | pytest-dev/pytest | Python | 7,257 | Prevent pytest from printing ConftestImportFailure traceback | Closes: #6956
@asottile I was not able to satisfy mypy so I added `# type: ignore` to the two lines. Let me know what you think :)
- [X] Include new tests or update existing tests when applicable.
- [X] Allow maintainers to push and squash when merging my commits. Please uncheck this if you prefer to squash the... | 2020-05-25T11:59:50Z | ConftestImportFailure: internal traceback when non-root conftest raises error
an internal traceback is exposed when a nested conftest raises an error (doesn't happen for top level conftest failure)
- [x] a detailed description of the bug or suggestion
- [x] output of `pip list` from the virtual environment you are ... | I might be misunderstanding, but it looks like you're trying to import the package that the conftest is inside of into the conftest, which would be circular.
it has this behaviour for any exception, the concidence in import name was perhaps not the best choice when I wrote up this bug report (I was being too hasty!)
I ... | [
{
"body": "an internal traceback is exposed when a nested conftest raises an error (doesn't happen for top level conftest failure)\r\n\r\n- [x] a detailed description of the bug or suggestion\r\n- [x] output of `pip list` from the virtual environment you are using\r\n- [x] pytest and operating system versions\r... | 981b0969404bc4116659dae8fa6318cfbab2c942 | {
"head_commit": "5ebcb34fb595c7652ccda889f69b2d4e3ca6443b",
"head_commit_message": "Move ConftestImportFailure check to correct position and add typing",
"patch_to_review": "diff --git a/changelog/6956.bugfix.rst b/changelog/6956.bugfix.rst\nnew file mode 100644\nindex 00000000000..a88ef94b6d5\n--- /dev/null\n++... | [
{
"diff_hunk": "@@ -331,13 +332,19 @@ def _prunetraceback(self, excinfo):\n pass\n \n def _repr_failure_py(\n- self, excinfo: ExceptionInfo[Union[Failed, FixtureLookupError]], style=None\n+ self,\n+ excinfo: ExceptionInfo[\n+ Union[Failed, FixtureLookupError, Conftest... | 5b9924e1444ee662a58d50fb22eaff23c38d6c03 | diff --git a/changelog/6956.bugfix.rst b/changelog/6956.bugfix.rst
new file mode 100644
index 00000000000..a88ef94b6d5
--- /dev/null
+++ b/changelog/6956.bugfix.rst
@@ -0,0 +1 @@
+Prevent pytest from printing ConftestImportFailure traceback to stdout.
diff --git a/src/_pytest/nodes.py b/src/_pytest/nodes.py
index 2f5f9... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} |
pydantic__pydantic-8171@8370461 | pydantic/pydantic | Python | 8,171 | updating docs with more SkipJsonSchema info | ## Change Summary
Update docs info, specifically re json schema tools.
## Related issue number
Closes #8160
## Checklist
* [x] The pull request title is a good summary of the changes - it will be used in the changelog
* [ ] Unit tests for the changes exist
* [x] Tests pass on CI
* [x] Documentation re... | 2023-11-19T18:47:18Z | More things to document
I've been doing some in depth stuff with pydantic and discovered we don't have great documentation for:
* `WithJsonSchema` - needs to be talked about on the JSON Schema page, with an example, link to docs
* `__get_pydantic_json_schema__` - on same page, needs an example | Will do today. Also going to add better docs / examples for `SkipJsonSchema`
Unless I'm mistaken, I haven't found any reference to `computed_field` in concepts (apart from a note in [Serialization](https://docs.pydantic.dev/latest/concepts/serialization/)). It might be beneficial to have a dedicated section? What do yo... | [
{
"body": "I've been doing some in depth stuff with pydantic and discovered we don't have great documentation for:\r\n* `WithJsonSchema` - needs to be talked about on the JSON Schema page, with an example, link to docs\r\n* `__get_pydantic_json_schema__` - on same page, needs an example",
"number": 8160,
... | 24272b4f856829dc10660d3f9e1f4607246afa84 | {
"head_commit": "8370461f9091222b9cbbacfb9c7d5b81053595ad",
"head_commit_message": "Wording fix\n\nCo-authored-by: psychedelicious <4822129+psychedelicious@users.noreply.github.com>",
"patch_to_review": "diff --git a/docs/concepts/fields.md b/docs/concepts/fields.md\nindex 448902640b2..56a74c22e36 100644\n--- a/... | [
{
"diff_hunk": "@@ -1,22 +1,44 @@\n ??? api \"API Documentation\"\n [`pydantic.json_schema`][pydantic.json_schema]<br>\n \n-Pydantic allows automatic creation of JSON schemas from models.\n-\n-Using Pydantic, there are several ways to generate JSON schemas or JSON representations from fields or models:\n-\n... | 003a53066f035923d326bb64aa3bd2534d5e34b0 | diff --git a/docs/concepts/fields.md b/docs/concepts/fields.md
index 448902640b2..8195f77d253 100644
--- a/docs/concepts/fields.md
+++ b/docs/concepts/fields.md
@@ -1,7 +1,7 @@
??? api "API Documentation"
[`pydantic.fields.Field`][pydantic.fields.Field]<br>
-The `Field` function is used to customize and add met... | {
"difficulty": "low",
"estimated_review_effort": 2,
"problem_domain": "Documentation Updates"
} |
pydantic__pydantic-8209@40a41fb | pydantic/pydantic | Python | 8,209 | Add eval_type_backport to handle union operator and builtin generic subscripting in older Pythons | Closes https://github.com/pydantic/pydantic/issues/7873
(previously #7958)
Replaces all calls (outside v1) to `typing._eval_type` with the new `typing_extra.eval_type_backport` which falls back to https://github.com/alexmojaki/eval_type_backport if installed. | 2023-11-22T19:12:16Z | future annotations with Python 3.8 cause TypeError
### Initial Checks
- [X] I confirm that I'm using Pydantic V2
### Description
Using `__future__ import annotations` with Python3.8 and Pydantic 2.4.2 cause:
```
TypeError: unsupported operand type(s) for |: 'type' and 'type'
```
### Example Code
```Python
f... | Hi @emcek,
Thanks for reporting this! I was able to replicate this issue. Indeed seems like a bug 🐛. We will look into a fix!
I can confirm I have the same bug when using Python 3.9.
**Python, Pydantic & OS Version**
```
pydantic version: 2.4.2
pydantic-core version: 2.10.1
pydantic-core build: profile=rel... | [
{
"body": "### Initial Checks\n\n- [X] I confirm that I'm using Pydantic V2\n\n### Description\n\nUsing `__future__ import annotations` with Python3.8 and Pydantic 2.4.2 cause:\r\n\r\n```\r\nTypeError: unsupported operand type(s) for |: 'type' and 'type'\r\n```\r\n\n\n### Example Code\n\n```Python\nfrom __futur... | 5de67f7c4f775b5319af9be157f9c7b68995eb1e | {
"head_commit": "40a41fb745c854ee35d1f651e007553403cdb13b",
"head_commit_message": "Add test dependency",
"patch_to_review": "diff --git a/pdm.lock b/pdm.lock\nindex d37751aac08..a09de9af52f 100644\n--- a/pdm.lock\n+++ b/pdm.lock\n@@ -5,7 +5,7 @@\n groups = [\"default\", \"docs\", \"email\", \"linting\", \"memra... | [
{
"diff_hunk": "@@ -221,12 +221,36 @@ def eval_type_lenient(value: Any, globalns: dict[str, Any] | None, localns: dict\n value = _make_forward_ref(value, is_argument=False, is_class=True)\n \n try:\n- return typing._eval_type(value, globalns, localns) # type: ignore\n+ return eval_typ... | 60aa70fdfaaa6edf3b6bba94148f60bbcf980cc0 | diff --git a/pdm.lock b/pdm.lock
index bc9a759a736..a2d763ef954 100644
--- a/pdm.lock
+++ b/pdm.lock
@@ -3,10 +3,9 @@
[metadata]
groups = ["default", "docs", "email", "linting", "memray", "mypy", "testing", "testing-extra"]
-cross_platform = true
-static_urls = false
-lock_version = "4.3"
-content_hash = "sha256:53... | {
"difficulty": "medium",
"estimated_review_effort": 4,
"problem_domain": "Bug Fixes"
} |
pytest-dev__pytest-7100@33df230 | pytest-dev/pytest | Python | 7,100 | Issue 1316 - longrepr is a string when pytrace=False | This pull request fixes #1316. I've added new `_TracebackStyle` - `no_pytrace`. For that style `ReprExceptionInfo` has as few information as possible. For example `report.longrepr.chain` is
```
[(ReprTraceback(reprentries=[ReprEntry(lines=['Hello World'], reprfuncargs=None, reprlocals=None, reprfileloc=None, style='n... | 2020-04-19T17:36:53Z | TestReport.longrepr is a string when pytest.fail(..., pytrace=False) is used
I'd expect the `assert` in my `conftest.py` to pass, but it doesn't:
``` python
# test_foo.py
import pytest
def test_foo(foo):
pytest.fail("Hello World", pytrace=False)
```
``` python
# conftest.py
import pytest
@pytest.hookimpl(hookw... | I've also faced this situation in some other occasion... it would be nice to have `longrepr` always be an `ReprExceptionInfo` instance. Hopefully this will be easier to fix once we merge `py,code` in.
imho longrepr is a bit problematic, i hope we can get reporting work different in the long term | [
{
"body": "I'd expect the `assert` in my `conftest.py` to pass, but it doesn't:\n\n``` python\n# test_foo.py\n\nimport pytest\n\ndef test_foo(foo):\n pytest.fail(\"Hello World\", pytrace=False)\n```\n\n``` python\n# conftest.py\nimport pytest\n\n@pytest.hookimpl(hookwrapper=True)\ndef pytest_runtest_makerepo... | 6c2d35891879408ccd1ca0d05355d3baa046f9da | {
"head_commit": "33df23078ed3e34b881052d3f292c37bcfaae3c8",
"head_commit_message": "Minor adjustment to CHANGELOG",
"patch_to_review": "diff --git a/changelog/1316.breaking.rst b/changelog/1316.breaking.rst\nnew file mode 100644\nindex 00000000000..4c01de728e8\n--- /dev/null\n+++ b/changelog/1316.breaking.rst\n@... | [
{
"diff_hunk": "@@ -202,10 +202,11 @@ def append_failure(self, report):\n if hasattr(report, \"wasxfail\"):\n self._add_simple(Junit.skipped, \"xfail-marked test passes unexpectedly\")\n else:\n- if hasattr(report.longrepr, \"reprcrash\"):\n+ if (\n+ ... | 2c18e252e629afc50b3f0f938d728c60589bcc7b | diff --git a/changelog/1316.breaking.rst b/changelog/1316.breaking.rst
new file mode 100644
index 00000000000..4c01de728e8
--- /dev/null
+++ b/changelog/1316.breaking.rst
@@ -0,0 +1 @@
+``TestReport.longrepr`` is now always an instance of ``ReprExceptionInfo``. Previously it was a ``str`` when a test failed with ``pyte... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} |
pydantic__pydantic-8059@11d8191 | pydantic/pydantic | Python | 8,059 | Add `TypeAdapter` section to `concepts` page of docs | ## Change Summary
Moving more conceptual overview of `TypeAdapter` to `concepts` section of the docs
## Related issue number
Fix #8051
## Checklist
* [x] The pull request title is a good summary of the changes - it will be used in the changelog
* [ ] Unit tests for the changes exist
* [x] Tests pass on... | 2023-11-08T19:44:51Z | Add `TypeAdapter` section to concepts docs
There used to be a `TypeAdapter` section in the `Usage` docs, but we moved all of that content to the `API Documentation` section.
Let's add a section to the `Concepts` docs explaining how to use a `TypeAdapter`. | [
{
"body": "There used to be a `TypeAdapter` section in the `Usage` docs, but we moved all of that content to the `API Documentation` section.\r\n\r\nLet's add a section to the `Concepts` docs explaining how to use a `TypeAdapter`.",
"number": 8051,
"title": "Add `TypeAdapter` section to concepts docs"
... | ecc18bd1bbfab19c5171129c53cbc75e97e478bb | {
"head_commit": "11d8191eac6fc3f5bace177d23efc27b30a8e0a7",
"head_commit_message": "moving more conceptual content to concepts page",
"patch_to_review": "diff --git a/docs/api/type_adapter.md b/docs/api/type_adapter.md\nindex 7a569758532..95c582d5a0f 100644\n--- a/docs/api/type_adapter.md\n+++ b/docs/api/type_ad... | [
{
"diff_hunk": "@@ -0,0 +1,77 @@\n+You may have types that are not `BaseModel`s that you want to validate data against.\n+Or you may want to validate a `List[SomeModel]`, or dump it to JSON.\n+\n+??? api \"API Documentation\"\n+ [`pydantic.type_adapter.TypeAdapter`][pydantic.type_adapter.TypeAdapter]<br>\n+\... | 21deb8c66311f2b5b205a269b973122ef643e13c | diff --git a/docs/api/type_adapter.md b/docs/api/type_adapter.md
index 7a569758532..95c582d5a0f 100644
--- a/docs/api/type_adapter.md
+++ b/docs/api/type_adapter.md
@@ -1 +1 @@
-::: pydantic.type_adapter
+::: pydantic.type_adapter.TypeAdapter
diff --git a/docs/concepts/type_adapter.md b/docs/concepts/type_adapter.md
ne... | {
"difficulty": "low",
"estimated_review_effort": 2,
"problem_domain": "Documentation Updates"
} | |
pytest-dev__pytest-7083@3d16811 | pytest-dev/pytest | Python | 7,083 | Improve error handling around yieldctx fixtures which do not yield a value | Fixes #7061.
Good afternoon, thanks for your time. I am opening this PR as a 'work in progress'. I have implemented some behaviour that checks a yielding fixture actually yields a value with a test to cover it.
What I am not so sure on is what to do exactly when that occurs; right now I am raising a ValueError,... | 2020-04-13T16:48:47Z | fixtures with yield statement in if-else clause crash pytest
If I have a fixture with a yield statement within an else clause and the else clause is False, pytest will crash
Here is a simple example (note one of the parametrize lines is purposely commented out as you can use it to toggle back and forth. Only when... | Can you show the output you get?
Here is the ouput. I removed the conftest.py file so nothing else should be running....
```
(p1_netmiko_exper) as2863@ubuntuP1-SYSlog-S1:~/pythonProjects/p1-automation$ pytest lag/test_yield.py -s
===================================================================================... | [
{
"body": "\r\nIf I have a fixture with a yield statement within an else clause and the else clause is False, pytest will crash\r\n\r\nHere is a simple example (note one of the parametrize lines is purposely commented out as you can use it to toggle back and forth. Only when \"filename\" is None does it crash.... | c08cff3770cfcb6328f500b09ac1447c1353eb93 | {
"head_commit": "3d1681179d269549f1a511e5b1d94904b402baf3",
"head_commit_message": "initial work for yielding fixtures failing to yield a value",
"patch_to_review": "diff --git a/changelog/7061.improvement.rst b/changelog/7061.improvement.rst\nnew file mode 100644\nindex 00000000000..7c12d408340\n--- /dev/null\n... | [
{
"diff_hunk": "@@ -0,0 +1 @@\n+Raise a ValueError when a yielding fixture fails to yield a single value",
"line": null,
"original_line": 1,
"original_start_line": null,
"path": "changelog/7061.improvement.rst",
"start_line": null,
"text": "@user1:\n```suggestion\r\nWhen a yielding fixtu... | 8733cf248e9ff633e3f26774dbd317c68137b306 | diff --git a/changelog/7061.bugfix.rst b/changelog/7061.bugfix.rst
new file mode 100644
index 00000000000..7e6d36c2fb1
--- /dev/null
+++ b/changelog/7061.bugfix.rst
@@ -0,0 +1 @@
+When a yielding fixture fails to yield a value, report a test setup error instead of crashing.
diff --git a/src/_pytest/fixtures.py b/src/_p... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} |
pydantic__pydantic-7925@0556048 | pydantic/pydantic | Python | 7,925 | Added fix for signature of inherited dataclass | <!-- Thank you for your contribution! -->
<!-- Unless your change is trivial, please create an issue to discuss the change before creating a PR -->
## Change Summary
Added fix for signature of inherited dataclass when using the pydantic dataclass decorator.
There is a bug in the following code
```python
f... | 2023-10-25T17:31:06Z | Signature of inherited dataclass does not include subclass field
### Initial Checks
- [X] I confirm that I'm using Pydantic V2
### Description
Hello, I found that the signature of inherited dataclass seems to have only its superclass fields. Is this expected behavior at pydantic v2? Due to this, FastAPI seems to i... | Hi @shinaji,
Thanks for reporting this. Looks like a bug with the pydantic dataclass signature generation. I've marked this with the `good first issue` tag, if anyone wants to help!
This should be helpful:
https://github.com/pydantic/pydantic/blob/f645f196b063843865b34bd696e4b85bae9c034c/pydantic/_internal/_datac... | [
{
"body": "### Initial Checks\n\n- [X] I confirm that I'm using Pydantic V2\n\n### Description\n\nHello, I found that the signature of inherited dataclass seems to have only its superclass fields. Is this expected behavior at pydantic v2? Due to this, FastAPI seems to ignore the subclass field value.\n\n### E... | 0a2d1dfbaf9f17c0e654ab612986faec50cf3550 | {
"head_commit": "055604812e3d2696c3ec4e7ad83c197062c311ac",
"head_commit_message": "Added fix for dataclass inheritance signature bug.",
"patch_to_review": "diff --git a/pydantic/_internal/_dataclasses.py b/pydantic/_internal/_dataclasses.py\nindex d1d1c5fa0c9..a0dab4d4c2e 100644\n--- a/pydantic/_internal/_datac... | [
{
"diff_hunk": "@@ -123,19 +124,25 @@ def complete_dataclass(\n typevars_map,\n )\n \n- # dataclass.__init__ must be defined here so its `__qualname__` can be changed since functions can't be copied.\n+ # Get a temporary signature before we change the __init__\n+ fields = cls.__pydantic_fie... | 4d0330907f8a2f4b847891d71fdb548e6e321b94 | diff --git a/pydantic/_internal/_dataclasses.py b/pydantic/_internal/_dataclasses.py
index d1d1c5fa0c9..17240571e58 100644
--- a/pydantic/_internal/_dataclasses.py
+++ b/pydantic/_internal/_dataclasses.py
@@ -6,7 +6,7 @@
import typing
import warnings
from functools import partial, wraps
-from inspect import Paramete... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} |
pydantic__pydantic-7898@0398cda | pydantic/pydantic | Python | 7,898 | Fix pydantic dataclass problem with dataclasses.field default | Fixes https://github.com/pydantic/pydantic/issues/7895
Selected Reviewer: @dmontagu | 2023-10-23T10:53:42Z | Inconsistent `model_dump` behavior with dataclasses and `field(init=False)`
### Initial Checks
- [X] I confirm that I'm using Pydantic V2
### Description
Models will only dump correctly if a field with `init=False` uses `default_factory`.
### Example Code
```Python
import uuid
from pydantic import RootModel
from... | @PrettyWood could this be somehow related to #7821 ?
No nothing to do with that
It comes from https://github.com/pydantic/pydantic/blob/main/pydantic/_internal/_fields.py#L251
I reckon https://github.com/pydantic/pydantic/pull/6616 introduced a regression on that
because we now have
```py
@dataclass
class A:
... | [
{
"body": "### Initial Checks\n\n- [X] I confirm that I'm using Pydantic V2\n\n### Description\n\nModels will only dump correctly if a field with `init=False` uses `default_factory`.\n\n### Example Code\n\n```Python\nimport uuid\r\nfrom pydantic import RootModel\r\nfrom pydantic.dataclasses import dataclass\r\n... | 4dd40aec7397418e37b1029a0496b486adecbb7c | {
"head_commit": "0398cdaae65d7ff5d60ff239feac6b1820879837",
"head_commit_message": "Fix pydantic dataclass problem with dataclasses.field default",
"patch_to_review": "diff --git a/pydantic/_internal/_fields.py b/pydantic/_internal/_fields.py\nindex e42c7a47e9f..1c2b88f21d7 100644\n--- a/pydantic/_internal/_fiel... | [
{
"diff_hunk": "@@ -248,7 +248,11 @@ def collect_dataclass_fields(\n if is_classvar(ann_type):\n continue\n \n- if not dataclass_field.init and dataclass_field.default_factory == dataclasses.MISSING:\n+ if (\n+ not dataclass_field.init\n+ and dataclass_fie... | bc1f1c4cd61baa3bdfcec490baab7f4d8503c7ba | diff --git a/pydantic/_internal/_fields.py b/pydantic/_internal/_fields.py
index e42c7a47e9f..621bd0fdce4 100644
--- a/pydantic/_internal/_fields.py
+++ b/pydantic/_internal/_fields.py
@@ -248,7 +248,11 @@ def collect_dataclass_fields(
if is_classvar(ann_type):
continue
- if not dataclass... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} |
pydantic__pydantic-8004@ee91d87 | pydantic/pydantic | Python | 8,004 | `PrivateAttr` is passed from `Annotated` default position | ## Change Summary
See related issue for a minimal example.
- When creating private fields from typing.Annotated, the default method gets thrown out in the current implementation.
- This Pull-Requests adds functionality to check wether the Default in the `Anntotated[]` definition already is a `PrivateAttr` and uses it ... | 2023-11-03T11:03:39Z | Use `PrivateAttr` with `Annotated` will cause `AttributeError` when getting private attr.
### Initial Checks
- [X] I confirm that I'm using Pydantic V2
### Description
```
m._t1=datetime.datetime(2023, 10, 29, 16, 44, 56, 993092)
Traceback (most recent call last):
File "/home/elonzh/.cache/pypoetry/vi... | Hi @elonzh,
Thanks for reporting this. Looks like a bug around here:
https://github.com/pydantic/pydantic/blob/46f24cee67c4da80166344076679aeb61d2348cc/pydantic/_internal/_model_construction.py#L375-L384
Specifically, I think we want to pull information from the `ann_type` re `default`, `default_factory` etc.
... | [
{
"body": "### Initial Checks\r\n\r\n- [X] I confirm that I'm using Pydantic V2\r\n\r\n### Description\r\n\r\n\r\n\r\n```\r\nm._t1=datetime.datetime(2023, 10, 29, 16, 44, 56, 993092)\r\nTraceback (most recent call last):\r\n File \"/home/elonzh/.cache/pypoetry/virtualenvs/unob-hX3-r8Vo-py3.10/lib/python3.10/si... | 0a2377e6eba9127e5debe5fda96dfd64a5b2030f | {
"head_commit": "ee91d878675e05294e52a11a7dadaa216147d588",
"head_commit_message": "more specific checking for annotated type",
"patch_to_review": "diff --git a/pdm.lock b/pdm.lock\nindex 78a7b5bf4f5..1196b7e1769 100644\n--- a/pdm.lock\n+++ b/pdm.lock\n@@ -3,10 +3,9 @@\n \n [metadata]\n groups = [\"default\", \"... | [
{
"diff_hunk": "@@ -384,6 +405,9 @@ def inspect_namespace( # noqa C901\n and ann_type not in all_ignored_types\n and getattr(ann_type, '__module__', None) != 'functools'\n ):\n+ if isinstance(ann_type, typing._AnnotatedAlias) and isinstance(ann_type.__metadata__[0], M... | ff9c789d153a187070c7fdac8e526c384537307c | diff --git a/pydantic/_internal/_model_construction.py b/pydantic/_internal/_model_construction.py
index 8a43b1b4a84..18ce56282b4 100644
--- a/pydantic/_internal/_model_construction.py
+++ b/pydantic/_internal/_model_construction.py
@@ -9,6 +9,7 @@
from types import FunctionType
from typing import Any, Callable, Gene... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} |
pydantic__pydantic-7893@6c9abee | pydantic/pydantic | Python | 7,893 | Make generic TypeAliasType specifications produce different schema definitions | <!-- Thank you for your contribution! -->
<!-- Unless your change is trivial, please create an issue to discuss the change before creating a PR -->
## Change Summary
This PR fixes #7840: now different specifications of a generic TypeAliasType produce different definitions in pydantic schema which prevents "overw... | 2023-10-21T14:06:20Z | PEP 695 generic type alias does not work
### Initial Checks
- [X] I confirm that I'm using Pydantic V2
### Description
PEP 695 generic type alias does not seem to work. JSON schema also does not look right. Looks like the first type definition is somehow cached and re-used incorrectly. See MRE, python 3.12+. I also ... | HI @AlexanderPodorov,
Thanks for reporting this. As the docs state [here](https://docs.pydantic.dev/latest/concepts/types/#named-type-aliases), we do support generic type aliases. Indeed looks like a bug 🐛.
Thank you @sydney-runkle !
The docs are using `TypeAliasType` backport, not sure is there any difference to ... | [
{
"body": "### Initial Checks\n\n- [X] I confirm that I'm using Pydantic V2\n\n### Description\n\nPEP 695 generic type alias does not seem to work. JSON schema also does not look right. Looks like the first type definition is somehow cached and re-used incorrectly. See MRE, python 3.12+. I also tried v2.4.2, bu... | 064b24c1894da519b5700f05067224044cd07ec6 | {
"head_commit": "6c9abee29552fb9ea595282766e5bf27999bb112",
"head_commit_message": "Fix typecheck",
"patch_to_review": "diff --git a/pydantic/_internal/_core_utils.py b/pydantic/_internal/_core_utils.py\nindex ebf12ec0fa1..46a27062eef 100644\n--- a/pydantic/_internal/_core_utils.py\n+++ b/pydantic/_internal/_cor... | [
{
"diff_hunk": "@@ -86,8 +87,10 @@ def get_type_ref(type_: type[Any], args_override: tuple[type[Any], ...] | None =\n This `args_override` argument was added for the purpose of creating valid recursive references\n when creating generic models without needing to create a concrete class.\n \"\"\"\n- ... | 03addf55609cbe2c4b4948b064537dbacfa687c1 | diff --git a/pydantic/_internal/_core_utils.py b/pydantic/_internal/_core_utils.py
index ebf12ec0fa1..501e5bbc442 100644
--- a/pydantic/_internal/_core_utils.py
+++ b/pydantic/_internal/_core_utils.py
@@ -8,15 +8,15 @@
Hashable,
TypeVar,
Union,
- _GenericAlias, # type: ignore
cast,
)
from py... | {
"difficulty": "medium",
"estimated_review_effort": 4,
"problem_domain": "Bug Fixes"
} |
pytest-dev__pytest-6009@e05b33e | pytest-dev/pytest | Python | 6,009 | setuponly: remove printing out/err from capman | resolve #5906
Thanks for @blueyed @asottile for the great help.
Really appreciate it.
| 2019-10-19T19:36:14Z | Crash when using --setup-show and KeyboardInterrupt
When interrupting a test using Ctrl-C (KeyboardInterrupt/SIGINT), the "setuponly" plugin crashes due to some interaction with the capture manager.
Using pytest 5.2.0 (fresh install on Python 3.7 in a virtual env), given a dummy test:
```
import time
import pytes... | Can I implement a quick fix by checking for None in read_global_capture? Or should I figure out the reason it's None in the first place?
Better to figure out the reason.
Tried to understand the reason `global_capturing` is None.
`stop_global_capturing` called twice:
1. because this callback for KeyboardIntterupt http... | [
{
"body": "When interrupting a test using Ctrl-C (KeyboardInterrupt/SIGINT), the \"setuponly\" plugin crashes due to some interaction with the capture manager.\r\n\r\nUsing pytest 5.2.0 (fresh install on Python 3.7 in a virtual env), given a dummy test:\r\n```\r\nimport time\r\nimport pytest\r\n\r\n\r\n@pytest.... | 2e11ea61088a3d24da96205627c8bc4dcf3a70ff | {
"head_commit": "e05b33ed162fd9da8f9c44c9de035a0fa14631ec",
"head_commit_message": "setuponly: remove printing out/err from capman",
"patch_to_review": "diff --git a/AUTHORS b/AUTHORS\nindex 9f6ee048d9a..e11400c1fa0 100644\n--- a/AUTHORS\n+++ b/AUTHORS\n@@ -267,5 +267,6 @@ Wouter van Ackooy\n Xixi Zhao\n Xuan Lu... | [
{
"diff_hunk": "@@ -267,3 +267,39 @@ def test_arg(arg):\n result.stdout.fnmatch_lines(\n [\"*SETUP F arg*\", \"*test_arg (fixtures used: arg)F*\", \"*TEARDOWN F arg*\"]\n )\n+\n+\n+def test_setup_show_with_KeyboardInterrupt_in_test(testdir):\n+ \"\"\" Verifies that setups are shown and tes... | 5624e366c1c812e200231e70c6ba2f15dc04a323 | diff --git a/AUTHORS b/AUTHORS
index 9f6ee048d9a..e11400c1fa0 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -267,5 +267,6 @@ Wouter van Ackooy
Xixi Zhao
Xuan Luong
Xuecong Liao
+Yoav Caspi
Zac Hatfield-Dodds
Zoltán Máté
diff --git a/changelog/5906.bugfix.rst b/changelog/5906.bugfix.rst
new file mode 100644
index 000000000... | {
"difficulty": "low",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} |
pydantic__pydantic-7775@96613c2 | pydantic/pydantic | Python | 7,775 | Keep values of private attributes set within `model_post_init` in subclasses | ## Change Summary
Check for an existing `__pydantic_private__` dict in `init_private_attributes` and account for values within, rather than always replacing with a new dict.
## Related issue number
Fixes https://github.com/pydantic/pydantic/issues/7091
## Checklist
* [x] The pull request title is a good ... | 2023-10-09T12:28:04Z | Inheritance of Models with private attributes causes unexpected behavior via model_post_init
### Initial Checks
- [X] I confirm that I'm using Pydantic V2
### Description
When a class defines a private attribute that inherits from a model containing its own private attribute. Values set in `model_post_init` are rese... | I can confirm that the issue reproduces on
```
pydantic version: 2.2.1
pydantic-core version: 2.6.1
pydantic-core build: profile=release pgo=true
python version: 3.11.4 (main, Jun 7 2023, 00:00:00) [GCC 13.1.1 20230511 (Red Hat 13.1.1-2)]
plat... | [
{
"body": "### Initial Checks\n\n- [X] I confirm that I'm using Pydantic V2\n\n### Description\n\nWhen a class defines a private attribute that inherits from a model containing its own private attribute. Values set in `model_post_init` are reset due to the `wrapped_model_post_init` in `ModelMetaclass`\n\n### Ex... | 83d408fbf6ce125932a0bd2493f86d8098c1aed0 | {
"head_commit": "96613c231d1938b51bff876c75262228a12d310d",
"head_commit_message": "Alternative fix that only avoids setting private attribute defaults more than once",
"patch_to_review": "diff --git a/pydantic/_internal/_model_construction.py b/pydantic/_internal/_model_construction.py\nindex 15dbb3ee1c1..20df1... | [
{
"diff_hunk": "@@ -259,6 +259,8 @@ def init_private_attributes(self: BaseModel, __context: Any) -> None:\n self: The BaseModel instance.\n __context: The context.\n \"\"\"\n+ if getattr(self, '__pydantic_private__', None) is not None:\n+ return\n pydantic_private = {}\n fo... | 217f6b97c15378d7a92dad63117e0194283bd42a | diff --git a/pydantic/_internal/_model_construction.py b/pydantic/_internal/_model_construction.py
index 15dbb3ee1c1..a0dc9db7e06 100644
--- a/pydantic/_internal/_model_construction.py
+++ b/pydantic/_internal/_model_construction.py
@@ -259,12 +259,13 @@ def init_private_attributes(self: BaseModel, __context: Any) -> N... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} |
pydantic__pydantic-7677@b6bbdcc | pydantic/pydantic | Python | 7,677 | Fix `mypy` issue with subclasses of `RootModel` | ## Change Summary
`mypy` no longer errors when a subclass of `RootModel` is instantiated without a `root` keyword argument. See issue for details/
## Related issue number
Fix #7463
## Checklist
* [x] The pull request title is a good summary of the changes - it will be used in the changelog
* [x] Unit te... | 2023-09-27T19:34:09Z | Mypy reports "Too many positional arguments" for RootModel subclass
### Initial Checks
- [X] I confirm that I'm using Pydantic V2
### Description
1. Subclassing the `RootModel` to use list as a root
2. Instantiating this new model without keyword `root=`
e.g. `ListRootModel(['qwe', 'asd'])` instead of `ListRo... | Hi,
Thanks for your question. You should be able to use `ListRootModel.model_validate(['qwe', 'asd'])` without a `mypy` error.
See the docs on how we recommend using `RootModel` [here](https://docs.pydantic.dev/latest/usage/models/#rootmodel-and-custom-root-types).
Let us know if you have any other questions! ... | [
{
"body": "### Initial Checks\n\n- [X] I confirm that I'm using Pydantic V2\n\n### Description\n\n\r\n1. Subclassing the `RootModel` to use list as a root\r\n2. Instantiating this new model without keyword `root=`\r\n e.g. `ListRootModel(['qwe', 'asd'])` instead of `ListRootModel(root=['qwe', 'asd'])`\r\n3. A... | 3205738358cfdf843991b5e2576597c23a449e47 | {
"head_commit": "b6bbdcca1d8a2eed7aadc0b5fe658aca8864bddc",
"head_commit_message": "first pass at fixing mypy argument error with subclasses of RootModel",
"patch_to_review": "diff --git a/pydantic/mypy.py b/pydantic/mypy.py\nindex c2eb919472d..359e1314f19 100644\n--- a/pydantic/mypy.py\n+++ b/pydantic/mypy.py\n... | [
{
"diff_hunk": "@@ -799,6 +802,14 @@ def add_initializer(self, fields: list[PydanticModelField], config: ModelConfigD\n use_alias=use_alias,\n is_settings=is_settings,\n )\n+ if is_root_model:\n+ if len(fields) > 1:\n+ pass... | fa028155b06b3ccecae564cd3166050ea455a2fe | diff --git a/pydantic/mypy.py b/pydantic/mypy.py
index c2eb919472d..e91aa7e613a 100644
--- a/pydantic/mypy.py
+++ b/pydantic/mypy.py
@@ -89,6 +89,7 @@
METADATA_KEY = 'pydantic-mypy-metadata'
BASEMODEL_FULLNAME = 'pydantic.main.BaseModel'
BASESETTINGS_FULLNAME = 'pydantic_settings.main.BaseSettings'
+ROOT_MODEL_FULLN... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} |
pydantic__pydantic-7570@526a933 | pydantic/pydantic | Python | 7,570 | Fixing `__iter__` returning private `cached_property` info | ## Change Summary
* Fixing `__iter__` returning private `cached_property` info
* By default, private `computed_field`s have `repr` set to False
<!-- Please give a short summary of the changes. -->
Fix #7499
## Checklist
* [x] The pull request title is a good summary of the changes - it will be used in the... | 2023-09-22T15:13:40Z | Private cached properties are included in BaseModel.__iter__
### Initial Checks
- [X] I confirm that I'm using Pydantic V2
### Description
Attributes whose name has a leading underscore are not treated as fields by Pydantic, and are not included in the model schema. However this doesn't seem to be the case for... | hmmm, looks like when calling a property with `cached_property`, the `cache_property` manipulates the class `__dict__` directly, here is the code snippet from `functools.cached_property`
```py
try:
cache = instance.__dict__ # <<< get the class __dict__
except AttributeError: # not a... | [
{
"body": "### Initial Checks\r\n\r\n- [X] I confirm that I'm using Pydantic V2\r\n\r\n### Description\r\n\r\nAttributes whose name has a leading underscore are not treated as fields by Pydantic, and are not included in the model schema. However this doesn't seem to be the case for fields injected by `cached_pr... | 8b11cc59d43339a91be120b7d0265197bc49435b | {
"head_commit": "526a933d67c42c3a9b3c0c33e3001980bac5caa2",
"head_commit_message": "adding docs update for default repr behavior",
"patch_to_review": "diff --git a/pydantic/fields.py b/pydantic/fields.py\nindex 46131b6ee9e..97137c2a098 100644\n--- a/pydantic/fields.py\n+++ b/pydantic/fields.py\n@@ -7,6 +7,7 @@\n... | [
{
"diff_hunk": "@@ -7,6 +7,7 @@\n import typing\n from copy import copy\n from dataclasses import Field as DataclassField\n+from functools import cached_property",
"line": null,
"original_line": 10,
"original_start_line": null,
"path": "pydantic/fields.py",
"start_line": null,
"text": "@... | 03526b866e28baa387d283560b06d20f2ee29e34 | diff --git a/pydantic/fields.py b/pydantic/fields.py
index 46131b6ee9e..222554b09af 100644
--- a/pydantic/fields.py
+++ b/pydantic/fields.py
@@ -7,6 +7,12 @@
import typing
from copy import copy
from dataclasses import Field as DataclassField
+
+try:
+ from functools import cached_property # type: ignore
+except ... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} |
pydantic__pydantic-7567@9d76cd2 | pydantic/pydantic | Python | 7,567 | Performance docs | - Replaces #7548
- Related to #7322
- Closes #7323 | 2023-09-22T13:26:03Z | Performance tips docs page
Page in the docs with tips on using pydantic in the most performant way.
Should start with a big notice saying something like "In most cases pydantic won't be your bottle neck, only follow this if you're sure it's necessary blah blah blah".
1. Use `model_validate_json()` not `model_vali... | [
{
"body": "Page in the docs with tips on using pydantic in the most performant way.\r\n\r\nShould start with a big notice saying something like \"In most cases pydantic won't be your bottle neck, only follow this if you're sure it's necessary blah blah blah\".\r\n\r\n1. Use `model_validate_json()` not `model_va... | e4409a84912c8bac7b050c5d398a5a67339341db | {
"head_commit": "9d76cd20d76f759dd5eb64424dddc2cf6251cf77",
"head_commit_message": "Literal from typing_extensions",
"patch_to_review": "diff --git a/docs/concepts/performance.md b/docs/concepts/performance.md\nnew file mode 100644\nindex 00000000000..5a597450892\n--- /dev/null\n+++ b/docs/concepts/performance.m... | [
{
"diff_hunk": "@@ -0,0 +1,157 @@\n+# Performance tips\n+\n+In most cases Pydantic won't be your bottle neck, only follow this if you're sure it's necessary.\n+\n+## Use `model_validate_json()` not `model_validate(json.loads(...))`\n+\n+On `model_validate(json.loads(...))`, the JSON is parsed in Python, then co... | 734f0b54d8360ed0b7d77431eccc2229750294c1 | diff --git a/docs/concepts/performance.md b/docs/concepts/performance.md
new file mode 100644
index 00000000000..d874336af14
--- /dev/null
+++ b/docs/concepts/performance.md
@@ -0,0 +1,209 @@
+# Performance tips
+
+In most cases Pydantic won't be your bottle neck, only follow this if you're sure it's necessary.
+
+## U... | {
"difficulty": "low",
"estimated_review_effort": 1,
"problem_domain": "Documentation Updates"
} | |
pydantic__pydantic-7319@7dbaeeb | pydantic/pydantic | Python | 7,319 | fix: adding a check that alias is validated as an identifier for Python | <!-- Thank you for your contribution! -->
<!-- Unless your change is trivial, please create an issue to discuss the change before creating a PR -->
## Change Summary
Changes in `generate_dataclass_signature` function. I used `is_valid_identifier` function from `_utils.py` for `alias` and `validation_alias` as ne... | 2023-09-03T02:08:26Z | Field alias does not accept parameter name with dashes in pydantic dataclasses
### Initial Checks
- [X] I confirm that I'm using Pydantic V2
### Description
Using a Field with an alias with a dash for a pydantic dataclass leads to a ValueError that the alias with dash is not a valid parameter name. For BaseModel it ... | I can confirm this is a bug. Would you like to try to make a PR to fix it? | [
{
"body": "### Initial Checks\n\n- [X] I confirm that I'm using Pydantic V2\n\n### Description\n\nUsing a Field with an alias with a dash for a pydantic dataclass leads to a ValueError that the alias with dash is not a valid parameter name. For BaseModel it works fine.\n\n### Example Code\n\n```Python\nfrom pyd... | c987bc6398b898d5c9e49606e3acb17b732359e8 | {
"head_commit": "7dbaeeb907d2485130e39ff3f4ee1ebef3ddafb6",
"head_commit_message": "refactor: rename class Example -> Foo in test",
"patch_to_review": "diff --git a/pydantic/_internal/_dataclasses.py b/pydantic/_internal/_dataclasses.py\nindex 4c2c4d025a4..6d40460fdf7 100644\n--- a/pydantic/_internal/_dataclasse... | [
{
"diff_hunk": "@@ -2547,3 +2547,15 @@ class Model(BaseModel, Base):\n pass\n \n assert Model().a == 5\n+\n+\n+def test_alias_with_dashes():\n+ \"\"\"Test for fix issue #7226.\"\"\"\n+ data = {'some-var': 'some_value'}\n+\n+ @pydantic.dataclasses.dataclass\n+ class Foo:\n+ some_va... | 457b3937f66221168392c66ec0f61da65b4bcf5f | diff --git a/pydantic/_internal/_dataclasses.py b/pydantic/_internal/_dataclasses.py
index 4c2c4d025a4..6d40460fdf7 100644
--- a/pydantic/_internal/_dataclasses.py
+++ b/pydantic/_internal/_dataclasses.py
@@ -22,6 +22,7 @@
from ._generics import get_standard_typevars_map
from ._mock_val_ser import set_dataclass_mock_... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} |
pydantic__pydantic-7346@b99d117 | pydantic/pydantic | Python | 7,346 | Raise an Error When Computed Field Overrides Field | ## Change Summary
* If a `computed_field` is defined in a subclass such that it overrides a field from a superclass, a `ValueError` is raised.
## Related issue number
fix #7250
## Checklist
* [x] The pull request title is a good summary of the changes - it will be used in the changelog
* [x] Unit tests f... | 2023-09-05T19:42:07Z | Failure to override an inherited field with a computed field
### Initial Checks
- [X] I confirm that I'm using Pydantic V2
### Description
It seems that overriding a regular field with a computed field doesn't behave as expected. Instead of a value being returned by accessing the property the property object i... | Looks like a bug. We should either fix it so in this example `name` is removed from fields, or raise an error.
BTW, there's no way to avoid the pyright complaint since that's just dataclass transforms doing their thing.
PR welcome to fix this.
Should this even be allowed? In general, overriding an attribute with ... | [
{
"body": "### Initial Checks\r\n\r\n- [X] I confirm that I'm using Pydantic V2\r\n\r\n### Description\r\n\r\nIt seems that overriding a regular field with a computed field doesn't behave as expected. Instead of a value being returned by accessing the property the property object itself is returned. And as for ... | 99555e9ac9ef9b54ced0e52fdc24f523eecfc244 | {
"head_commit": "b99d117f05d5f4f501efc703121b8e19e7d2ed7b",
"head_commit_message": "raise error on field override, adding needed import and unit test",
"patch_to_review": "diff --git a/pydantic/_internal/_fields.py b/pydantic/_internal/_fields.py\nindex 92a240f547e..e42c7a47e9f 100644\n--- a/pydantic/_internal/_... | [
{
"diff_hunk": "@@ -741,3 +741,18 @@ def double_x(self) -> T:\n \n with pytest.warns(UserWarning, match='Expected `int` but got `str` - serialized value may not be as expected'):\n B[int]().model_dump()\n+\n+\n+def test_computed_field_override_raises():\n+ class Model(BaseModel):\n+ name: ... | 9b9a435a4cd3447d5a4b0eac800e6026b79fbad9 | diff --git a/pydantic/_internal/_fields.py b/pydantic/_internal/_fields.py
index 92a240f547e..e42c7a47e9f 100644
--- a/pydantic/_internal/_fields.py
+++ b/pydantic/_internal/_fields.py
@@ -19,6 +19,7 @@
from ..fields import FieldInfo
from ..main import BaseModel
from ._dataclasses import StandardDataclas... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} |
pytest-dev__pytest-3741@5003bae | pytest-dev/pytest | Python | 3,741 | Miscellaneous improvements to approx() | This PR fixes a couple small issues with ``approx()``:
- Change the output of ``repr(approx(np.array(...)))`` to reflect the dimension of the array being compared. For example, ``repr(approx([[1, 2], [3, 4]]))`` would look something like ``approx([[1±..., 2±...], [3±..., 4±...]])`` rather than ``approx([1±..., 2±..... | 2018-07-31T07:43:58Z | 'approx' should error immediately if an invalid parameter is passed
Using pytest.approx with an invalid parameter (eg, a string) should fail immediately rather than waiting until it calls repr(). Example:
```
>>> import pytest
>>> x = pytest.approx("abc")
>>> x
Traceback (most recent call last):
File "<stdin>... | After some digging I have traced the flow through these files:
## Approx function is fired off ##
Providing a string argument to this function defaults the cls selection to approx scalar.
```
if _is_numpy_array(expected):
cls = ApproxNumpy
elif isinstance(expected, Mapping):
cls = ApproxM... | [
{
"body": "Using pytest.approx with an invalid parameter (eg, a string) should fail immediately rather than waiting until it calls repr(). Example:\r\n\r\n```\r\n>>> import pytest\r\n>>> x = pytest.approx(\"abc\")\r\n>>> x\r\nTraceback (most recent call last):\r\n File \"<stdin>\", line 1, in <module>\r\n Fil... | 253419316ce09b952862811db229a9e9383a332b | {
"head_commit": "5003bae0de4e1dc3ded16950c24c2aad275c78a4",
"head_commit_message": "Fix 'at' string for non-numeric messages in approx()",
"patch_to_review": "diff --git a/changelog/3473.bugfix.rst b/changelog/3473.bugfix.rst\nnew file mode 100644\nindex 00000000000..ef434b29f16\n--- /dev/null\n+++ b/changelog/3... | [
{
"diff_hunk": "@@ -75,20 +89,31 @@ def _yield_comparisons(self, actual):\n \"\"\"\n raise NotImplementedError\n \n+ def _check_type(self):\n+ \"\"\"\n+ Raise a TypeError if the expected value is not a valid type.\n+ \"\"\"\n+ # This is only a concern if the expect... | a5c0fb7f6b8d6213111c70d07ace773e6e794614 | diff --git a/changelog/3473.bugfix.rst b/changelog/3473.bugfix.rst
new file mode 100644
index 00000000000..ef434b29f16
--- /dev/null
+++ b/changelog/3473.bugfix.rst
@@ -0,0 +1 @@
+Raise immediately if ``approx()`` is given an expected value of a type it doesn't understand (e.g. strings, nested dicts, etc.).
diff --git ... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} |
pydantic__pydantic-7302@031eda6 | pydantic/pydantic | Python | 7,302 | Do not override `model_post_init` in subclass with private attrs | <!-- Thank you for your contribution! -->
<!-- Unless your change is trivial, please create an issue to discuss the change before creating a PR -->
## Change Summary
<!-- Please give a short summary of the changes. -->
## Related issue number
Fixes https://github.com/pydantic/pydantic/issues/7293
<!-- W... | 2023-08-31T08:02:31Z | model_post_init not called on subclasses with a private attribute
### Initial Checks
- [X] I confirm that I'm using Pydantic V2
### Description
In the example below, I would expect the `Model1.model_post_init` to be called when instantiating `Model2` but it is not.
On the other hand, `Model1.model_post_init... | @Viicos I think you are on the right track. Would you like to open a PR for this? If not, we can get it across the line.
> @Viicos I think you are on the right track. Would you like to open a PR for this? If not, we can get it across the line.
I'll try to submit a PR | [
{
"body": "### Initial Checks\r\n\r\n- [X] I confirm that I'm using Pydantic V2\r\n\r\n### Description\r\n\r\nIn the example below, I would expect the `Model1.model_post_init` to be called when instantiating `Model2` but it is not.\r\n\r\nOn the other hand, `Model1.model_post_init` is called:\r\n- when instanti... | c987bc6398b898d5c9e49606e3acb17b732359e8 | {
"head_commit": "031eda6cc74ca85a8e25dfef1c30c3b19503bed9",
"head_commit_message": "Use a default return value for `getattr`",
"patch_to_review": "diff --git a/pydantic/_internal/_model_construction.py b/pydantic/_internal/_model_construction.py\nindex 5b22a67e4a3..cca9d449369 100644\n--- a/pydantic/_internal/_m... | [
{
"diff_hunk": "@@ -266,6 +266,17 @@ def init_private_attributes(self: BaseModel, __context: Any) -> None:\n object_setattr(self, '__pydantic_private__', pydantic_private)\n \n \n+def get_model_post_init(namespace: dict[str, Any], bases: tuple[type[Any], ...]) -> Callable[..., Any] | None:\n+ \"\"\"Get t... | a0591c02f1edfe2d66b36347f82ad0589e175761 | diff --git a/pydantic/_internal/_decorators.py b/pydantic/_internal/_decorators.py
index 75e0c51ac68..49a386fcafd 100644
--- a/pydantic/_internal/_decorators.py
+++ b/pydantic/_internal/_decorators.py
@@ -341,6 +341,9 @@ def merge_seqs(seqs: list[deque[type[Any]]]) -> Iterable[type[Any]]:
return tuple(merge_seqs(s... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} |
pydantic__pydantic-7184@fb35206 | pydantic/pydantic | Python | 7,184 | fix: Allow inheriting dataclasses with defaults | <!-- Thank you for your contribution! -->
<!-- Unless your change is trivial, please create an issue to discuss the change before creating a PR -->
## Change Summary
This patch allows for a `pydantic.Basemodel` class to inherit a "pure" stdlib dataclass, even when the attribute name is set on the class instance,... | 2023-08-20T21:13:02Z | Allow inheriting `dataclasses.dataclass` with defaults
### Initial Checks
- [X] I confirm that I'm using Pydantic V2
### Description
Currently, inheriting a pure dataclass to a subclass that is also a `BaseModel` works. This is great, and this feature has been used extensively in v1 in a code base i maintain. ... | @tobni thank you for the bug report.
I can confirm that the issue reproduces in Pydantic v2.1.1. | [
{
"body": "### Initial Checks\r\n\r\n- [X] I confirm that I'm using Pydantic V2\r\n\r\n### Description\r\n\r\nCurrently, inheriting a pure dataclass to a subclass that is also a `BaseModel` works. This is great, and this feature has been used extensively in v1 in a code base i maintain. v2 seems to have the add... | ace9f8da589b1a2a15608d97472fc332e8d5465c | {
"head_commit": "fb35206a98a29a2b6113a8c780a8ba77d5f21cb6",
"head_commit_message": "test: Add explanatory docstring and showcase supported use",
"patch_to_review": "diff --git a/pydantic/_internal/_fields.py b/pydantic/_internal/_fields.py\nindex 61ba44696df..92a240f547e 100644\n--- a/pydantic/_internal/_fields.... | [
{
"diff_hunk": "@@ -2500,3 +2500,50 @@ class StdLibDataclass:\n \n assert is_pydantic_dataclass(PydanticDataclass) is True\n assert is_pydantic_dataclass(StdLibDataclass) is False\n+\n+\n+def test_can_inherit_stdlib_dataclasses_with_defaults():\n+ @dataclasses.dataclass\n+ class Base:\n+ a:... | a1b87f23dc370450c5ef7ae081ff8b9e4b63c74f | diff --git a/pydantic/_internal/_fields.py b/pydantic/_internal/_fields.py
index 61ba44696df..92a240f547e 100644
--- a/pydantic/_internal/_fields.py
+++ b/pydantic/_internal/_fields.py
@@ -147,10 +147,18 @@ def collect_model_fields( # noqa: C901
# "... shadows an attribute" errors
generic_origin = ge... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} |
pytest-dev__pytest-3641@a6636fd | pytest-dev/pytest | Python | 3,641 | Fixes #3630 | Fixes #3630
- [x] Create a new changelog file in the `changelog` folder, with a name like `<ISSUE NUMBER>.<TYPE>.rst`. See [changelog/README.rst](/changelog/README.rst) for details.
- [x] Target the `master` branch for bug fixes, documentation updates and trivial changes.
- **(not applicable)** Target the `feature... | 2018-06-29T14:20:33Z | problems with unicode characters when saving log to file
## Normal case
I have this very simple test which is just logging some unicode character:
test_log.py
```
import logging
logger = logging.getLogger(__name__)
def test():
logger.info("Normal")
logger.info("\u251c")
logger.info("Also norm... | [GitMate.io](https://gitmate.io) thinks possibly related issues are https://github.com/pytest-dev/pytest/issues/3338 (Problem with Custom Subclass of logging.Formatter), https://github.com/pytest-dev/pytest/issues/1131 (Experiencing unicode error inside pytester in Hypothesis test suite), https://github.com/pytest-dev/... | [
{
"body": "## Normal case\r\nI have this very simple test which is just logging some unicode character:\r\n\r\ntest_log.py\r\n```\r\nimport logging\r\n\r\nlogger = logging.getLogger(__name__)\r\n\r\ndef test():\r\n logger.info(\"Normal\")\r\n logger.info(\"\\u251c\")\r\n logger.info(\"Also normal\")\r\... | a48c47b53b95b3f3425f47a1ad2b21f3a30d4209 | {
"head_commit": "a6636fddcdcbb198e750f4097d5d0c08442e1f00",
"head_commit_message": "Fixed open function with encoding in python 2.7",
"patch_to_review": "diff --git a/changelog/3630.bugfix.rst b/changelog/3630.bugfix.rst\nnew file mode 100644\nindex 00000000000..505bcb8fde9\n--- /dev/null\n+++ b/changelog/3630.b... | [
{
"diff_hunk": "@@ -827,6 +828,40 @@ def test_log_file(request):\n assert \"This log message won't be shown\" not in contents\n \n \n+def test_log_file_unicode(testdir):\n+ log_file = testdir.tmpdir.join(\"pytest.log\").strpath\n+\n+ testdir.makeini(\n+ \"\"\"\n+ [pytest]\n+ l... | dad3e773198a95e49a0b5a1e805bd0318c508996 | diff --git a/changelog/3630.bugfix.rst b/changelog/3630.bugfix.rst
new file mode 100644
index 00000000000..505bcb8fde9
--- /dev/null
+++ b/changelog/3630.bugfix.rst
@@ -0,0 +1 @@
+Log messages with unicode characters would not appear in the output log file.
diff --git a/src/_pytest/logging.py b/src/_pytest/logging.py
i... | {
"difficulty": "low",
"estimated_review_effort": 2,
"problem_domain": "Bug Fixes"
} |
pytest-dev__pytest-3215@18c84a1 | pytest-dev/pytest | Python | 3,215 | Disable output capturing in doctest on macOS | ... to avoid losing reference to stdout. Fixes #985.
This patch implements the [change proposed](https://github.com/pytest-dev/pytest/issues/985#issuecomment-357541238), but encapsulates the workaround and documents it with a docstring.
- [x] Create a new changelog file in the `changelog` folder, with a name like... | 2018-02-13T17:28:00Z | pdb prompt unusable if doctests ran first (macOS and Python 3)
Consider this simple test:
```
">>> 3\n3"
def test_stuff():
import pdb; pdb.set_trace()
```
Create a virtualenv on Python 3.4.3, install pytest 2.7.2 and py 1.4.30 and run py.test:
```
(pytest) $ py.test
====================================== test s... | for testing purposes i'd suggest to write s small script using python pexpect that then can be used to test against different versions an potentially for bisecting the responsible change
do you have a rough set of known good/bad releases
I rolled back to pytest 2.6.x and 2.7.0, but the issue remained. I'll try some o... | [
{
"body": "Consider this simple test:\n\n```\n\">>> 3\\n3\"\n\ndef test_stuff():\n import pdb; pdb.set_trace()\n```\n\nCreate a virtualenv on Python 3.4.3, install pytest 2.7.2 and py 1.4.30 and run py.test:\n\n```\n(pytest) $ py.test\n====================================== test session starts ==============... | e7bcc854d975e981c090e37e747d91fc7999500e | {
"head_commit": "18c84a1904e96d5a4fc265b0fde56765ca36c7c3",
"head_commit_message": "Restrict fix to macOS only. Ref #3215.",
"patch_to_review": "diff --git a/_pytest/doctest.py b/_pytest/doctest.py\nindex bba90e551c5..6a2918b6f5a 100644\n--- a/_pytest/doctest.py\n+++ b/_pytest/doctest.py\n@@ -2,6 +2,8 @@\n from ... | [
{
"diff_hunk": "@@ -103,8 +105,21 @@ def setup(self):\n \n def runtest(self):\n _check_all_skipped(self.dtest)\n+ self._disable_output_capturing()\n self.runner.run(self.dtest)\n \n+ def _disable_output_capturing(self):",
"line": null,
"original_line": 111,
"original_st... | 4131d3f300196da059f5abe6d36f4870459692ad | diff --git a/_pytest/doctest.py b/_pytest/doctest.py
index bba90e551c5..f54f833ece9 100644
--- a/_pytest/doctest.py
+++ b/_pytest/doctest.py
@@ -2,6 +2,8 @@
from __future__ import absolute_import, division, print_function
import traceback
+import sys
+import platform
import pytest
from _pytest._code.code import... | {
"difficulty": "low",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} |
pydantic__pydantic-6892@fd1cadb | pydantic/pydantic | Python | 6,892 | remove parts of docs about i64 limits applying to python ints | ## Change Summary
This removes the places where the docs still talk about ints being internally handled as i64s. As discussed in #6889 this isn't the case anymore. The "Pydantic V2 Plan" page also talks about it but I've left it as is since it's a historic page and not really part of the current docs.
## Related ... | 2023-07-26T21:21:49Z | Implicit int limits
### Initial Checks
- [X] I confirm that I'm using Pydantic V2
### Description
Some of the older messaging around the move to v2 and the current data conversion table in the docs say that you use i64 values to internally represent python `int`. I expected this to lead to either error messages when... | I think we recently fixed this to handle large numbers, up to the limits of python (which IIRC are ~4000 decimal digits). I think we use i64s when the value can fit, and otherwise convert to a python int.
If there are places in the docs that you think should be updated (probably an oversight on our part), please le... | [
{
"body": "### Initial Checks\n\n- [X] I confirm that I'm using Pydantic V2\n\n### Description\n\nSome of the older messaging around the move to v2 and the current data conversion table in the docs say that you use i64 values to internally represent python `int`. I expected this to lead to either error messages... | e4a6dba2af504777a20fd66ad0da05e6d3283345 | {
"head_commit": "fd1cadb32be1b723eb8d9aab0c32123c0e5c8ace",
"head_commit_message": "remove mentions of i64 limits applying to python ints",
"patch_to_review": "diff --git a/docs/errors/validation_errors.md b/docs/errors/validation_errors.md\nindex bcc9dd6e8bb..7c8d43f8c58 100644\n--- a/docs/errors/validation_err... | [
{
"diff_hunk": "@@ -778,8 +778,7 @@ except ValidationError as exc:\n \n ## `int_parsing_size`\n \n-This error is raised when attempting to parse a python value from a string outside the maximum range of a Python `int`,\n-or when trying to parse an integer from JSON that is outside the valid range of a 64 bit in... | 0a3ecf15c74a4c187f361a28c74f517c0f4a54be | diff --git a/docs/errors/validation_errors.md b/docs/errors/validation_errors.md
index bcc9dd6e8bb..320ebb4349d 100644
--- a/docs/errors/validation_errors.md
+++ b/docs/errors/validation_errors.md
@@ -778,8 +778,8 @@ except ValidationError as exc:
## `int_parsing_size`
-This error is raised when attempting to pars... | {
"difficulty": "low",
"estimated_review_effort": 1,
"problem_domain": "Bug Fixes"
} |
pyodide__pyodide-5719@3bec82c | pyodide/pyodide | Python | 5,719 | Add ffi support for JS null and switch to wasm-gc struct for error signaling | We need JS null to represent actual null and not an error. Instead, we use wasm-gc except on safari iOS
where wasm-gc is broken or on old runtimes where wasm-gc support is missing. If we can't use wasm-gc,
we use a JS object and a JS trampoline. There is maybe a 3-4% performance hit associated with
this fallback com... | 2025-06-27T14:08:18Z | Provide a way to convert None to null in to_js
## 🚀 Feature
I propose some functionality be added to `pyodide.ffi.to_js` to allow Python `None` values to be translated into `null` values rather than `undefined` values.
### Motivation
Currently `pyodide.ffi.to_js` converts all encountered `None` values to `un... | Does this work for you:
```py
from pyodide.ffi import to_js
from pyodide.code import run_js
dict_converter = run_js(
"""
((entries) => {
for(let entry of entries) {
if(entry[1] === undefined) {
entry[1] = null;
}
}
return Object.fromEntries(entries);
})
"""
)
... | [
{
"body": "## 🚀 Feature\r\n\r\nI propose some functionality be added to `pyodide.ffi.to_js` to allow Python `None` values to be translated into `null` values rather than `undefined` values. \r\n\r\n### Motivation\r\n\r\nCurrently `pyodide.ffi.to_js` converts all encountered `None` values to `undefined` on the ... | a61c0af1df4a7adee258e5ac7d2da134d7655d7a | {
"head_commit": "3bec82c8e7ba6cd7dfd63b2b44c751c4135f5877",
"head_commit_message": "Tidy sentinel.wat",
"patch_to_review": "diff --git a/Makefile b/Makefile\nindex 9da11f8144a..4eca4f6c1a9 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -68,6 +68,9 @@ src/core/pyodide_pre.gen.dat: src/js/generated/_pyodide.out.js src... | [
{
"diff_hunk": "@@ -5,6 +5,11 @@ import { initializeNativeFS } from \"./nativefs\";\n import { loadBinaryFile, getBinaryResponse } from \"./compat\";\n import { API, PreRunFunc, type Module } from \"./types\";\n \n+// @ts-ignore",
"line": null,
"original_line": 8,
"original_start_line": null,
"p... | 281a5349ea29f1f378ab9e5791f10842cd59847f | diff --git a/.gitignore b/.gitignore
index 3654beb36b6..e63ddb61842 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,6 +4,7 @@
*.gen.*
src/js/generated
*.out.*
+*.wasm
*.egg-info/
diff --git a/Makefile b/Makefile
index 9da11f8144a..e260917cd97 100644
--- a/Makefile
+++ b/Makefile
@@ -68,6 +68,9 @@ src/core/pyodid... | {
"difficulty": "medium",
"estimated_review_effort": 4,
"problem_domain": "New Feature Additions"
} |
pydantic__pydantic-6715@b294f57 | pydantic/pydantic | Python | 6,715 | Use contentSchema keyword for JSON schema | Closes https://github.com/pydantic/pydantic/issues/6663
Selected Reviewer: @lig | 2023-07-17T16:36:14Z | `Json[type]` schema generated now returns `string` rather than `type`
### Initial Checks
- [X] I confirm that I'm using Pydantic V2
### Description
With `Json[]` the schema type is now always `string`, rather than the type inside `Json[]`.
In `V1` the example would produce:
```JSON
{
"title":"Foo",
... | Thanks @zakstucke for reporting this 🙏
Isn't the `"type":"string"` correct? because the model accepts strings, not int.
```py
Foo(foo='1') # Ok
Foo(foo=1)
"""
pydantic_core._pydantic_core.ValidationError: 1 validation error for Foo
foo
JSON input should be string, bytes or bytearray [type=json_type, ... | [
{
"body": "### Initial Checks\r\n\r\n- [X] I confirm that I'm using Pydantic V2\r\n\r\n### Description\r\n\r\nWith `Json[]` the schema type is now always `string`, rather than the type inside `Json[]`.\r\n\r\nIn `V1` the example would produce:\r\n\r\n```JSON\r\n{\r\n \"title\":\"Foo\",\r\n \"type\":\"object... | d249af9c7895020fee8e34f59ffb5c9220453719 | {
"head_commit": "b294f570a4a6c8f2bb93ab3f69760f5a3e05a328",
"head_commit_message": "Use contentSchema keyword for JSON schema",
"patch_to_review": "diff --git a/pydantic/json_schema.py b/pydantic/json_schema.py\nindex 2de8af4023e..955fff7f058 100644\n--- a/pydantic/json_schema.py\n+++ b/pydantic/json_schema.py\n... | [
{
"diff_hunk": "@@ -1609,13 +1609,13 @@ def json_schema(self, schema: core_schema.JsonSchema) -> JsonSchemaValue:\n Returns:\n The generated JSON schema.\n \"\"\"\n+ content_core_schema = schema['schema'] if 'schema' in schema else core_schema.any_schema()",
"line": null,
... | 1380b8cb0322ca70fa962ac57d53762f51971d2a | diff --git a/pydantic/json_schema.py b/pydantic/json_schema.py
index 2de8af4023e..e76603a17cc 100644
--- a/pydantic/json_schema.py
+++ b/pydantic/json_schema.py
@@ -1609,13 +1609,13 @@ def json_schema(self, schema: core_schema.JsonSchema) -> JsonSchemaValue:
Returns:
The generated JSON schema.
... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} |
pyodide__pyodide-4993@0399d3f | pyodide/pyodide | Python | 4,993 | Fix `pyimport` for some corner cases | ### Description
Fix #4992
### Checklists
- [x] Add a [CHANGELOG](https://github.com/pyodide/pyodide/blob/main/docs/project/changelog.md) entry
- [x] Add / update tests
| 2024-08-07T04:14:29Z | `pyimport` fail to import a module from a module
## 🐛 Bug
After manually deleting the child module from `sys.modules` or deleting the attribute from the parent module, `pyimport` fail to import the child module, which is inconsistent with the behavior of `from ... import ...` statement.
### To Reproduce
```py... | [
{
"body": "## 🐛 Bug\r\n\r\nAfter manually deleting the child module from `sys.modules` or deleting the attribute from the parent module, `pyimport` fail to import the child module, which is inconsistent with the behavior of `from ... import ...` statement.\r\n\r\n### To Reproduce\r\n\r\n```py\r\n# setup files\... | 73a13d08121ba180697df248caebaa5f36cfd64a | {
"head_commit": "0399d3f70505246cc5e29ab85ac64e96f72eb1d2",
"head_commit_message": "fix `pyimport`",
"patch_to_review": "diff --git a/src/py/_pyodide/_base.py b/src/py/_pyodide/_base.py\nindex 4c1af43d5cd..24d67391e30 100644\n--- a/src/py/_pyodide/_base.py\n+++ b/src/py/_pyodide/_base.py\n@@ -11,6 +11,7 @@\n imp... | [
{
"diff_hunk": "@@ -649,8 +650,11 @@ def find_imports(source: str) -> list[str]:\n \n \n def pyimport_impl(path: str) -> Any:\n- [stem, *fromlist] = path.rsplit(\".\", 1)\n- res = __import__(stem, fromlist=fromlist)\n- if fromlist:\n- res = getattr(res, fromlist[0])\n- return res\n+ if \".... | bc9dcf8d502cb08699fe9e79c3e53a2b861deadd | diff --git a/docs/project/changelog.md b/docs/project/changelog.md
index 67db38dbf44..26e6298dd51 100644
--- a/docs/project/changelog.md
+++ b/docs/project/changelog.md
@@ -44,6 +44,9 @@ myst:
speedup for methods with arguments is less drastic but still quite a lot.
{pr}`4961`
+- {{ Fix }} `pyimport("a.b")` won... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} | |
pydantic__pydantic-6622@2f6e34a | pydantic/pydantic | Python | 6,622 | 🐛 Support defining `json_schema_extra` on `RootModel` using `Field` | ## Change Summary
Add support for `json_schema_extra` using `Field` on `Root.root`
## Related issue number
Fix #6579
## Checklist
* [x] The pull request title is a good summary of the changes - it will be used in the changelog
* [x] Unit tests for the changes exist
* [x] Tests pass on CI and coverage r... | 2023-07-12T13:20:32Z | `Field(json_schema_extra=...)` is missing in schema with `RootModel`
### Initial Checks
- [X] I confirm that I'm using Pydantic V2
### Description
`RootModel` ignores `json_schema_extra` in the outputted schema. Breakage from V1 `__root__` which did respect it.
### Example Code
```Python
from pydantic i... | [
{
"body": "### Initial Checks\r\n\r\n- [X] I confirm that I'm using Pydantic V2\r\n\r\n### Description\r\n\r\n`RootModel` ignores `json_schema_extra` in the outputted schema. Breakage from V1 `__root__` which did respect it.\r\n\r\n### Example Code\r\n\r\n```Python\r\nfrom pydantic import BaseModel, Field, Root... | b0058adb54c4364479db52b38345bad15ef0a947 | {
"head_commit": "2f6e34a62a872c73b716730377ef97a92bbf0240",
"head_commit_message": "🐛 Support defining `json_schema_extra` on `RootModel` using `Field`",
"patch_to_review": "diff --git a/pydantic/json_schema.py b/pydantic/json_schema.py\nindex d469840294b..989cef6d9bd 100644\n--- a/pydantic/json_schema.py\n+++ ... | [
{
"diff_hunk": "@@ -1256,6 +1256,16 @@ def model_schema(self, schema: core_schema.ModelSchema) -> JsonSchemaValue:\n title = config.get('title')\n \n json_schema_extra = config.get('json_schema_extra')\n+ if cls.__pydantic_root_model__:\n+ root_json_schema_extra = cls.model_fie... | 861254c5386453ad59c800f915b0cabeed9fb110 | diff --git a/pydantic/json_schema.py b/pydantic/json_schema.py
index d469840294b..2548b92ca60 100644
--- a/pydantic/json_schema.py
+++ b/pydantic/json_schema.py
@@ -1256,6 +1256,16 @@ def model_schema(self, schema: core_schema.ModelSchema) -> JsonSchemaValue:
title = config.get('title')
json_schema_... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} | |
pydantic__pydantic-6562@a5934fa | pydantic/pydantic | Python | 6,562 | Include extra when iterating over a model | Fixes #6560
skip change file check
Selected Reviewer: @Kludex | 2023-07-10T17:03:54Z | Unexpected behavior with extra fields
### Initial Checks
- [X] I confirm that I'm using Pydantic V2 installed directly from the `main` branch, or equivalent
### Description
While migrating to v2, I realized that iteration and extra fields were not working as I expected. Before, extra fields would be included when i... | [
{
"body": "### Initial Checks\n\n- [X] I confirm that I'm using Pydantic V2 installed directly from the `main` branch, or equivalent\n\n### Description\n\nWhile migrating to v2, I realized that iteration and extra fields were not working as I expected. Before, extra fields would be included when iterating throu... | ac576b6d3f7514e66c6284e24bb1bdfa791177c8 | {
"head_commit": "a5934fa157ff07a26d238698b013e7cf7c8265b5",
"head_commit_message": "Include extra when iterating over a model",
"patch_to_review": "diff --git a/pydantic/main.py b/pydantic/main.py\nindex 7bb3fb00358..8febf52f0ac 100644\n--- a/pydantic/main.py\n+++ b/pydantic/main.py\n@@ -835,6 +835,7 @@ class My... | [
{
"diff_hunk": "@@ -835,6 +835,7 @@ class MyModel(BaseModel, extra='allow'):\n def __iter__(self) -> TupleGenerator:\n \"\"\"So `dict(model)` works.\"\"\"\n yield from self.__dict__.items()\n+ yield from (self.__pydantic_extra__ or {}).items()",
"line": null,
"original_line": ... | 66e21577d200bf5b5319fd4ff6486f9a862ea51f | diff --git a/pydantic/main.py b/pydantic/main.py
index 7bb3fb00358..fefbdf8c799 100644
--- a/pydantic/main.py
+++ b/pydantic/main.py
@@ -835,6 +835,9 @@ class MyModel(BaseModel, extra='allow'):
def __iter__(self) -> TupleGenerator:
"""So `dict(model)` works."""
yield from self.__dict__.items()
+ ... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} | |
pydantic__pydantic-6511@f5841fb | pydantic/pydantic | Python | 6,511 | Fix forward ref in generic | Fixes #6503
skip change file check
Selected Reviewer: @samuelcolvin | 2023-07-07T14:59:34Z | Forward reference in typing.Type["..."] errors with `TypeError: 'ForwardRef' object cannot be converted to 'PyType'`
### Initial Checks
- [X] I confirm that I'm using Pydantic V2 installed directly from the `main` branch, or equivalent
### Description
When a pydantic model (or any other class) is forward refer... | [
{
"body": "### Initial Checks\r\n\r\n- [X] I confirm that I'm using Pydantic V2 installed directly from the `main` branch, or equivalent\r\n\r\n### Description\r\n\r\nWhen a pydantic model (or any other class) is forward referenced inside `tp.Type[\"Bar\"]` pydantic errors. \r\n\r\nWhen the whole type is forwar... | 1a8bd8f56273126848d65af7df7ecc91a1ee9304 | {
"head_commit": "f5841fb2c4caa5872b83c617182839c097ff19e4",
"head_commit_message": "Handle tuple case",
"patch_to_review": "diff --git a/pydantic/_internal/_generate_schema.py b/pydantic/_internal/_generate_schema.py\nindex 865b130ef0d..d5e259e0604 100644\n--- a/pydantic/_internal/_generate_schema.py\n+++ b/pyda... | [
{
"diff_hunk": "@@ -997,3 +997,26 @@ class allOfExpressions_(BaseModel):\n models = [allOfExpressions_, Expressions_]\n for m in models:\n m.model_rebuild(_types_namespace=types_namespace)\n+\n+\n+def test_forward_ref_in_generic(create_module: Any) -> None:\n+ \"\"\"https://github.com/pydanti... | b885eac71f31d13be9d4d413c378d1331a43ddad | diff --git a/pydantic/_internal/_generate_schema.py b/pydantic/_internal/_generate_schema.py
index 865b130ef0d..d5e259e0604 100644
--- a/pydantic/_internal/_generate_schema.py
+++ b/pydantic/_internal/_generate_schema.py
@@ -15,7 +15,20 @@
from itertools import chain
from operator import attrgetter
from types import... | {
"difficulty": "medium",
"estimated_review_effort": 4,
"problem_domain": "Bug Fixes"
} | |
pydantic__pydantic-6417@d07faaa | pydantic/pydantic | Python | 6,417 | Improve `BaseModel.__getattr__` to raise a better error in case of AttributeError in model property | Closes https://github.com/pydantic/pydantic/issues/6360
Based on [@samuelcolvin comment](https://github.com/pydantic/pydantic/issues/6360#issuecomment-1617725012)
Selected Reviewer: @dmontagu | 2023-07-04T12:38:06Z | Change in behaviour when a models property raises an attribute error.
### Initial Checks
- [X] I confirm that I'm using Pydantic V2 installed directly from the `main` branch, or equivalent
### Description
Whilst trying to debug an error in my code, I kept getting an error telling me that my property doesn't ex... | Thanks @ollz272 for reporting this.
Yes, In V2, we have `BaseModel.__getattr__` and it handles private and extra attrs.
Not sure how we are going to handle this case.
@samuelcolvin Do you have any idea?
See [this SO question](https://stackoverflow.com/a/24260979/949890) - this is a known problem with `__getatt... | [
{
"body": "### Initial Checks\r\n\r\n- [X] I confirm that I'm using Pydantic V2 installed directly from the `main` branch, or equivalent\r\n\r\n### Description\r\n\r\nWhilst trying to debug an error in my code, I kept getting an error telling me that my property doesn't exist. Code was something like:\r\n\r\n``... | 5aa850687b969e7c0526f9ecedab94d88b3e1a07 | {
"head_commit": "d07faaaace8a426e7c360bdb58f85a0192b5c72c",
"head_commit_message": "Update tests/test_main.py\n\nCo-authored-by: David Montague <35119617+dmontagu@users.noreply.github.com>",
"patch_to_review": "diff --git a/pydantic/main.py b/pydantic/main.py\nindex 2d75c726568..bf3c9e72eaf 100644\n--- a/pydanti... | [
{
"diff_hunk": "@@ -703,7 +703,14 @@ def __getattr__(self, item: str) -> Any:\n except KeyError as exc:\n raise AttributeError(f'{type(self).__name__!r} object has no attribute {item!r}') from exc\n else:\n- raise AttributeError(f'{t... | 153833dd0f2258959f2fc04cb291f88f87d90abe | diff --git a/pydantic/main.py b/pydantic/main.py
index 2d75c726568..f0732ed28e2 100644
--- a/pydantic/main.py
+++ b/pydantic/main.py
@@ -703,7 +703,11 @@ def __getattr__(self, item: str) -> Any:
except KeyError as exc:
raise AttributeError(f'{type(self).__name__!r} object h... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} |
pydantic__pydantic-6402@bde5ace | pydantic/pydantic | Python | 6,402 | Rework how JSON schema refs get built/"simplified" | This closes #6369, and also addresses various other issues:
* Fixes a bug where names weren't being simplified fully in the presence of nested models (i.e., you'd get separate Input and Output schemas for an outer model even if the inner model had the same Input and Output schema, now you don't)
* Fixes a bug where... | 2023-07-03T21:31:46Z | Nested models created with `create_model` with same name results in key error
### Initial Checks
- [X] I confirm that I'm using Pydantic V2 installed directly from the `main` branch, or equivalent
### Description
When using the same model name in `create_model` as an inner model (dynamic or static) this results in a... | Thanks for reporting, confirmed.
@dmontagu as the king of JSON Schema, could you take a look. If you don't have time, feel free to assign back to me and I can have a dig. | [
{
"body": "### Initial Checks\n\n- [X] I confirm that I'm using Pydantic V2 installed directly from the `main` branch, or equivalent\n\n### Description\n\nWhen using the same model name in `create_model` as an inner model (dynamic or static) this results in a key error when creating the JSON schema:\r\n```\r\nT... | 827f258daf8e0e248faee0a4793cb0c278da5321 | {
"head_commit": "bde5ace9bb3751b058184a6db4126f519190c5a1",
"head_commit_message": "Rework how JSON schema refs get built/simplified",
"patch_to_review": "diff --git a/pydantic/json_schema.py b/pydantic/json_schema.py\nindex aaab7508c76..15784385e81 100644\n--- a/pydantic/json_schema.py\n+++ b/pydantic/json_sche... | [
{
"diff_hunk": "@@ -120,6 +122,91 @@ class PydanticJsonSchemaWarning(UserWarning):\n JsonSchemaKeyT = TypeVar('JsonSchemaKeyT', bound=Hashable)\n \n \n+@_internal_dataclass.slots_dataclass\n+class _DefinitionsRemapping:\n+ defs_remapping: dict[DefsRef, DefsRef]\n+ json_remapping: dict[JsonRef, JsonRef]\n+... | 1763af48a7737ffaaba6d784053aa57a4408c53b | diff --git a/pydantic/json_schema.py b/pydantic/json_schema.py
index c5e8dddd22b..28815b9c965 100644
--- a/pydantic/json_schema.py
+++ b/pydantic/json_schema.py
@@ -5,6 +5,8 @@
import math
import re
import warnings
+from collections import defaultdict
+from copy import deepcopy
from dataclasses import is_dataclass
... | {
"difficulty": "high",
"estimated_review_effort": 4,
"problem_domain": "Bug Fixes"
} |
pydantic__pydantic-6382@f16264d | pydantic/pydantic | Python | 6,382 | 🐛 Don't call `repr()` on qualname retrieval | - Closes #6368
Selected Reviewer: @dmontagu | 2023-07-03T11:14:44Z | Super class variables no longer available to subclasses
### Initial Checks
- [X] I confirm that I'm using Pydantic V2 installed directly from the `main` branch, or equivalent
### Description
Hi, I have an issue with accessing variables in a superclass from a base class. I added an example code in the section b... | It seems like `__repr__` is getting called one the type itself?
```python
from pydantic import validate_call
class Class:
@validate_call
def __init__(self, number: int) -> None:
assert False, 'init'
def __repr__(self) -> str:
assert False, 'repr'
Class(50) #> AssertionErro... | [
{
"body": "### Initial Checks\r\n\r\n- [X] I confirm that I'm using Pydantic V2 installed directly from the `main` branch, or equivalent\r\n\r\n### Description\r\n\r\nHi, I have an issue with accessing variables in a superclass from a base class. I added an example code in the section below.\r\n\r\nWhenever I r... | 0ed48ae141e2a50694bc57ee356bdac13c4af406 | {
"head_commit": "f16264d29acb8d52d6ca615afa92dd633d09d2a2",
"head_commit_message": "🐛 Don't call `repr()` on qualname retrieval",
"patch_to_review": "diff --git a/pydantic/_internal/_core_utils.py b/pydantic/_internal/_core_utils.py\nindex e1c1a74bedc..55f6e9de539 100644\n--- a/pydantic/_internal/_core_utils.py... | [
{
"diff_hunk": "@@ -83,7 +83,7 @@ def get_type_ref(type_: type[Any], args_override: tuple[type[Any], ...] | None =\n if isinstance(origin, TypeAliasType):\n type_ref = f'{module_name}.{origin.__name__}'\n else:\n- qualname = getattr(origin, '__qualname__', f'<No __qualname__: {origin}>')\... | deafa14a9a1a5c7b4688994e647de0ca6324bd90 | diff --git a/pydantic/_internal/_core_utils.py b/pydantic/_internal/_core_utils.py
index e1c1a74bedc..97a0aab361a 100644
--- a/pydantic/_internal/_core_utils.py
+++ b/pydantic/_internal/_core_utils.py
@@ -83,7 +83,10 @@ def get_type_ref(type_: type[Any], args_override: tuple[type[Any], ...] | None =
if isinstance(... | {
"difficulty": "low",
"estimated_review_effort": 2,
"problem_domain": "Bug Fixes"
} |
pydantic__pydantic-6283@3fbb65b | pydantic/pydantic | Python | 6,283 | 🐛 Fix `RootModel.construct()` and `RootModel.__init__()` results aren't equal | ## Change Summary
Add `RootModel` specific logic to `BaseModel.construct()`
## Related issue number
Fixes #6195
## Checklist
* [x] Unit tests for the changes exist
* [x] Tests pass on CI and coverage remains at 100%
* [ ] Documentation reflects the changes where applicable
* [ ] `changes/<pull reques... | 2023-06-28T12:28:44Z | Result of `RootModel.model_construct` is not equal to result of `RootModel.__init__`
### Initial Checks
- [X] I confirm that I'm using Pydantic V2 installed directly from the `main` branch, or equivalent
### Description
Creating an instance of `RootModel` is not equal to the result of `RootModel.model_construct` cal... | [
{
"body": "### Initial Checks\n\n- [X] I confirm that I'm using Pydantic V2 installed directly from the `main` branch, or equivalent\n\n### Description\n\nCreating an instance of `RootModel` is not equal to the result of `RootModel.model_construct` called with the same valid values of a proper type.\r\n\r\nThis... | a29286609e79c79b2ecd71bc7272eea43ed9fccd | {
"head_commit": "3fbb65ba3d923643e5002ba0728708eeb7cba9fe",
"head_commit_message": "🐛 Fix `RootModel.construct()` and `RootModel.__init__()` results aren't equal",
"patch_to_review": "diff --git a/pydantic/main.py b/pydantic/main.py\nindex 9150390fc8d..5e12b8ab07e 100644\n--- a/pydantic/main.py\n+++ b/pydantic/... | [
{
"diff_hunk": "@@ -310,6 +310,9 @@ def test_root_model_equality():\n assert RootModel[int](42) == RootModel[int](42)\n assert RootModel[int](42) != RootModel[int](7)\n assert RootModel[int](42) != RootModel[float](42)\n+ print('***', vars(RootModel[int](42)))\n+ print('***', vars(RootModel[in... | a8c9bf79e4f06aa348f70b858704b989d7ecad1d | diff --git a/pydantic/main.py b/pydantic/main.py
index 9150390fc8d..5e12b8ab07e 100644
--- a/pydantic/main.py
+++ b/pydantic/main.py
@@ -213,11 +213,12 @@ def model_construct(cls: type[Model], _fields_set: set[str] | None = None, **val
fields_values.update(values)
_object_setattr(m, '__dict__', fi... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} | |
pydantic__pydantic-6104@7df3c14 | pydantic/pydantic | Python | 6,104 | 🐛 Fix RootModel json schema meta info | ## Change Summary
Fix RootModel metadata handling
## Related issue number
Fixes #6000
## Checklist
* [X] Unit tests for the changes exist
* [x] Tests pass on CI and coverage remains at 100%
* [ ] Documentation reflects the changes where applicable
* [ ] `changes/<pull request or issue id>-<github use... | 2023-06-13T08:18:56Z | RootModel's `model_json_schema` miss field `title` and `description`
### Initial Checks
- [X] I confirm that I'm using Pydantic V2 installed directly from the `main` branch, or equivalent
### Description
`SelloutList` expects a title named `SelloutList`, but gets a `None`
By default, we should use the name of the... | Thanks @luolingchun for reporting this.
I can confirm the problem. | [
{
"body": "### Initial Checks\n\n- [X] I confirm that I'm using Pydantic V2 installed directly from the `main` branch, or equivalent\n\n### Description\n\n`SelloutList` expects a title named `SelloutList`, but gets a `None`\r\n\r\nBy default, we should use the name of the class as the title and the document of ... | 493be96bb627edc9a665be52569ee14d5febb374 | {
"head_commit": "7df3c148cabbe176fdf6aa14c7368dda174329e6",
"head_commit_message": "Update test",
"patch_to_review": "diff --git a/docs/usage/models.md b/docs/usage/models.md\nindex 87c9cbe81a7..991ae3de20d 100644\n--- a/docs/usage/models.md\n+++ b/docs/usage/models.md\n@@ -884,7 +884,7 @@ print(Pets(['dog', 'ca... | [
{
"diff_hunk": "@@ -157,9 +157,19 @@ def modify_model_json_schema(\n json_schema = handler(schema_or_field)\n original_schema = handler.resolve_ref_schema(json_schema)\n if 'title' not in original_schema:\n+ # Preserve the fact that definitions schemas should never have sibling keys:\n+ ... | 14d1ae7e5929eb6e58bbf9e870e2665b7894fd64 | diff --git a/docs/usage/models.md b/docs/usage/models.md
index 87c9cbe81a7..991ae3de20d 100644
--- a/docs/usage/models.md
+++ b/docs/usage/models.md
@@ -884,7 +884,7 @@ print(Pets(['dog', 'cat']).model_dump_json())
print(Pets.model_validate(['dog', 'cat']))
#> root=['dog', 'cat']
print(Pets.model_json_schema())
-#> ... | {
"difficulty": "medium",
"estimated_review_effort": 3,
"problem_domain": "Bug Fixes"
} |
pydantic__pydantic-6115@faa1d4a | pydantic/pydantic | Python | 6,115 | Fix extra fields behavior for TypedDict and make additionalProperties explicit in JSON schema | Closes #6082
Selected Reviewer: @Kludex | 2023-06-13T14:04:47Z | explicit additionalProperties even when model_config["extra"] != "forbid"
### Initial Checks
- [X] I confirm that I'm using Pydantic V2 installed directly from the `main` branch, or equivalent
### Description
Currently additionalProperties in the model_schema is only set for "forbid".
Due to the evaluation of mis... | I would rather not add `additionalProperties` for ignore because we will never return extra properties, and if we did it only for validation mode (and not serialization mode) it would mean the vast majority of models would have different schemas for validation and serialization, which isn't ideal. And because we are th... | [
{
"body": "### Initial Checks\n\n- [X] I confirm that I'm using Pydantic V2 installed directly from the `main` branch, or equivalent\n\n### Description\n\nCurrently additionalProperties in the model_schema is only set for \"forbid\". \r\nDue to the evaluation of missing values to True is this correct, but I pr... | b2f9f9bbfd08fa5ca6cf1e053745ec0a0877b54e | {
"head_commit": "faa1d4a7134eb15d9182297c3d2fb6e9c42a5cbd",
"head_commit_message": "Remove mode logic:",
"patch_to_review": "diff --git a/docs/usage/models.md b/docs/usage/models.md\nindex e2c67b1f437..5a5a690c03e 100644\n--- a/docs/usage/models.md\n+++ b/docs/usage/models.md\n@@ -791,11 +791,9 @@ try:\n except ... | [
{
"diff_hunk": "@@ -962,19 +971,26 @@ def model_schema(self, schema: core_schema.ModelSchema) -> JsonSchemaValue:\n cls = cast('type[BaseModel]', schema['cls'])\n config = cls.model_config\n title = config.get('title')\n- forbid_additional_properties = config.get('extra') == 'forb... | efd91df612bf615fce7ba32d6361816e27ef460c | diff --git a/docs/usage/models.md b/docs/usage/models.md
index e2c67b1f437..5a5a690c03e 100644
--- a/docs/usage/models.md
+++ b/docs/usage/models.md
@@ -791,11 +791,9 @@ try:
except ValidationError as e:
print(e)
"""
- 2 validation errors for list[typed-dict]
+ 1 validation error for list[typed-dict]
... | {
"difficulty": "medium",
"estimated_review_effort": 4,
"problem_domain": "Code Refactoring / Architectural Improvement"
} |
Subsets and Splits
Review Test Instances
Retrieves basic metadata about code review instances but doesn't provide any analytical insights or patterns beyond raw data access.