Run overview
swe_bench / lite / dev
Run 53985d1a...f010
Benchmark pass rate
25%
1 of 4 tasks passed
Pass rate is the share of benchmark tasks that passed.
Passed
1
Tasks that passed
Failed
3
Tasks that failed
Total spend
$0.90
Duration 758 s
Task review
Completed tasks
4 completed tasks. Open a card only when you need logs, patch text, or scoring detail.
pvlib__pvlib-python-1154
pvlib/pvlib-python
Score
0%
Outcome
Error
Task cost
$0.00
Duration
0 ms
Summary
Error
DaytonaError: Failed to execute command: request timeout: command execution timeout
View task details
Run metadata
Benchmark
swe_bench/lite/dev
Model
Not reported
Started
Mar 31, 2026, 2:09 AM UTC
Completed
Mar 31, 2026, 2:19 AM UTC
Sandbox
Not provisioned yet
Tokens
Not reported
F2P / P2P
Pending
Passed benchmark
Pending
Task failed
Benchmark context
Task input
pvlib.irradiance.reindl() model generates NaNs when GHI = 0 **Describe the bug** The reindl function should give zero sky diffuse when GHI is zero. Instead it generates NaN or Inf values due to "term3" having a quotient that divides by GHI. **Expected behavior** The reindl function should result in zero sky diffuse when GHI is zero. pvlib.irradiance.reindl() model generates NaNs when GHI = 0 **Describe the bug** The reindl function should give zero sky diffuse when GHI is zero. Instead it generates NaN or Inf values due to "term3" having a quotient that divides by GHI. **Expected behavior** The reindl function should result in zero sky diffuse when GHI is zero.
Fix tests
pvlib/tests/test_irradiance.py::test_reindl
Regression tests
pvlib/tests/test_irradiance.py::test_get_extra_radiation[asce-300-1383.636203] pvlib/tests/test_irradiance.py::test_get_extra_radiation[asce-300.0-1383.636203] pvlib/tests/test_irradiance.py::test_get_extra_radiation[asce-testval2-1383.636203] pvlib/tests/test_irradiance.py::test_get_extra_radiation[asce-testval3-1383.636203] pvlib/tests/test_irradiance.py::test_get_extra_radiation[asce-testval4-1383.636203] pvlib/tests/test_irradiance.py::test_get_extra_radiation[asce-testval5-expected5] pvlib/tests/test_irradiance.py::test_get_extra_radiation[asce-testval6-expected6] pvlib/tests/test_irradiance.py::test_get_extra_radiation[asce-testval7-expected7] pvlib/tests/test_irradiance.py::test_get_extra_radiation[asce-testval8-1383.636203] pvlib/tests/test_irradiance.py::test_get_extra_radiation[spencer-300-1383.636203] pvlib/tests/test_irradiance.py::test_get_extra_radiation[spencer-300.0-1383.636203] pvlib/tests/test_irradiance.py::test_get_extra_radiation[spencer-testval2-1383.636203] pvlib/tests/test_irradiance.py::test_get_extra_radiation[spencer-testval3-1383.636203] pvlib/tests/test_irradiance.py::test_get_extra_radiation[spencer-testval4-1383.636203] pvlib/tests/test_irradiance.py::test_get_extra_radiation[spencer-testval5-expected5] pvlib/tests/test_irradiance.py::test_get_extra_radiation[spencer-testval6-expected6] pvlib/tests/test_irradiance.py::test_get_extra_radiation[spencer-testval7-expected7] pvlib/tests/test_irradiance.py::test_get_extra_radiation[spencer-testval8-1383.636203] pvlib/tests/test_irradiance.py::test_get_extra_radiation[nrel-300-1383.636203] pvlib/tests/test_irradiance.py::test_get_extra_radiation[nrel-300.0-1383.636203] pvlib/tests/test_irradiance.py::test_get_extra_radiation[nrel-testval2-1383.636203] pvlib/tests/test_irradiance.py::test_get_extra_radiation[nrel-testval3-1383.636203] pvlib/tests/test_irradiance.py::test_get_extra_radiation[nrel-testval4-1383.636203] pvlib/tests/test_irradiance.py::test_get_extra_radiation[nrel-testval5-expected5] pvlib/tests/test_irradiance.py::test_get_extra_radiation[nrel-testval6-expected6] pvlib/tests/test_irradiance.py::test_get_extra_radiation[nrel-testval7-expected7] pvlib/tests/test_irradiance.py::test_get_extra_radiation[nrel-testval8-1383.636203] pvlib/tests/test_irradiance.py::test_get_extra_radiation[pyephem-300-1383.636203] pvlib/tests/test_irradiance.py::test_get_extra_radiation[pyephem-300.0-1383.636203] pvlib/tests/test_irradiance.py::test_get_extra_radiation[pyephem-testval2-1383.636203] pvlib/tests/test_irradiance.py::test_get_extra_radiation[pyephem-testval3-1383.636203] pvlib/tests/test_irradiance.py::test_get_extra_radiation[pyephem-testval4-1383.636203] pvlib/tests/test_irradiance.py::test_get_extra_radiation[pyephem-testval5-expected5] pvlib/tests/test_irradiance.py::test_get_extra_radiation[pyephem-testval6-expected6] pvlib/tests/test_irradiance.py::test_get_extra_radiation[pyephem-testval7-expected7] pvlib/tests/test_irradiance.py::test_get_extra_radiation[pyephem-testval8-1383.636203] pvlib/tests/test_irradiance.py::test_get_extra_radiation_epoch_year pvlib/tests/test_irradiance.py::test_get_extra_radiation_nrel_numba pvlib/tests/test_irradiance.py::test_get_extra_radiation_invalid pvlib/tests/test_irradiance.py::test_grounddiffuse_simple_float pvlib/tests/test_irradiance.py::test_grounddiffuse_simple_series pvlib/tests/test_irradiance.py::test_grounddiffuse_albedo_0 pvlib/tests/test_irradiance.py::test_grounddiffuse_albedo_invalid_surface pvlib/tests/test_irradiance.py::test_grounddiffuse_albedo_surface pvlib/tests/test_irradiance.py::test_isotropic_float pvlib/tests/test_irradiance.py::test_isotropic_series pvlib/tests/test_irradiance.py::test_klucher_series_float pvlib/tests/test_irradiance.py::test_klucher_series pvlib/tests/test_irradiance.py::test_haydavies pvlib/tests/test_irradiance.py::test_king pvlib/tests/test_irradiance.py::test_perez pvlib/tests/test_irradiance.py::test_perez_components pvlib/tests/test_irradiance.py::test_perez_arrays pvlib/tests/test_irradiance.py::test_perez_scalar pvlib/tests/test_irradiance.py::test_sky_diffuse_zenith_close_to_90[isotropic] pvlib/tests/test_irradiance.py::test_sky_diffuse_zenith_close_to_90[klucher] pvlib/tests/test_irradiance.py::test_sky_diffuse_zenith_close_to_90[haydavies] pvlib/tests/test_irradiance.py::test_sky_diffuse_zenith_close_to_90[reindl] pvlib/tests/test_irradiance.py::test_sky_diffuse_zenith_close_to_90[king] pvlib/tests/test_irradiance.py::test_sky_diffuse_zenith_close_to_90[perez] pvlib/tests/test_irradiance.py::test_get_sky_diffuse_invalid pvlib/tests/test_irradiance.py::test_campbell_norman pvlib/tests/test_irradiance.py::test_get_total_irradiance pvlib/tests/test_irradiance.py::test_get_total_irradiance_scalars[isotropic] pvlib/tests/test_irradiance.py::test_get_total_irradiance_scalars[klucher] pvlib/tests/test_irradiance.py::test_get_total_irradiance_scalars[haydavies] pvlib/tests/test_irradiance.py::test_get_total_irradiance_scalars[reindl] pvlib/tests/test_irradiance.py::test_get_total_irradiance_scalars[king] pvlib/tests/test_irradiance.py::test_get_total_irradiance_scalars[perez] pvlib/tests/test_irradiance.py::test_poa_components pvlib/tests/test_irradiance.py::test_disc_value[93193-expected0] pvlib/tests/test_irradiance.py::test_disc_value[None-expected1] pvlib/tests/test_irradiance.py::test_disc_value[101325-expected2] pvlib/tests/test_irradiance.py::test_disc_overirradiance pvlib/tests/test_irradiance.py::test_disc_min_cos_zenith_max_zenith pvlib/tests/test_irradiance.py::test_dirint_value pvlib/tests/test_irradiance.py::test_dirint_nans pvlib/tests/test_irradiance.py::test_dirint_tdew pvlib/tests/test_irradiance.py::test_dirint_no_delta_kt pvlib/tests/test_irradiance.py::test_dirint_coeffs pvlib/tests/test_irradiance.py::test_dirint_min_cos_zenith_max_zenith pvlib/tests/test_irradiance.py::test_gti_dirint pvlib/tests/test_irradiance.py::test_erbs pvlib/tests/test_irradiance.py::test_erbs_min_cos_zenith_max_zenith pvlib/tests/test_irradiance.py::test_erbs_all_scalar pvlib/tests/test_irradiance.py::test_dirindex pvlib/tests/test_irradiance.py::test_dirindex_min_cos_zenith_max_zenith pvlib/tests/test_irradiance.py::test_dni pvlib/tests/test_irradiance.py::test_aoi_and_aoi_projection[0-0-0-0-0-1] pvlib/tests/test_irradiance.py::test_aoi_and_aoi_projection[30-180-30-180-0-1] pvlib/tests/test_irradiance.py::test_aoi_and_aoi_projection[30-180-150-0-180--1] pvlib/tests/test_irradiance.py::test_aoi_and_aoi_projection[90-0-30-60-75.5224878-0.25] pvlib/tests/test_irradiance.py::test_aoi_and_aoi_projection[90-0-30-170-119.4987042--0.4924038] pvlib/tests/test_irradiance.py::test_kt_kt_prime_factor pvlib/tests/test_irradiance.py::test_clearsky_index pvlib/tests/test_irradiance.py::test_clearness_index pvlib/tests/test_irradiance.py::test_clearness_index_zenith_independent
Execution
Scorer detail
DaytonaError: Failed to execute command: request timeout: command execution timeout
Patch text
No patch captured yet.
Stdout
No stdout captured yet.
Stderr
No stderr captured yet.
Agent output
No agent output captured yet.
Scoring
Passing target tests
No fail-to-pass successes recorded yet.
Failing target tests
No fail-to-pass failures recorded yet.
Maintained regression tests
No pass-to-pass successes recorded yet.
Regressed tests
No regression failures recorded yet.
Harness output
No harness output captured yet.
Reference output
diff --git a/pvlib/irradiance.py b/pvlib/irradiance.py
--- a/pvlib/irradiance.py
+++ b/pvlib/irradiance.py
@@ -886,8 +886,9 @@ def reindl(surface_tilt, surface_azimuth, dhi, dni, ghi, dni_extra,
# these are the () and [] sub-terms of the second term of eqn 8
term1 = 1 - AI
term2 = 0.5 * (1 + tools.cosd(surface_tilt))
- term3 = 1 + np.sqrt(HB / ghi) * (tools.sind(0.5 * surface_tilt) ** 3)
-
+ with np.errstate(invalid='ignore', divide='ignore'):
+ hb_to_ghi = np.where(ghi == 0, 0, np.divide(HB, ghi))
+ term3 = 1 + np.sqrt(hb_to_ghi) * (tools.sind(0.5 * surface_tilt)**3)
sky_diffuse = dhi * (AI * Rb + term1 * term2 * term3)
sky_diffuse = np.maximum(sky_diffuse, 0)
pvlib__pvlib-python-1072
pvlib/pvlib-python
Score
0%
Outcome
Did not pass
Task cost
$0.28
Duration
129 s
Summary
Did not pass
Not resolved by official SWE-bench grading. Fail-to-pass: 0%. Pass-to-pass: 0%.
View task details
Run metadata
Benchmark
swe_bench/lite/dev
Model
claude-sonnet-4-5-20250929
Started
Mar 31, 2026, 2:09 AM UTC
Completed
Mar 31, 2026, 2:11 AM UTC
Sandbox
d9e94bdb-84e4-471a-9409-9306300c33b0
Tokens
In 20,016 / out 8,192
F2P / P2P
0% / 0%
Passed benchmark
No
Completed
m sphinxcontrib-websupport->sphinx==1.8.5->pvlib==0.8.0+3.gdc81df7.dirty) (2.0.0)
Requirement already satisfied: executing>=1.2.0 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from stack-data->ipython->pvlib==0.8.0+3.gdc81df7.dirty) (2.2.0)
Requirement already satisfied: asttokens>=2.1.0 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from stack-data->ipython->pvlib==0.8.0+3.gdc81df7.dirty) (3.0.0)
Requirement already satisfied: pure-eval in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from stack-data->ipython->pvlib==0.8.0+3.gdc81df7.dirty) (0.2.3)
Requirement already satisfied: patsy>=0.5.6 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from statsmodels->pvlib==0.8.0+3.gdc81df7.dirty) (1.0.1)
Requirement already satisfied: numexpr>=2.6.2 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from tables->pvlib==0.8.0+3.gdc81df7.dirty) (2.10.1)
Requirement already satisfied: py-cpuinfo in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from tables->pvlib==0.8.0+3.gdc81df7.dirty) (9.0.0)
Requirement already satisfied: blosc2>=2.3.0 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from tables->pvlib==0.8.0+3.gdc81df7.dirty) (2.5.1)
Requirement already satisfied: ndindex>=1.4 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from blosc2>=2.3.0->tables->pvlib==0.8.0+3.gdc81df7.dirty) (1.9.2)
Requirement already satisfied: msgpack in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from blosc2>=2.3.0->tables->pvlib==0.8.0+3.gdc81df7.dirty) (1.1.0)
Installing collected packages: pvlib
Attempting uninstall: pvlib
Found existing installation: pvlib 0.8.0+2.g04a523f
Uninstalling pvlib-0.8.0+2.g04a523f:
Successfully uninstalled pvlib-0.8.0+2.g04a523f
DEPRECATION: Legacy editable install of pvlib[all]==0.8.0+3.gdc81df7.dirty from file:///testbed (setup.py develop) is deprecated. pip 25.3 will enforce this behaviour change. A possible replacement is to add a pyproject.toml or enable --use-pep517, and use setuptools >= 64. If the resulting installation is not behaving as expected, try using --config-settings editable_mode=compat. Please consult the setuptools documentation for more information. Discussion can be found at https://github.com/pypa/pip/issues/11457
Running setup.py develop for pvlib
Successfully installed pvlib
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager, possibly rendering your system unusable. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv. Use the --root-user-action option if you know what you are doing and want to suppress this warning.
+ git checkout 04a523fafbd61bc2e49420963b84ed8e2bd1b3cf pvlib/tests/test_temperature.py
Updated 0 paths from 6b8d479
+ git apply -v -
Checking patch pvlib/tests/test_temperature.py...
Applied patch pvlib/tests/test_temperature.py cleanly.
+ : '>>>>> Start Test Output'
+ pytest -rA pvlib/tests/test_temperature.py
ImportError while loading conftest '/testbed/pvlib/tests/conftest.py'.
pvlib/tests/conftest.py:10: in <module>
import pvlib
pvlib/__init__.py:10: in <module>
from pvlib import ivtools # noqa: F401
pvlib/ivtools/__init__.py:7: in <module>
from pvlib.ivtools import sde, sdm, utils # noqa: F401
pvlib/ivtools/sdm.py:15: in <module>
from pvlib.pvsystem import singlediode, v_from_i
pvlib/pvsystem.py:16: in <module>
from pvlib import (atmosphere, iam, inverter, irradiance,
pvlib/singlediode.py:59: in <module>
NsVbi=np.Inf, breakdown_factor=0., breakdown_voltage=-5.5,
/opt/miniconda3/envs/testbed/lib/python3.9/site-packages/numpy/__init__.py:397: in __getattr__
raise AttributeError(
E AttributeError: `np.Inf` was removed in the NumPy 2.0 release. Use `np.inf` instead.
+ : '>>>>> End Test Output'
+ git checkout 04a523fafbd61bc2e49420963b84ed8e2bd1b3cf pvlib/tests/test_temperature.py
Updated 1 path from 6b8d479
Open in DaytonaBenchmark context
Task input
temperature.fuentes errors when given tz-aware inputs on pandas>=1.0.0
**Describe the bug**
When the weather timeseries inputs to `temperature.fuentes` have tz-aware index, an internal call to `np.diff(index)` returns an array of `Timedelta` objects instead of an array of nanosecond ints, throwing an error immediately after. The error only happens when using pandas>=1.0.0; using 0.25.3 runs successfully, but emits the warning:
```
/home/kevin/anaconda3/envs/pvlib-dev/lib/python3.7/site-packages/numpy/lib/function_base.py:1243: FutureWarning: Converting timezone-aware DatetimeArray to timezone-naive ndarray with 'datetime64[ns]' dtype. In the future, this will return an ndarray with 'object' dtype where each element is a 'pandas.Timestamp' with the correct 'tz'.
To accept the future behavior, pass 'dtype=object'.
To keep the old behavior, pass 'dtype="datetime64[ns]"'.
a = asanyarray(a)
```
**To Reproduce**
```python
In [1]: import pvlib
...: import pandas as pd
...:
...: index_naive = pd.date_range('2019-01-01', freq='h', periods=3)
...:
...: kwargs = {
...: 'poa_global': pd.Series(1000, index_naive),
...: 'temp_air': pd.Series(20, index_naive),
...: 'wind_speed': pd.Series(1, index_naive),
...: 'noct_installed': 45
...: }
...:
In [2]: print(pvlib.temperature.fuentes(**kwargs))
2019-01-01 00:00:00 47.85
2019-01-01 01:00:00 50.85
2019-01-01 02:00:00 50.85
Freq: H, Name: tmod, dtype: float64
In [3]: kwargs['poa_global'].index = index_naive.tz_localize('UTC')
...: print(pvlib.temperature.fuentes(**kwargs))
...:
Traceback (most recent call last):
File "<ipython-input-3-ff99badadc91>", line 2, in <module>
print(pvlib.temperature.fuentes(**kwargs))
File "/home/kevin/anaconda3/lib/python3.7/site-packages/pvlib/temperature.py", line 602, in fuentes
timedelta_hours = np.diff(poa_global.index).astype(float) / 1e9 / 60 / 60
TypeError: float() argument must be a string or a number, not 'Timedelta'
```
**Expected behavior**
`temperature.fuentes` should work with both tz-naive and tz-aware inputs.
**Versions:**
- ``pvlib.__version__``: 0.8.0
- ``pandas.__version__``: 1.0.0+
- python: 3.7.4 (default, Aug 13 2019, 20:35:49) \n[GCC 7.3.0]
Fix tests
pvlib/tests/test_temperature.py::test_fuentes_timezone[Etc/GMT+5]
Regression tests
pvlib/tests/test_temperature.py::test_sapm_cell pvlib/tests/test_temperature.py::test_sapm_module pvlib/tests/test_temperature.py::test_sapm_cell_from_module pvlib/tests/test_temperature.py::test_sapm_ndarray pvlib/tests/test_temperature.py::test_sapm_series pvlib/tests/test_temperature.py::test_pvsyst_cell_default pvlib/tests/test_temperature.py::test_pvsyst_cell_kwargs pvlib/tests/test_temperature.py::test_pvsyst_cell_ndarray pvlib/tests/test_temperature.py::test_pvsyst_cell_series pvlib/tests/test_temperature.py::test_faiman_default pvlib/tests/test_temperature.py::test_faiman_kwargs pvlib/tests/test_temperature.py::test_faiman_list pvlib/tests/test_temperature.py::test_faiman_ndarray pvlib/tests/test_temperature.py::test_faiman_series pvlib/tests/test_temperature.py::test__temperature_model_params pvlib/tests/test_temperature.py::test_fuentes[pvwatts_8760_rackmount.csv-45] pvlib/tests/test_temperature.py::test_fuentes[pvwatts_8760_roofmount.csv-49] pvlib/tests/test_temperature.py::test_fuentes_timezone[None]
Execution
Scorer detail
Not resolved by official SWE-bench grading. Fail-to-pass: 0%. Pass-to-pass: 0%.
Patch text
diff --git a/pvlib/temperature.py b/pvlib/temperature.py
index 1d98736..6ac4533 100644
--- a/pvlib/temperature.py
+++ b/pvlib/temperature.py
@@ -367,293 +367,4 @@ def pvsyst_cell(poa_global, temp_air, wind_speed=1.0, u_c=29.0, u_v=0.0,
>>> params = TEMPERATURE_MODEL_PARAMETERS['pvsyst']['freestanding']
>>> pvsyst_cell(1000, 10, **params)
37.93103448275862
- """
-
- total_loss_factor = u_c + u_v * wind_speed
- heat_input = poa_global * alpha_absorption * (1 - eta_m)
- temp_difference = heat_input / total_loss_factor
- return temp_air + temp_difference
-
-
-def faiman(poa_global, temp_air, wind_speed=1.0, u0=25.0, u1=6.84):
- r'''
- Calculate cell or module temperature using the Faiman model. The Faiman
- model uses an empirical heat loss factor model [1]_ and is adopted in the
- IEC 61853 standards [2]_ and [3]_.
-
- Usage of this model in the IEC 61853 standard does not distinguish
- between cell and module temperature.
-
- Parameters
- ----------
- poa_global : numeric
- Total incident irradiance [W/m^2].
-
- temp_air : numeric
- Ambient dry bulb temperature [C].
-
- wind_speed : numeric, default 1.0
- Wind speed in m/s measured at the same height for which the wind loss
- factor was determined. The default value 1.0 m/s is the wind
- speed at module height used to determine NOCT. [m/s]
-
- u0 : numeric, default 25.0
- Combined heat loss factor coefficient. The default value is one
- determined by Faiman for 7 silicon modules.
- :math:`\left[\frac{\text{W}/{\text{m}^2}}{\text{C}}\right]`
-
- u1 : numeric, default 6.84
- Combined heat loss factor influenced by wind. The default value is one
- determined by Faiman for 7 silicon modules.
- :math:`\left[ \frac{\text{W}/\text{m}^2}{\text{C}\ \left( \text{m/s} \right)} \right]`
-
- Returns
- -------
- numeric, values in degrees Celsius
-
- Notes
- -----
- All arguments may be scalars or vectors. If multiple arguments
- are vectors they must be the same length.
-
- References
- ----------
- .. [1] Faiman, D. (2008). "Assessing the outdoor operating temperature of
- photovoltaic modules." Progress in Photovoltaics 16(4): 307-315.
-
- .. [2] "IEC 61853-2 Photovoltaic (PV) module performance testing and energy
- rating - Part 2: Spectral responsivity, incidence angle and module
- operating temperature measurements". IEC, Geneva, 2018.
-
- .. [3] "IEC 61853-3 Photovoltaic (PV) module performance testing and energy
- rating - Part 3: Energy rating of PV modules". IEC, Geneva, 2018.
-
- '''
- # Contributed by Anton Driesse (@adriesse), PV Performance Labs. Dec., 2019
-
- # The following lines may seem odd since u0 & u1 are probably scalar,
- # but it serves an indirect and easy way of allowing lists and
- # tuples for the other function arguments.
- u0 = np.asanyarray(u0)
- u1 = np.asanyarray(u1)
-
- total_loss_factor = u0 + u1 * wind_speed
- heat_input = poa_global
- temp_difference = heat_input / total_loss_factor
- return temp_air + temp_difference
-
-
-def _fuentes_hconv(tave, windmod, tinoct, temp_delta, xlen, tilt,
- check_reynold):
- # Calculate the convective coefficient as in Fuentes 1987 -- a mixture of
- # free, laminar, and turbulent convection.
- densair = 0.003484 * 101325.0 / tave # density
- visair = 0.24237e-6 * tave**0.76 / densair # kinematic viscosity
- condair = 2.1695e-4 * tave**0.84 # thermal conductivity
- reynold = windmod * xlen / visair
- # the boundary between laminar and turbulent is modeled as an abrupt
- # change at Re = 1.2e5:
- if check_reynold and reynold > 1.2e5:
- # turbulent convection
- hforce = 0.0282 / reynold**0.2 * densair * windmod * 1007 / 0.71**0.4
- else:
- # laminar convection
- hforce = 0.8600 / reynold**0.5 * densair * windmod * 1007 / 0.71**0.67
- # free convection via Grashof number
- # NB: Fuentes hardwires sind(tilt) as 0.5 for tilt=30
- grashof = 9.8 / tave * temp_delta * xlen**3 / visair**2 * sind(tilt)
- # product of Nusselt number and (k/l)
- hfree = 0.21 * (grashof * 0.71)**0.32 * condair / xlen
- # combine free and forced components
- hconv = (hfree**3 + hforce**3)**(1/3)
- return hconv
-
-
-def _hydraulic_diameter(width, height):
- # calculate the hydraulic diameter of a rectangle
- return 2 * (width * height) / (width + height)
-
-
-def fuentes(poa_global, temp_air, wind_speed, noct_installed, module_height=5,
- wind_height=9.144, emissivity=0.84, absorption=0.83,
- surface_tilt=30, module_width=0.31579, module_length=1.2):
- """
- Calculate cell or module temperature using the Fuentes model.
-
- The Fuentes model is a first-principles heat transfer energy balance
- model [1]_ that is used in PVWatts for cell temperature modeling [2]_.
-
- Parameters
- ----------
- poa_global : pandas Series
- Total incident irradiance [W/m^2]
-
- temp_air : pandas Series
- Ambient dry bulb temperature [C]
-
- wind_speed : pandas Series
- Wind speed [m/s]
-
- noct_installed : float
- The "installed" nominal operating cell temperature as defined in [1]_.
- PVWatts assumes this value to be 45 C for rack-mounted arrays and
- 49 C for roof mount systems with restricted air flow around the
- module. [C]
-
- module_height : float, default 5.0
- The height above ground of the center of the module. The PVWatts
- default is 5.0 [m]
-
- wind_height : float, default 9.144
- The height above ground at which ``wind_speed`` is measured. The
- PVWatts defauls is 9.144 [m]
-
- emissivity : float, default 0.84
- The effectiveness of the module at radiating thermal energy. [unitless]
-
- absorption : float, default 0.83
- The fraction of incident irradiance that is converted to thermal
- energy in the module. [unitless]
-
- surface_tilt : float, default 30
- Module tilt from horizontal. If not provided, the default value
- of 30 degrees from [1]_ and [2]_ is used. [degrees]
-
- module_width : float, default 0.31579
- Module width. The default value of 0.31579 meters in combination with
- the default `module_length` gives a hydraulic diameter of 0.5 as
- assumed in [1]_ and [2]_. [m]
-
- module_length : float, default 1.2
- Module length. The default value of 1.2 meters in combination with
- the default `module_width` gives a hydraulic diameter of 0.5 as
- assumed in [1]_ and [2]_. [m]
-
- Returns
- -------
- temperature_cell : pandas Series
- The modeled cell temperature [C]
-
- Notes
- -----
- This function returns slightly different values from PVWatts at night
- and just after dawn. This is because the SAM SSC assumes that module
- temperature equals ambient temperature when irradiance is zero so it can
- skip the heat balance calculation at night.
-
- References
- ----------
- .. [1] Fuentes, M. K., 1987, "A Simplifed Thermal Model for Flat-Plate
- Photovoltaic Arrays", SAND85-0330, Sandia National Laboratories,
- Albuquerque NM.
- http://prod.sandia.gov/techlib/access-control.cgi/1985/850330.pdf
- .. [2] Dobos, A. P., 2014, "PVWatts Version 5 Manual", NREL/TP-6A20-62641,
- National Renewable Energy Laboratory, Golden CO.
- doi:10.2172/1158421.
- """
- # ported from the FORTRAN77 code provided in Appendix A of Fuentes 1987;
- # nearly all variable names are kept the same for ease of comparison.
-
- boltz = 5.669e-8
- emiss = emissivity
- absorp = absorption
- xlen = _hydraulic_diameter(module_width, module_length)
- # cap0 has units of [J / (m^2 K)], equal to mass per unit area times
- # specific heat of the module.
- cap0 = 11000
- tinoct = noct_installed + 273.15
-
- # convective coefficient of top surface of module at NOCT
- windmod = 1.0
- tave = (tinoct + 293.15) / 2
- hconv = _fuentes_hconv(tave, windmod, tinoct, tinoct - 293.15, xlen,
- surface_tilt, False)
-
- # determine the ground temperature ratio and the ratio of the total
- # convection to the top side convection
- hground = emiss * boltz * (tinoct**2 + 293.15**2) * (tinoct + 293.15)
- backrat = (
- absorp * 800.0
- - emiss * boltz * (tinoct**4 - 282.21**4)
- - hconv * (tinoct - 293.15)
- ) / ((hground + hconv) * (tinoct - 293.15))
- tground = (tinoct**4 - backrat * (tinoct**4 - 293.15**4))**0.25
- tground = np.clip(tground, 293.15, tinoct)
-
- tgrat = (tground - 293.15) / (tinoct - 293.15)
- convrat = (absorp * 800 - emiss * boltz * (
- 2 * tinoct**4 - 282.21**4 - tground**4)) / (hconv * (tinoct - 293.15))
-
- # adjust the capacitance (thermal mass) of the module based on the INOCT.
- # It is a function of INOCT because high INOCT implies thermal coupling
- # with the racking (e.g. roofmount), so the thermal mass is increased.
- # `cap` has units J/(m^2 C) -- see Table 3, Equations 26 & 27
- cap = cap0
- if tinoct > 321.15:
- cap = cap * (1 + (tinoct - 321.15) / 12)
-
- # iterate through timeseries inputs
- sun0 = 0
- tmod0 = 293.15
-
- # n.b. the way Fuentes calculates the first timedelta makes it seem like
- # the value doesn't matter -- rather than recreate it here, just assume
- # it's the same as the second timedelta:
- timedelta_hours = np.diff(poa_global.index).astype(float) / 1e9 / 60 / 60
- timedelta_hours = np.append([timedelta_hours[0]], timedelta_hours)
-
- tamb_array = temp_air + 273.15
- sun_array = poa_global * absorp
-
- # Two of the calculations are easily vectorized, so precalculate them:
- # sky temperature -- Equation 24
- tsky_array = 0.68 * (0.0552 * tamb_array**1.5) + 0.32 * tamb_array
- # wind speed at module height -- Equation 22
- # not sure why the 1e-4 factor is included -- maybe the equations don't
- # behave well if wind == 0?
- windmod_array = wind_speed * (module_height/wind_height)**0.2 + 1e-4
-
- tmod0 = 293.15
- tmod_array = np.zeros_like(poa_global)
-
- iterator = zip(tamb_array, sun_array, windmod_array, tsky_array,
- timedelta_hours)
- for i, (tamb, sun, windmod, tsky, dtime) in enumerate(iterator):
- # solve the heat transfer equation, iterating because the heat loss
- # terms depend on tmod. NB Fuentes doesn't show that 10 iterations is
- # sufficient for convergence.
- tmod = tmod0
- for j in range(10):
- # overall convective coefficient
- tave = (tmod + tamb) / 2
- hconv = convrat * _fuentes_hconv(tave, windmod, tinoct,
- abs(tmod-tamb), xlen,
- surface_tilt, True)
- # sky radiation coefficient (Equation 3)
- hsky = emiss * boltz * (tmod**2 + tsky**2) * (tmod + tsky)
- # ground radiation coeffieicient (Equation 4)
- tground = tamb + tgrat * (tmod - tamb)
- hground = emiss * boltz * (tmod**2 + tground**2) * (tmod + tground)
- # thermal lag -- Equation 8
- eigen = - (hconv + hsky + hground) / cap * dtime * 3600
- # not sure why this check is done, maybe as a speed optimization?
- if eigen > -10:
- ex = np.exp(eigen)
- else:
- ex = 0
- # Equation 7 -- note that `sun` and `sun0` already account for
- # absorption (alpha)
- tmod = tmod0 * ex + (
- (1 - ex) * (
- hconv * tamb
- + hsky * tsky
- + hground * tground
- + sun0
- + (sun - sun0) / eigen
- ) + sun - sun0
- ) / (hconv + hsky + hground)
- tmod_array[i] = tmod
- tmod0 = tmod
- sun0 = sun
-
- return pd.Series(tmod_array - 273.15, index=poa_global.index, name='tmod')
+ """
\ No newline at end of fileStdout
[anthropic-agent] instance=pvlib__pvlib-python-1072 [anthropic-agent] repo=pvlib/pvlib-python [anthropic-agent] sandbox=d9e94bdb-84e4-471a-9409-9306300c33b0 [anthropic-agent] model=claude-sonnet-4-5-20250929 [anthropic-agent] context_files=6 [anthropic-agent] full_file_context=yes [anthropic-agent] edit_attempts=2
Stderr
[anthropic-agent] Attempt 1: File-rewrite plan contained no files.
Agent output
diff --git a/pvlib/temperature.py b/pvlib/temperature.py
index 1d98736..6ac4533 100644
--- a/pvlib/temperature.py
+++ b/pvlib/temperature.py
@@ -367,293 +367,4 @@ def pvsyst_cell(poa_global, temp_air, wind_speed=1.0, u_c=29.0, u_v=0.0,
>>> params = TEMPERATURE_MODEL_PARAMETERS['pvsyst']['freestanding']
>>> pvsyst_cell(1000, 10, **params)
37.93103448275862
- """
-
- total_loss_factor = u_c + u_v * wind_speed
- heat_input = poa_global * alpha_absorption * (1 - eta_m)
- temp_difference = heat_input / total_loss_factor
- return temp_air + temp_difference
-
-
-def faiman(poa_global, temp_air, wind_speed=1.0, u0=25.0, u1=6.84):
- r'''
- Calculate cell or module temperature using the Faiman model. The Faiman
- model uses an empirical heat loss factor model [1]_ and is adopted in the
- IEC 61853 standards [2]_ and [3]_.
-
- Usage of this model in the IEC 61853 standard does not distinguish
- between cell and module temperature.
-
- Parameters
- ----------
- poa_global : numeric
- Total incident irradiance [W/m^2].
-
- temp_air : numeric
- Ambient dry bulb temperature [C].
-
- wind_speed : numeric, default 1.0
- Wind speed in m/s measured at the same height for which the wind loss
- factor was determined. The default value 1.0 m/s is the wind
- speed at module height used to determine NOCT. [m/s]
-
- u0 : numeric, default 25.0
- Combined heat loss factor coefficient. The default value is one
- determined by Faiman for 7 silicon modules.
- :math:`\left[\frac{\text{W}/{\text{m}^2}}{\text{C}}\right]`
-
- u1 : numeric, default 6.84
- Combined heat loss factor influenced by wind. The default value is one
- determined by Faiman for 7 silicon modules.
- :math:`\left[ \frac{\text{W}/\text{m}^2}{\text{C}\ \left( \text{m/s} \right)} \right]`
-
- Returns
- -------
- numeric, values in degrees Celsius
-
- Notes
- -----
- All arguments may be scalars or vectors. If multiple arguments
- are vectors they must be the same length.
-
- References
- ----------
- .. [1] Faiman, D. (2008). "Assessing the outdoor operating temperature of
- photovoltaic modules." Progress in Photovoltaics 16(4): 307-315.
-
- .. [2] "IEC 61853-2 Photovoltaic (PV) module performance testing and energy
- rating - Part 2: Spectral responsivity, incidence angle and module
- operating temperature measurements". IEC, Geneva, 2018.
-
- .. [3] "IEC 61853-3 Photovoltaic (PV) module performance testing and energy
- rating - Part 3: Energy rating of PV modules". IEC, Geneva, 2018.
-
- '''
- # Contributed by Anton Driesse (@adriesse), PV Performance Labs. Dec., 2019
-
- # The following lines may seem odd since u0 & u1 are probably scalar,
- # but it serves an indirect and easy way of allowing lists and
- # tuples for the other function arguments.
- u0 = np.asanyarray(u0)
- u1 = np.asanyarray(u1)
-
- total_loss_factor = u0 + u1 * wind_speed
- heat_input = poa_global
- temp_difference = heat_input / total_loss_factor
- return temp_air + temp_difference
-
-
-def _fuentes_hconv(tave, windmod, tinoct, temp_delta, xlen, tilt,
- check_reynold):
- # Calculate the convective coefficient as in Fuentes 1987 -- a mixture of
- # free, laminar, and turbulent convection.
- densair = 0.003484 * 101325.0 / tave # density
- visair = 0.24237e-6 * tave**0.76 / densair # kinematic viscosity
- condair = 2.1695e-4 * tave**0.84 # thermal conductivity
- reynold = windmod * xlen / visair
- # the boundary between laminar and turbulent is modeled as an abrupt
- # change at Re = 1.2e5:
- if check_reynold and reynold > 1.2e5:
- # turbulent convection
- hforce = 0.0282 / reynold**0.2 * densair * windmod * 1007 / 0.71**0.4
- else:
- # laminar convection
- hforce = 0.8600 / reynold**0.5 * densair * windmod * 1007 / 0.71**0.67
- # free convection via Grashof number
- # NB: Fuentes hardwires sind(tilt) as 0.5 for tilt=30
- grashof = 9.8 / tave * temp_delta * xlen**3 / visair**2 * sind(tilt)
- # product of Nusselt number and (k/l)
- hfree = 0.21 * (grashof * 0.71)**0.32 * condair / xlen
- # combine free and forced components
- hconv = (hfree**3 + hforce**3)**(1/3)
- return hconv
-
-
-def _hydraulic_diameter(width, height):
- # calculate the hydraulic diameter of a rectangle
- return 2 * (width * height) / (width + height)
-
-
-def fuentes(poa_global, temp_air, wind_speed, noct_installed, module_height=5,
- wind_height=9.144, emissivity=0.84, absorption=0.83,
- surface_tilt=30, module_width=0.31579, module_length=1.2):
- """
- Calculate cell or module temperature using the Fuentes model.
-
- The Fuentes model is a first-principles heat transfer energy balance
- model [1]_ that is used in PVWatts for cell temperature modeling [2]_.
-
- Parameters
- ----------
- poa_global : pandas Series
- Total incident irradiance [W/m^2]
-
- temp_air : pandas Series
- Ambient dry bulb temperature [C]
-
- wind_speed : pandas Series
- Wind speed [m/s]
-
- noct_installed : float
- The "installed" nominal operating cell temperature as defined in [1]_.
- PVWatts assumes this value to be 45 C for rack-mounted arrays and
- 49 C for roof mount systems with restricted air flow around the
- module. [C]
-
- module_height : float, default 5.0
- The height above ground of the center of the module. The PVWatts
- default is 5.0 [m]
-
- wind_height : float, default 9.144
- The height above ground at which ``wind_speed`` is measured. The
- PVWatts defauls is 9.144 [m]
-
- emissivity : float, default 0.84
- The effectiveness of the module at radiating thermal energy. [unitless]
-
- absorption : float, default 0.83
- The fraction of incident irradiance that is converted to thermal
- energy in the module. [unitless]
-
- surface_tilt : float, default 30
- Module tilt from horizontal. If not provided, the default value
- of 30 degrees from [1]_ and [2]_ is used. [degrees]
-
- module_width : float, default 0.31579
- Module width. The default value of 0.31579 meters in combination with
- the default `module_length` gives a hydraulic diameter of 0.5 as
- assumed in [1]_ and [2]_. [m]
-
- module_length : float, default 1.2
- Module length. The default value of 1.2 meters in combination with
- the default `module_width` gives a hydraulic diameter of 0.5 as
- assumed in [1]_ and [2]_. [m]
-
- Returns
- -------
- temperature_cell : pandas Series
- The modeled cell temperature [C]
-
- Notes
- -----
- This function returns slightly different values from PVWatts at night
- and just after dawn. This is because the SAM SSC assumes that module
- temperature equals ambient temperature when irradiance is zero so it can
- skip the heat balance calculation at night.
-
- References
- ----------
- .. [1] Fuentes, M. K., 1987, "A Simplifed Thermal Model for Flat-Plate
- Photovoltaic Arrays", SAND85-0330, Sandia National Laboratories,
- Albuquerque NM.
- http://prod.sandia.gov/techlib/access-control.cgi/1985/850330.pdf
- .. [2] Dobos, A. P., 2014, "PVWatts Version 5 Manual", NREL/TP-6A20-62641,
- National Renewable Energy Laboratory, Golden CO.
- doi:10.2172/1158421.
- """
- # ported from the FORTRAN77 code provided in Appendix A of Fuentes 1987;
- # nearly all variable names are kept the same for ease of comparison.
-
- boltz = 5.669e-8
- emiss = emissivity
- absorp = absorption
- xlen = _hydraulic_diameter(module_width, module_length)
- # cap0 has units of [J / (m^2 K)], equal to mass per unit area times
- # specific heat of the module.
- cap0 = 11000
- tinoct = noct_installed + 273.15
-
- # convective coefficient of top surface of module at NOCT
- windmod = 1.0
- tave = (tinoct + 293.15) / 2
- hconv = _fuentes_hconv(tave, windmod, tinoct, tinoct - 293.15, xlen,
- surface_tilt, False)
-
- # determine the ground temperature ratio and the ratio of the total
- # convection to the top side convection
- hground = emiss * boltz * (tinoct**2 + 293.15**2) * (tinoct + 293.15)
- backrat = (
- absorp * 800.0
- - emiss * boltz * (tinoct**4 - 282.21**4)
- - hconv * (tinoct - 293.15)
- ) / ((hground + hconv) * (tinoct - 293.15))
- tground = (tinoct**4 - backrat * (tinoct**4 - 293.15**4))**0.25
- tground = np.clip(tground, 293.15, tinoct)
-
- tgrat = (tground - 293.15) / (tinoct - 293.15)
- convrat = (absorp * 800 - emiss * boltz * (
- 2 * tinoct**4 - 282.21**4 - tground**4)) / (hconv * (tinoct - 293.15))
-
- # adjust the capacitance (thermal mass) of the module based on the INOCT.
- # It is a function of INOCT because high INOCT implies thermal coupling
- # with the racking (e.g. roofmount), so the thermal mass is increased.
- # `cap` has units J/(m^2 C) -- see Table 3, Equations 26 & 27
- cap = cap0
- if tinoct > 321.15:
- cap = cap * (1 + (tinoct - 321.15) / 12)
-
- # iterate through timeseries inputs
- sun0 = 0
- tmod0 = 293.15
-
- # n.b. the way Fuentes calculates the first timedelta makes it seem like
- # the value doesn't matter -- rather than recreate it here, just assume
- # it's the same as the second timedelta:
- timedelta_hours = np.diff(poa_global.index).astype(float) / 1e9 / 60 / 60
- timedelta_hours = np.append([timedelta_hours[0]], timedelta_hours)
-
- tamb_array = temp_air + 273.15
- sun_array = poa_global * absorp
-
- # Two of the calculations are easily vectorized, so precalculate them:
- # sky temperature -- Equation 24
- tsky_array = 0.68 * (0.0552 * tamb_array**1.5) + 0.32 * tamb_array
- # wind speed at module height -- Equation 22
- # not sure why the 1e-4 factor is included -- maybe the equations don't
- # behave well if wind == 0?
- windmod_array = wind_speed * (module_height/wind_height)**0.2 + 1e-4
-
- tmod0 = 293.15
- tmod_array = np.zeros_like(poa_global)
-
- iterator = zip(tamb_array, sun_array, windmod_array, tsky_array,
- timedelta_hours)
- for i, (tamb, sun, windmod, tsky, dtime) in enumerate(iterator):
- # solve the heat transfer equation, iterating because the heat loss
- # terms depend on tmod. NB Fuentes doesn't show that 10 iterations is
- # sufficient for convergence.
- tmod = tmod0
- for j in range(10):
- # overall convective coefficient
- tave = (tmod + tamb) / 2
- hconv = convrat * _fuentes_hconv(tave, windmod, tinoct,
- abs(tmod-tamb), xlen,
- surface_tilt, True)
- # sky radiation coefficient (Equation 3)
- hsky = emiss * boltz * (tmod**2 + tsky**2) * (tmod + tsky)
- # ground radiation coeffieicient (Equation 4)
- tground = tamb + tgrat * (tmod - tamb)
- hground = emiss * boltz * (tmod**2 + tground**2) * (tmod + tground)
- # thermal lag -- Equation 8
- eigen = - (hconv + hsky + hground) / cap * dtime * 3600
- # not sure why this check is done, maybe as a speed optimization?
- if eigen > -10:
- ex = np.exp(eigen)
- else:
- ex = 0
- # Equation 7 -- note that `sun` and `sun0` already account for
- # absorption (alpha)
- tmod = tmod0 * ex + (
- (1 - ex) * (
- hconv * tamb
- + hsky * tsky
- + hground * tground
- + sun0
- + (sun - sun0) / eigen
- ) + sun - sun0
- ) / (hconv + hsky + hground)
- tmod_array[i] = tmod
- tmod0 = tmod
- sun0 = sun
-
- return pd.Series(tmod_array - 273.15, index=poa_global.index, name='tmod')
+ """
\ No newline at end of fileScoring
Passing target tests
No fail-to-pass successes recorded yet.
Failing target tests
pvlib/tests/test_temperature.py::test_fuentes_timezone[Etc/GMT+5]
Maintained regression tests
No pass-to-pass successes recorded yet.
Regressed tests
pvlib/tests/test_temperature.py::test_sapm_cell pvlib/tests/test_temperature.py::test_sapm_module pvlib/tests/test_temperature.py::test_sapm_cell_from_module pvlib/tests/test_temperature.py::test_sapm_ndarray pvlib/tests/test_temperature.py::test_sapm_series pvlib/tests/test_temperature.py::test_pvsyst_cell_default pvlib/tests/test_temperature.py::test_pvsyst_cell_kwargs pvlib/tests/test_temperature.py::test_pvsyst_cell_ndarray pvlib/tests/test_temperature.py::test_pvsyst_cell_series pvlib/tests/test_temperature.py::test_faiman_default pvlib/tests/test_temperature.py::test_faiman_kwargs pvlib/tests/test_temperature.py::test_faiman_list pvlib/tests/test_temperature.py::test_faiman_ndarray pvlib/tests/test_temperature.py::test_faiman_series pvlib/tests/test_temperature.py::test__temperature_model_params pvlib/tests/test_temperature.py::test_fuentes[pvwatts_8760_rackmount.csv-45] pvlib/tests/test_temperature.py::test_fuentes[pvwatts_8760_roofmount.csv-49] pvlib/tests/test_temperature.py::test_fuentes_timezone[None]
Harness output
+ source /opt/miniconda3/bin/activate
++ _CONDA_ROOT=/opt/miniconda3
++ . /opt/miniconda3/etc/profile.d/conda.sh
+++ export CONDA_EXE=/opt/miniconda3/bin/conda
+++ CONDA_EXE=/opt/miniconda3/bin/conda
+++ export _CE_M=
+++ _CE_M=
+++ export _CE_CONDA=
+++ _CE_CONDA=
+++ export CONDA_PYTHON_EXE=/opt/miniconda3/bin/python
+++ CONDA_PYTHON_EXE=/opt/miniconda3/bin/python
+++ '[' -z x ']'
++ conda activate
++ local cmd=activate
++ case "$cmd" in
++ __conda_activate activate
++ '[' -n '' ']'
++ local ask_conda
+++ PS1=
+++ __conda_exe shell.posix activate
+++ /opt/miniconda3/bin/conda shell.posix activate
++ ask_conda='PS1='\''(base) '\''
export PATH='\''/opt/miniconda3/bin:/opt/miniconda3/condabin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'\''
export CONDA_PREFIX='\''/opt/miniconda3'\''
export CONDA_SHLVL='\''2'\''
export CONDA_DEFAULT_ENV='\''base'\''
export CONDA_PROMPT_MODIFIER='\''(base) '\''
export CONDA_PREFIX_1='\''/opt/miniconda3/envs/testbed'\''
export CONDA_EXE='\''/opt/miniconda3/bin/conda'\''
export _CE_M='\'''\''
export _CE_CONDA='\'''\''
export CONDA_PYTHON_EXE='\''/opt/miniconda3/bin/python'\'''
++ eval 'PS1='\''(base) '\''
export PATH='\''/opt/miniconda3/bin:/opt/miniconda3/condabin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'\''
export CONDA_PREFIX='\''/opt/miniconda3'\''
export CONDA_SHLVL='\''2'\''
export CONDA_DEFAULT_ENV='\''base'\''
export CONDA_PROMPT_MODIFIER='\''(base) '\''
export CONDA_PREFIX_1='\''/opt/miniconda3/envs/testbed'\''
export CONDA_EXE='\''/opt/miniconda3/bin/conda'\''
export _CE_M='\'''\''
export _CE_CONDA='\'''\''
export CONDA_PYTHON_EXE='\''/opt/miniconda3/bin/python'\'''
+++ PS1='(base) '
+++ export PATH=/opt/miniconda3/bin:/opt/miniconda3/condabin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+++ PATH=/opt/miniconda3/bin:/opt/miniconda3/condabin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+++ export CONDA_PREFIX=/opt/miniconda3
+++ CONDA_PREFIX=/opt/miniconda3
+++ export CONDA_SHLVL=2
+++ CONDA_SHLVL=2
+++ export CONDA_DEFAULT_ENV=base
+++ CONDA_DEFAULT_ENV=base
+++ export 'CONDA_PROMPT_MODIFIER=(base) '
+++ CONDA_PROMPT_MODIFIER='(base) '
+++ export CONDA_PREFIX_1=/opt/miniconda3/envs/testbed
+++ CONDA_PREFIX_1=/opt/miniconda3/envs/testbed
+++ export CONDA_EXE=/opt/miniconda3/bin/conda
+++ CONDA_EXE=/opt/miniconda3/bin/conda
+++ export _CE_M=
+++ _CE_M=
+++ export _CE_CONDA=
+++ _CE_CONDA=
+++ export CONDA_PYTHON_EXE=/opt/miniconda3/bin/python
+++ CONDA_PYTHON_EXE=/opt/miniconda3/bin/python
++ __conda_hashr
++ '[' -n '' ']'
++ '[' -n '' ']'
++ hash -r
+ conda activate testbed
+ local cmd=activate
+ case "$cmd" in
+ __conda_activate activate testbed
+ '[' -n '' ']'
+ local ask_conda
++ PS1='(base) '
++ __conda_exe shell.posix activate testbed
++ /opt/miniconda3/bin/conda shell.posix activate testbed
+ ask_conda='PS1='\''(testbed) '\''
export PATH='\''/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/condabin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'\''
export CONDA_PREFIX='\''/opt/miniconda3/envs/testbed'\''
export CONDA_SHLVL='\''3'\''
export CONDA_DEFAULT_ENV='\''testbed'\''
export CONDA_PROMPT_MODIFIER='\''(testbed) '\''
export CONDA_PREFIX_2='\''/opt/miniconda3'\''
export CONDA_EXE='\''/opt/miniconda3/bin/conda'\''
export _CE_M='\'''\''
export _CE_CONDA='\'''\''
export CONDA_PYTHON_EXE='\''/opt/miniconda3/bin/python'\'''
+ eval 'PS1='\''(testbed) '\''
export PATH='\''/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/condabin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'\''
export CONDA_PREFIX='\''/opt/miniconda3/envs/testbed'\''
export CONDA_SHLVL='\''3'\''
export CONDA_DEFAULT_ENV='\''testbed'\''
export CONDA_PROMPT_MODIFIER='\''(testbed) '\''
export CONDA_PREFIX_2='\''/opt/miniconda3'\''
export CONDA_EXE='\''/opt/miniconda3/bin/conda'\''
export _CE_M='\'''\''
export _CE_CONDA='\'''\''
export CONDA_PYTHON_EXE='\''/opt/miniconda3/bin/python'\'''
++ PS1='(testbed) '
++ export PATH=/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/condabin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
++ PATH=/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/condabin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
++ export CONDA_PREFIX=/opt/miniconda3/envs/testbed
++ CONDA_PREFIX=/opt/miniconda3/envs/testbed
++ export CONDA_SHLVL=3
++ CONDA_SHLVL=3
++ export CONDA_DEFAULT_ENV=testbed
++ CONDA_DEFAULT_ENV=testbed
++ export 'CONDA_PROMPT_MODIFIER=(testbed) '
++ CONDA_PROMPT_MODIFIER='(testbed) '
++ export CONDA_PREFIX_2=/opt/miniconda3
++ CONDA_PREFIX_2=/opt/miniconda3
++ export CONDA_EXE=/opt/miniconda3/bin/conda
++ CONDA_EXE=/opt/miniconda3/bin/conda
++ export _CE_M=
++ _CE_M=
++ export _CE_CONDA=
++ _CE_CONDA=
++ export CONDA_PYTHON_EXE=/opt/miniconda3/bin/python
++ CONDA_PYTHON_EXE=/opt/miniconda3/bin/python
+ __conda_hashr
+ '[' -n '' ']'
+ '[' -n '' ']'
+ hash -r
+ cd /testbed
+ git config --global --add safe.directory /testbed
+ cd /testbed
+ git status
On branch main
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: pvlib/temperature.py
no changes added to commit (use "git add" and/or "git commit -a")
+ git show
commit dc81df76430196d3325871870b952e61df3032e8
Author: SWE-bench <setup@swebench.config>
Date: Tue May 6 23:21:30 2025 +0000
SWE-bench
+ git -c core.fileMode=false diff 04a523fafbd61bc2e49420963b84ed8e2bd1b3cf
diff --git a/pvlib/temperature.py b/pvlib/temperature.py
index 1d98736..6ac4533 100644
--- a/pvlib/temperature.py
+++ b/pvlib/temperature.py
@@ -367,293 +367,4 @@ def pvsyst_cell(poa_global, temp_air, wind_speed=1.0, u_c=29.0, u_v=0.0,
>>> params = TEMPERATURE_MODEL_PARAMETERS['pvsyst']['freestanding']
>>> pvsyst_cell(1000, 10, **params)
37.93103448275862
- """
-
- total_loss_factor = u_c + u_v * wind_speed
- heat_input = poa_global * alpha_absorption * (1 - eta_m)
- temp_difference = heat_input / total_loss_factor
- return temp_air + temp_difference
-
-
-def faiman(poa_global, temp_air, wind_speed=1.0, u0=25.0, u1=6.84):
- r'''
- Calculate cell or module temperature using the Faiman model. The Faiman
- model uses an empirical heat loss factor model [1]_ and is adopted in the
- IEC 61853 standards [2]_ and [3]_.
-
- Usage of this model in the IEC 61853 standard does not distinguish
- between cell and module temperature.
-
- Parameters
- ----------
- poa_global : numeric
- Total incident irradiance [W/m^2].
-
- temp_air : numeric
- Ambient dry bulb temperature [C].
-
- wind_speed : numeric, default 1.0
- Wind speed in m/s measured at the same height for which the wind loss
- factor was determined. The default value 1.0 m/s is the wind
- speed at module height used to determine NOCT. [m/s]
-
- u0 : numeric, default 25.0
- Combined heat loss factor coefficient. The default value is one
- determined by Faiman for 7 silicon modules.
- :math:`\left[\frac{\text{W}/{\text{m}^2}}{\text{C}}\right]`
-
- u1 : numeric, default 6.84
- Combined heat loss factor influenced by wind. The default value is one
- determined by Faiman for 7 silicon modules.
- :math:`\left[ \frac{\text{W}/\text{m}^2}{\text{C}\ \left( \text{m/s} \right)} \right]`
-
- Returns
- -------
- numeric, values in degrees Celsius
-
- Notes
- -----
- All arguments may be scalars or vectors. If multiple arguments
- are vectors they must be the same length.
-
- References
- ----------
- .. [1] Faiman, D. (2008). "Assessing the outdoor operating temperature of
- photovoltaic modules." Progress in Photovoltaics 16(4): 307-315.
-
- .. [2] "IEC 61853-2 Photovoltaic (PV) module performance testing and energy
- rating - Part 2: Spectral responsivity, incidence angle and module
- operating temperature measurements". IEC, Geneva, 2018.
-
- .. [3] "IEC 61853-3 Photovoltaic (PV) module performance testing and energy
- rating - Part 3: Energy rating of PV modules". IEC, Geneva, 2018.
-
- '''
- # Contributed by Anton Driesse (@adriesse), PV Performance Labs. Dec., 2019
-
- # The following lines may seem odd since u0 & u1 are probably scalar,
- # but it serves an indirect and easy way of allowing lists and
- # tuples for the other function arguments.
- u0 = np.asanyarray(u0)
- u1 = np.asanyarray(u1)
-
- total_loss_factor = u0 + u1 * wind_speed
- heat_input = poa_global
- temp_difference = heat_input / total_loss_factor
- return temp_air + temp_difference
-
-
-def _fuentes_hconv(tave, windmod, tinoct, temp_delta, xlen, tilt,
- check_reynold):
- # Calculate the convective coefficient as in Fuentes 1987 -- a mixture of
- # free, laminar, and turbulent convection.
- densair = 0.003484 * 101325.0 / tave # density
- visair = 0.24237e-6 * tave**0.76 / densair # kinematic viscosity
- condair = 2.1695e-4 * tave**0.84 # thermal conductivity
- reynold = windmod * xlen / visair
- # the boundary between laminar and turbulent is modeled as an abrupt
- # change at Re = 1.2e5:
- if check_reynold and reynold > 1.2e5:
- # turbulent convection
- hforce = 0.0282 / reynold**0.2 * densair * windmod * 1007 / 0.71**0.4
- else:
- # laminar convection
- hforce = 0.8600 / reynold**0.5 * densair * windmod * 1007 / 0.71**0.67
- # free convection via Grashof number
- # NB: Fuentes hardwires sind(tilt) as 0.5 for tilt=30
- grashof = 9.8 / tave * temp_delta * xlen**3 / visair**2 * sind(tilt)
- # product of Nusselt number and (k/l)
- hfree = 0.21 * (grashof * 0.71)**0.32 * condair / xlen
- # combine free and forced components
- hconv = (hfree**3 + hforce**3)**(1/3)
- return hconv
-
-
-def _hydraulic_diameter(width, height):
- # calculate the hydraulic diameter of a rectangle
- return 2 * (width * height) / (width + height)
-
-
-def fuentes(poa_global, temp_air, wind_speed, noct_installed, module_height=5,
- wind_height=9.144, emissivity=0.84, absorption=0.83,
- surface_tilt=30, module_width=0.31579, module_length=1.2):
- """
- Calculate cell or module temperature using the Fuentes model.
-
- The Fuentes model is a first-principles heat transfer energy balance
- model [1]_ that is used in PVWatts for cell temperature modeling [2]_.
-
- Parameters
- ----------
- poa_global : pandas Series
- Total incident irradiance [W/m^2]
-
- temp_air : pandas Series
- Ambient dry bulb temperature [C]
-
- wind_speed : pandas Series
- Wind speed [m/s]
-
- noct_installed : float
- The "installed" nominal operating cell temperature as defined in [1]_.
- PVWatts assumes this value to be 45 C for rack-mounted arrays and
- 49 C for roof mount systems with restricted air flow around the
- module. [C]
-
- module_height : float, default 5.0
- The height above ground of the center of the module. The PVWatts
- default is 5.0 [m]
-
- wind_height : float, default 9.144
- The height above ground at which ``wind_speed`` is measured. The
- PVWatts defauls is 9.144 [m]
-
- emissivity : float, default 0.84
- The effectiveness of the module at radiating thermal energy. [unitless]
-
- absorption : float, default 0.83
- The fraction of incident irradiance that is converted to thermal
- energy in the module. [unitless]
-
- surface_tilt : float, default 30
- Module tilt from horizontal. If not provided, the default value
- of 30 degrees from [1]_ and [2]_ is used. [degrees]
-
- module_width : float, default 0.31579
- Module width. The default value of 0.31579 meters in combination with
- the default `module_length` gives a hydraulic diameter of 0.5 as
- assumed in [1]_ and [2]_. [m]
-
- module_length : float, default 1.2
- Module length. The default value of 1.2 meters in combination with
- the default `module_width` gives a hydraulic diameter of 0.5 as
- assumed in [1]_ and [2]_. [m]
-
- Returns
- -------
- temperature_cell : pandas Series
- The modeled cell temperature [C]
-
- Notes
- -----
- This function returns slightly different values from PVWatts at night
- and just after dawn. This is because the SAM SSC assumes that module
- temperature equals ambient temperature when irradiance is zero so it can
- skip the heat balance calculation at night.
-
- References
- ----------
- .. [1] Fuentes, M. K., 1987, "A Simplifed Thermal Model for Flat-Plate
- Photovoltaic Arrays", SAND85-0330, Sandia National Laboratories,
- Albuquerque NM.
- http://prod.sandia.gov/techlib/access-control.cgi/1985/850330.pdf
- .. [2] Dobos, A. P., 2014, "PVWatts Version 5 Manual", NREL/TP-6A20-62641,
- National Renewable Energy Laboratory, Golden CO.
- doi:10.2172/1158421.
- """
- # ported from the FORTRAN77 code provided in Appendix A of Fuentes 1987;
- # nearly all variable names are kept the same for ease of comparison.
-
- boltz = 5.669e-8
- emiss = emissivity
- absorp = absorption
- xlen = _hydraulic_diameter(module_width, module_length)
- # cap0 has units of [J / (m^2 K)], equal to mass per unit area times
- # specific heat of the module.
- cap0 = 11000
- tinoct = noct_installed + 273.15
-
- # convective coefficient of top surface of module at NOCT
- windmod = 1.0
- tave = (tinoct + 293.15) / 2
- hconv = _fuentes_hconv(tave, windmod, tinoct, tinoct - 293.15, xlen,
- surface_tilt, False)
-
- # determine the ground temperature ratio and the ratio of the total
- # convection to the top side convection
- hground = emiss * boltz * (tinoct**2 + 293.15**2) * (tinoct + 293.15)
- backrat = (
- absorp * 800.0
- - emiss * boltz * (tinoct**4 - 282.21**4)
- - hconv * (tinoct - 293.15)
- ) / ((hground + hconv) * (tinoct - 293.15))
- tground = (tinoct**4 - backrat * (tinoct**4 - 293.15**4))**0.25
- tground = np.clip(tground, 293.15, tinoct)
-
- tgrat = (tground - 293.15) / (tinoct - 293.15)
- convrat = (absorp * 800 - emiss * boltz * (
- 2 * tinoct**4 - 282.21**4 - tground**4)) / (hconv * (tinoct - 293.15))
-
- # adjust the capacitance (thermal mass) of the module based on the INOCT.
- # It is a function of INOCT because high INOCT implies thermal coupling
- # with the racking (e.g. roofmount), so the thermal mass is increased.
- # `cap` has units J/(m^2 C) -- see Table 3, Equations 26 & 27
- cap = cap0
- if tinoct > 321.15:
- cap = cap * (1 + (tinoct - 321.15) / 12)
-
- # iterate through timeseries inputs
- sun0 = 0
- tmod0 = 293.15
-
- # n.b. the way Fuentes calculates the first timedelta makes it seem like
- # the value doesn't matter -- rather than recreate it here, just assume
- # it's the same as the second timedelta:
- timedelta_hours = np.diff(poa_global.index).astype(float) / 1e9 / 60 / 60
- timedelta_hours = np.append([timedelta_hours[0]], timedelta_hours)
-
- tamb_array = temp_air + 273.15
- sun_array = poa_global * absorp
-
- # Two of the calculations are easily vectorized, so precalculate them:
- # sky temperature -- Equation 24
- tsky_array = 0.68 * (0.0552 * tamb_array**1.5) + 0.32 * tamb_array
- # wind speed at module height -- Equation 22
- # not sure why the 1e-4 factor is included -- maybe the equations don't
- # behave well if wind == 0?
- windmod_array = wind_speed * (module_height/wind_height)**0.2 + 1e-4
-
- tmod0 = 293.15
- tmod_array = np.zeros_like(poa_global)
-
- iterator = zip(tamb_array, sun_array, windmod_array, tsky_array,
- timedelta_hours)
- for i, (tamb, sun, windmod, tsky, dtime) in enumerate(iterator):
- # solve the heat transfer equation, iterating because the heat loss
- # terms depend on tmod. NB Fuentes doesn't show that 10 iterations is
- # sufficient for convergence.
- tmod = tmod0
- for j in range(10):
- # overall convective coefficient
- tave = (tmod + tamb) / 2
- hconv = convrat * _fuentes_hconv(tave, windmod, tinoct,
- abs(tmod-tamb), xlen,
- surface_tilt, True)
- # sky radiation coefficient (Equation 3)
- hsky = emiss * boltz * (tmod**2 + tsky**2) * (tmod + tsky)
- # ground radiation coeffieicient (Equation 4)
- tground = tamb + tgrat * (tmod - tamb)
- hground = emiss * boltz * (tmod**2 + tground**2) * (tmod + tground)
- # thermal lag -- Equation 8
- eigen = - (hconv + hsky + hground) / cap * dtime * 3600
- # not sure why this check is done, maybe as a speed optimization?
- if eigen > -10:
- ex = np.exp(eigen)
- else:
- ex = 0
- # Equation 7 -- note that `sun` and `sun0` already account for
- # absorption (alpha)
- tmod = tmod0 * ex + (
- (1 - ex) * (
- hconv * tamb
- + hsky * tsky
- + hground * tground
- + sun0
- + (sun - sun0) / eigen
- ) + sun - sun0
- ) / (hconv + hsky + hground)
- tmod_array[i] = tmod
- tmod0 = tmod
- sun0 = sun
-
- return pd.Series(tmod_array - 273.15, index=poa_global.index, name='tmod')
+ """
\ No newline at end of file
+ source /opt/miniconda3/bin/activate
++ _CONDA_ROOT=/opt/miniconda3
++ . /opt/miniconda3/etc/profile.d/conda.sh
+++ export CONDA_EXE=/opt/miniconda3/bin/conda
+++ CONDA_EXE=/opt/miniconda3/bin/conda
+++ export _CE_M=
+++ _CE_M=
+++ export _CE_CONDA=
+++ _CE_CONDA=
+++ export CONDA_PYTHON_EXE=/opt/miniconda3/bin/python
+++ CONDA_PYTHON_EXE=/opt/miniconda3/bin/python
+++ '[' -z x ']'
++ conda activate
++ local cmd=activate
++ case "$cmd" in
++ __conda_activate activate
++ '[' -n '' ']'
++ local ask_conda
+++ PS1='(testbed) '
+++ __conda_exe shell.posix activate
+++ /opt/miniconda3/bin/conda shell.posix activate
++ ask_conda='PS1='\''(base) '\''
export PATH='\''/opt/miniconda3/bin:/opt/miniconda3/condabin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'\''
export CONDA_PREFIX='\''/opt/miniconda3'\''
export CONDA_SHLVL='\''4'\''
export CONDA_DEFAULT_ENV='\''base'\''
export CONDA_PROMPT_MODIFIER='\''(base) '\''
export CONDA_PREFIX_3='\''/opt/miniconda3/envs/testbed'\''
export CONDA_EXE='\''/opt/miniconda3/bin/conda'\''
export _CE_M='\'''\''
export _CE_CONDA='\'''\''
export CONDA_PYTHON_EXE='\''/opt/miniconda3/bin/python'\'''
++ eval 'PS1='\''(base) '\''
export PATH='\''/opt/miniconda3/bin:/opt/miniconda3/condabin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'\''
export CONDA_PREFIX='\''/opt/miniconda3'\''
export CONDA_SHLVL='\''4'\''
export CONDA_DEFAULT_ENV='\''base'\''
export CONDA_PROMPT_MODIFIER='\''(base) '\''
export CONDA_PREFIX_3='\''/opt/miniconda3/envs/testbed'\''
export CONDA_EXE='\''/opt/miniconda3/bin/conda'\''
export _CE_M='\'''\''
export _CE_CONDA='\'''\''
export CONDA_PYTHON_EXE='\''/opt/miniconda3/bin/python'\'''
+++ PS1='(base) '
+++ export PATH=/opt/miniconda3/bin:/opt/miniconda3/condabin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+++ PATH=/opt/miniconda3/bin:/opt/miniconda3/condabin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+++ export CONDA_PREFIX=/opt/miniconda3
+++ CONDA_PREFIX=/opt/miniconda3
+++ export CONDA_SHLVL=4
+++ CONDA_SHLVL=4
+++ export CONDA_DEFAULT_ENV=base
+++ CONDA_DEFAULT_ENV=base
+++ export 'CONDA_PROMPT_MODIFIER=(base) '
+++ CONDA_PROMPT_MODIFIER='(base) '
+++ export CONDA_PREFIX_3=/opt/miniconda3/envs/testbed
+++ CONDA_PREFIX_3=/opt/miniconda3/envs/testbed
+++ export CONDA_EXE=/opt/miniconda3/bin/conda
+++ CONDA_EXE=/opt/miniconda3/bin/conda
+++ export _CE_M=
+++ _CE_M=
+++ export _CE_CONDA=
+++ _CE_CONDA=
+++ export CONDA_PYTHON_EXE=/opt/miniconda3/bin/python
+++ CONDA_PYTHON_EXE=/opt/miniconda3/bin/python
++ __conda_hashr
++ '[' -n '' ']'
++ '[' -n '' ']'
++ hash -r
+ conda activate testbed
+ local cmd=activate
+ case "$cmd" in
+ __conda_activate activate testbed
+ '[' -n '' ']'
+ local ask_conda
++ PS1='(base) '
++ __conda_exe shell.posix activate testbed
++ /opt/miniconda3/bin/conda shell.posix activate testbed
+ ask_conda='PS1='\''(testbed) '\''
export PATH='\''/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/condabin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'\''
export CONDA_PREFIX='\''/opt/miniconda3/envs/testbed'\''
export CONDA_SHLVL='\''5'\''
export CONDA_DEFAULT_ENV='\''testbed'\''
export CONDA_PROMPT_MODIFIER='\''(testbed) '\''
export CONDA_PREFIX_4='\''/opt/miniconda3'\''
export CONDA_EXE='\''/opt/miniconda3/bin/conda'\''
export _CE_M='\'''\''
export _CE_CONDA='\'''\''
export CONDA_PYTHON_EXE='\''/opt/miniconda3/bin/python'\'''
+ eval 'PS1='\''(testbed) '\''
export PATH='\''/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/condabin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'\''
export CONDA_PREFIX='\''/opt/miniconda3/envs/testbed'\''
export CONDA_SHLVL='\''5'\''
export CONDA_DEFAULT_ENV='\''testbed'\''
export CONDA_PROMPT_MODIFIER='\''(testbed) '\''
export CONDA_PREFIX_4='\''/opt/miniconda3'\''
export CONDA_EXE='\''/opt/miniconda3/bin/conda'\''
export _CE_M='\'''\''
export _CE_CONDA='\'''\''
export CONDA_PYTHON_EXE='\''/opt/miniconda3/bin/python'\'''
++ PS1='(testbed) '
++ export PATH=/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/condabin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
++ PATH=/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/condabin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
++ export CONDA_PREFIX=/opt/miniconda3/envs/testbed
++ CONDA_PREFIX=/opt/miniconda3/envs/testbed
++ export CONDA_SHLVL=5
++ CONDA_SHLVL=5
++ export CONDA_DEFAULT_ENV=testbed
++ CONDA_DEFAULT_ENV=testbed
++ export 'CONDA_PROMPT_MODIFIER=(testbed) '
++ CONDA_PROMPT_MODIFIER='(testbed) '
++ export CONDA_PREFIX_4=/opt/miniconda3
++ CONDA_PREFIX_4=/opt/miniconda3
++ export CONDA_EXE=/opt/miniconda3/bin/conda
++ CONDA_EXE=/opt/miniconda3/bin/conda
++ export _CE_M=
++ _CE_M=
++ export _CE_CONDA=
++ _CE_CONDA=
++ export CONDA_PYTHON_EXE=/opt/miniconda3/bin/python
++ CONDA_PYTHON_EXE=/opt/miniconda3/bin/python
+ __conda_hashr
+ '[' -n '' ']'
+ '[' -n '' ']'
+ hash -r
+ python -m pip install -e '.[all]'
Obtaining file:///testbed
Preparing metadata (setup.py): started
Preparing metadata (setup.py): finished with status 'done'
Requirement already satisfied: numpy>=1.12.0 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pvlib==0.8.0+3.gdc81df7.dirty) (2.0.2)
Requirement already satisfied: pandas>=0.22.0 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pvlib==0.8.0+3.gdc81df7.dirty) (2.2.3)
Requirement already satisfied: pytz in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pvlib==0.8.0+3.gdc81df7.dirty) (2024.1)
Requirement already satisfied: requests in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pvlib==0.8.0+3.gdc81df7.dirty) (2.32.3)
Requirement already satisfied: scipy>=1.2.0 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pvlib==0.8.0+3.gdc81df7.dirty) (1.13.1)
Requirement already satisfied: cftime>=1.1.1 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pvlib==0.8.0+3.gdc81df7.dirty) (1.6.4.post1)
Requirement already satisfied: cython in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pvlib==0.8.0+3.gdc81df7.dirty) (3.0.12)
Requirement already satisfied: docutils==0.15.2 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pvlib==0.8.0+3.gdc81df7.dirty) (0.15.2)
Requirement already satisfied: ephem in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pvlib==0.8.0+3.gdc81df7.dirty) (4.2)
Requirement already satisfied: ipython in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pvlib==0.8.0+3.gdc81df7.dirty) (8.18.1)
Requirement already satisfied: matplotlib in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pvlib==0.8.0+3.gdc81df7.dirty) (3.9.4)
Requirement already satisfied: netcdf4 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pvlib==0.8.0+3.gdc81df7.dirty) (1.7.2)
Requirement already satisfied: nose in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pvlib==0.8.0+3.gdc81df7.dirty) (1.3.7)
Requirement already satisfied: nrel-pysam in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pvlib==0.8.0+3.gdc81df7.dirty) (7.0.0)
Requirement already satisfied: numba in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pvlib==0.8.0+3.gdc81df7.dirty) (0.60.0)
Requirement already satisfied: pillow in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pvlib==0.8.0+3.gdc81df7.dirty) (11.2.1)
Requirement already satisfied: pvfactors in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pvlib==0.8.0+3.gdc81df7.dirty) (1.5.1)
Requirement already satisfied: pytest in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pvlib==0.8.0+3.gdc81df7.dirty) (8.3.5)
Requirement already satisfied: pytest-cov in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pvlib==0.8.0+3.gdc81df7.dirty) (6.1.1)
Requirement already satisfied: pytest-mock in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pvlib==0.8.0+3.gdc81df7.dirty) (3.14.0)
Requirement already satisfied: pytest-remotedata in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pvlib==0.8.0+3.gdc81df7.dirty) (0.4.1)
Requirement already satisfied: pytest-rerunfailures in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pvlib==0.8.0+3.gdc81df7.dirty) (15.0)
Requirement already satisfied: pytest-timeout in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pvlib==0.8.0+3.gdc81df7.dirty) (2.4.0)
Requirement already satisfied: siphon in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pvlib==0.8.0+3.gdc81df7.dirty) (0.9)
Requirement already satisfied: sphinx==1.8.5 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pvlib==0.8.0+3.gdc81df7.dirty) (1.8.5)
Requirement already satisfied: sphinx-gallery in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pvlib==0.8.0+3.gdc81df7.dirty) (0.11.0)
Requirement already satisfied: sphinx_rtd_theme in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pvlib==0.8.0+3.gdc81df7.dirty) (1.3.0)
Requirement already satisfied: statsmodels in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pvlib==0.8.0+3.gdc81df7.dirty) (0.14.4)
Requirement already satisfied: tables in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pvlib==0.8.0+3.gdc81df7.dirty) (3.9.2)
Requirement already satisfied: six>=1.5 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from sphinx==1.8.5->pvlib==0.8.0+3.gdc81df7.dirty) (1.17.0)
Requirement already satisfied: Jinja2>=2.3 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from sphinx==1.8.5->pvlib==0.8.0+3.gdc81df7.dirty) (3.1.6)
Requirement already satisfied: Pygments>=2.0 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from sphinx==1.8.5->pvlib==0.8.0+3.gdc81df7.dirty) (2.19.1)
Requirement already satisfied: snowballstemmer>=1.1 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from sphinx==1.8.5->pvlib==0.8.0+3.gdc81df7.dirty) (2.2.0)
Requirement already satisfied: babel!=2.0,>=1.3 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from sphinx==1.8.5->pvlib==0.8.0+3.gdc81df7.dirty) (2.17.0)
Requirement already satisfied: alabaster<0.8,>=0.7 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from sphinx==1.8.5->pvlib==0.8.0+3.gdc81df7.dirty) (0.7.16)
Requirement already satisfied: imagesize in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from sphinx==1.8.5->pvlib==0.8.0+3.gdc81df7.dirty) (1.4.1)
Requirement already satisfied: setuptools in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from sphinx==1.8.5->pvlib==0.8.0+3.gdc81df7.dirty) (72.1.0)
Requirement already satisfied: packaging in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from sphinx==1.8.5->pvlib==0.8.0+3.gdc81df7.dirty) (25.0)
Requirement already satisfied: sphinxcontrib-websupport in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from sphinx==1.8.5->pvlib==0.8.0+3.gdc81df7.dirty) (1.2.4)
Requirement already satisfied: MarkupSafe>=2.0 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from Jinja2>=2.3->sphinx==1.8.5->pvlib==0.8.0+3.gdc81df7.dirty) (3.0.2)
Requirement already satisfied: python-dateutil>=2.8.2 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pandas>=0.22.0->pvlib==0.8.0+3.gdc81df7.dirty) (2.9.0.post0)
Requirement already satisfied: tzdata>=2022.7 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pandas>=0.22.0->pvlib==0.8.0+3.gdc81df7.dirty) (2025.2)
Requirement already satisfied: charset-normalizer<4,>=2 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from requests->pvlib==0.8.0+3.gdc81df7.dirty) (3.4.2)
Requirement already satisfied: idna<4,>=2.5 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from requests->pvlib==0.8.0+3.gdc81df7.dirty) (3.10)
Requirement already satisfied: urllib3<3,>=1.21.1 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from requests->pvlib==0.8.0+3.gdc81df7.dirty) (2.4.0)
Requirement already satisfied: certifi>=2017.4.17 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from requests->pvlib==0.8.0+3.gdc81df7.dirty) (2025.4.26)
Requirement already satisfied: decorator in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from ipython->pvlib==0.8.0+3.gdc81df7.dirty) (5.2.1)
Requirement already satisfied: jedi>=0.16 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from ipython->pvlib==0.8.0+3.gdc81df7.dirty) (0.19.2)
Requirement already satisfied: matplotlib-inline in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from ipython->pvlib==0.8.0+3.gdc81df7.dirty) (0.1.7)
Requirement already satisfied: prompt-toolkit<3.1.0,>=3.0.41 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from ipython->pvlib==0.8.0+3.gdc81df7.dirty) (3.0.51)
Requirement already satisfied: stack-data in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from ipython->pvlib==0.8.0+3.gdc81df7.dirty) (0.6.3)
Requirement already satisfied: traitlets>=5 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from ipython->pvlib==0.8.0+3.gdc81df7.dirty) (5.14.3)
Requirement already satisfied: typing-extensions in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from ipython->pvlib==0.8.0+3.gdc81df7.dirty) (4.15.0)
Requirement already satisfied: exceptiongroup in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from ipython->pvlib==0.8.0+3.gdc81df7.dirty) (1.2.2)
Requirement already satisfied: pexpect>4.3 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from ipython->pvlib==0.8.0+3.gdc81df7.dirty) (4.9.0)
Requirement already satisfied: wcwidth in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from prompt-toolkit<3.1.0,>=3.0.41->ipython->pvlib==0.8.0+3.gdc81df7.dirty) (0.2.13)
Requirement already satisfied: parso<0.9.0,>=0.8.4 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from jedi>=0.16->ipython->pvlib==0.8.0+3.gdc81df7.dirty) (0.8.4)
Requirement already satisfied: ptyprocess>=0.5 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pexpect>4.3->ipython->pvlib==0.8.0+3.gdc81df7.dirty) (0.7.0)
Requirement already satisfied: contourpy>=1.0.1 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from matplotlib->pvlib==0.8.0+3.gdc81df7.dirty) (1.3.0)
Requirement already satisfied: cycler>=0.10 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from matplotlib->pvlib==0.8.0+3.gdc81df7.dirty) (0.12.1)
Requirement already satisfied: fonttools>=4.22.0 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from matplotlib->pvlib==0.8.0+3.gdc81df7.dirty) (4.57.0)
Requirement already satisfied: kiwisolver>=1.3.1 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from matplotlib->pvlib==0.8.0+3.gdc81df7.dirty) (1.4.7)
Requirement already satisfied: pyparsing>=2.3.1 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from matplotlib->pvlib==0.8.0+3.gdc81df7.dirty) (3.2.3)
Requirement already satisfied: importlib-resources>=3.2.0 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from matplotlib->pvlib==0.8.0+3.gdc81df7.dirty) (6.5.2)
Requirement already satisfied: zipp>=3.1.0 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from importlib-resources>=3.2.0->matplotlib->pvlib==0.8.0+3.gdc81df7.dirty) (3.21.0)
Requirement already satisfied: llvmlite<0.44,>=0.43.0dev0 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from numba->pvlib==0.8.0+3.gdc81df7.dirty) (0.43.0)
Requirement already satisfied: shapely>=1.6.4.post2 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pvfactors->pvlib==0.8.0+3.gdc81df7.dirty) (2.0.7)
Requirement already satisfied: future in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pvfactors->pvlib==0.8.0+3.gdc81df7.dirty) (1.0.0)
Requirement already satisfied: iniconfig in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pytest->pvlib==0.8.0+3.gdc81df7.dirty) (2.1.0)
Requirement already satisfied: pluggy<2,>=1.5 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pytest->pvlib==0.8.0+3.gdc81df7.dirty) (1.5.0)
Requirement already satisfied: tomli>=1 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pytest->pvlib==0.8.0+3.gdc81df7.dirty) (2.2.1)
Requirement already satisfied: coverage>=7.5 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from coverage[toml]>=7.5->pytest-cov->pvlib==0.8.0+3.gdc81df7.dirty) (7.8.0)
Requirement already satisfied: protobuf>=3.0.0a3 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from siphon->pvlib==0.8.0+3.gdc81df7.dirty) (6.31.0rc2)
Requirement already satisfied: beautifulsoup4>=4.6 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from siphon->pvlib==0.8.0+3.gdc81df7.dirty) (4.13.4)
Requirement already satisfied: soupsieve>1.2 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from beautifulsoup4>=4.6->siphon->pvlib==0.8.0+3.gdc81df7.dirty) (2.7)
Requirement already satisfied: sphinxcontrib-jquery<5,>=4 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from sphinx_rtd_theme->pvlib==0.8.0+3.gdc81df7.dirty) (4.1)
Requirement already satisfied: sphinxcontrib-serializinghtml in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from sphinxcontrib-websupport->sphinx==1.8.5->pvlib==0.8.0+3.gdc81df7.dirty) (2.0.0)
Requirement already satisfied: executing>=1.2.0 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from stack-data->ipython->pvlib==0.8.0+3.gdc81df7.dirty) (2.2.0)
Requirement already satisfied: asttokens>=2.1.0 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from stack-data->ipython->pvlib==0.8.0+3.gdc81df7.dirty) (3.0.0)
Requirement already satisfied: pure-eval in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from stack-data->ipython->pvlib==0.8.0+3.gdc81df7.dirty) (0.2.3)
Requirement already satisfied: patsy>=0.5.6 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from statsmodels->pvlib==0.8.0+3.gdc81df7.dirty) (1.0.1)
Requirement already satisfied: numexpr>=2.6.2 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from tables->pvlib==0.8.0+3.gdc81df7.dirty) (2.10.1)
Requirement already satisfied: py-cpuinfo in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from tables->pvlib==0.8.0+3.gdc81df7.dirty) (9.0.0)
Requirement already satisfied: blosc2>=2.3.0 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from tables->pvlib==0.8.0+3.gdc81df7.dirty) (2.5.1)
Requirement already satisfied: ndindex>=1.4 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from blosc2>=2.3.0->tables->pvlib==0.8.0+3.gdc81df7.dirty) (1.9.2)
Requirement already satisfied: msgpack in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from blosc2>=2.3.0->tables->pvlib==0.8.0+3.gdc81df7.dirty) (1.1.0)
Installing collected packages: pvlib
Attempting uninstall: pvlib
Found existing installation: pvlib 0.8.0+2.g04a523f
Uninstalling pvlib-0.8.0+2.g04a523f:
Successfully uninstalled pvlib-0.8.0+2.g04a523f
DEPRECATION: Legacy editable install of pvlib[all]==0.8.0+3.gdc81df7.dirty from file:///testbed (setup.py develop) is deprecated. pip 25.3 will enforce this behaviour change. A possible replacement is to add a pyproject.toml or enable --use-pep517, and use setuptools >= 64. If the resulting installation is not behaving as expected, try using --config-settings editable_mode=compat. Please consult the setuptools documentation for more information. Discussion can be found at https://github.com/pypa/pip/issues/11457
Running setup.py develop for pvlib
Successfully installed pvlib
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager, possibly rendering your system unusable. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv. Use the --root-user-action option if you know what you are doing and want to suppress this warning.
+ git checkout 04a523fafbd61bc2e49420963b84ed8e2bd1b3cf pvlib/tests/test_temperature.py
Updated 0 paths from 6b8d479
+ git apply -v -
Checking patch pvlib/tests/test_temperature.py...
Applied patch pvlib/tests/test_temperature.py cleanly.
+ : '>>>>> Start Test Output'
+ pytest -rA pvlib/tests/test_temperature.py
ImportError while loading conftest '/testbed/pvlib/tests/conftest.py'.
pvlib/tests/conftest.py:10: in <module>
import pvlib
pvlib/__init__.py:10: in <module>
from pvlib import ivtools # noqa: F401
pvlib/ivtools/__init__.py:7: in <module>
from pvlib.ivtools import sde, sdm, utils # noqa: F401
pvlib/ivtools/sdm.py:15: in <module>
from pvlib.pvsystem import singlediode, v_from_i
pvlib/pvsystem.py:16: in <module>
from pvlib import (atmosphere, iam, inverter, irradiance,
pvlib/singlediode.py:59: in <module>
NsVbi=np.Inf, breakdown_factor=0., breakdown_voltage=-5.5,
/opt/miniconda3/envs/testbed/lib/python3.9/site-packages/numpy/__init__.py:397: in __getattr__
raise AttributeError(
E AttributeError: `np.Inf` was removed in the NumPy 2.0 release. Use `np.inf` instead.
+ : '>>>>> End Test Output'
+ git checkout 04a523fafbd61bc2e49420963b84ed8e2bd1b3cf pvlib/tests/test_temperature.py
Updated 1 path from 6b8d479
Reference output
diff --git a/pvlib/temperature.py b/pvlib/temperature.py
--- a/pvlib/temperature.py
+++ b/pvlib/temperature.py
@@ -599,8 +599,9 @@ def fuentes(poa_global, temp_air, wind_speed, noct_installed, module_height=5,
# n.b. the way Fuentes calculates the first timedelta makes it seem like
# the value doesn't matter -- rather than recreate it here, just assume
# it's the same as the second timedelta:
- timedelta_hours = np.diff(poa_global.index).astype(float) / 1e9 / 60 / 60
- timedelta_hours = np.append([timedelta_hours[0]], timedelta_hours)
+ timedelta_seconds = poa_global.index.to_series().diff().dt.total_seconds()
+ timedelta_hours = timedelta_seconds / 3600
+ timedelta_hours.iloc[0] = timedelta_hours.iloc[1]
tamb_array = temp_air + 273.15
sun_array = poa_global * absorp
marshmallow-code__marshmallow-1359
marshmallow-code/marshmallow
Score
0%
Outcome
Did not pass
Task cost
$0.33
Duration
153 s
Summary
Did not pass
Not resolved by official SWE-bench grading. Fail-to-pass: 0%. Pass-to-pass: 0%.
View task details
Run metadata
Benchmark
swe_bench/lite/dev
Model
claude-sonnet-4-5-20250929
Started
Mar 31, 2026, 2:06 AM UTC
Completed
Mar 31, 2026, 2:09 AM UTC
Sandbox
5834ecbb-75b1-466d-9322-68bc15d3ba2e
Tokens
In 32,694 / out 8,192
F2P / P2P
0% / 0%
Passed benchmark
No
Completed
miniconda3/envs/testbed/lib/python3.9/site-packages (from virtualenv>=15.2->pre-commit~=1.17->marshmallow==3.0.0) (0.3.9)
Requirement already satisfied: filelock<4,>=3.12.2 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from virtualenv>=15.2->pre-commit~=1.17->marshmallow==3.0.0) (3.18.0)
Requirement already satisfied: platformdirs<5,>=3.9.1 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from virtualenv>=15.2->pre-commit~=1.17->marshmallow==3.0.0) (4.3.7)
Requirement already satisfied: exceptiongroup>=1.0.0rc8 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pytest->marshmallow==3.0.0) (1.2.2)
Requirement already satisfied: iniconfig in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pytest->marshmallow==3.0.0) (2.1.0)
Requirement already satisfied: packaging in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pytest->marshmallow==3.0.0) (25.0)
Requirement already satisfied: pluggy<2,>=1.5 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pytest->marshmallow==3.0.0) (1.5.0)
Requirement already satisfied: tomli>=1 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pytest->marshmallow==3.0.0) (2.2.1)
Requirement already satisfied: cachetools>=5.5.1 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from tox->marshmallow==3.0.0) (5.5.2)
Requirement already satisfied: chardet>=5.2 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from tox->marshmallow==3.0.0) (5.2.0)
Requirement already satisfied: colorama>=0.4.6 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from tox->marshmallow==3.0.0) (0.4.6)
Requirement already satisfied: pyproject-api>=1.8 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from tox->marshmallow==3.0.0) (1.9.0)
Requirement already satisfied: typing-extensions>=4.12.2 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from tox->marshmallow==3.0.0) (4.15.0)
Building wheels for collected packages: marshmallow
Building editable for marshmallow (pyproject.toml): started
Building editable for marshmallow (pyproject.toml): finished with status 'done'
Created wheel for marshmallow: filename=marshmallow-3.0.0-0.editable-py2.py3-none-any.whl size=4552 sha256=ebe6eb9a87531162a1aad15a1bfe051c79e014f4baef10744174f7f0438b2dd4
Stored in directory: /tmp/pip-ephem-wheel-cache-c5v2wpmt/wheels/7d/66/67/70d1ee2124ccf21d601c352e25cdca10f611f7c8b3f9ffb9e4
Successfully built marshmallow
Installing collected packages: marshmallow
Attempting uninstall: marshmallow
Found existing installation: marshmallow 3.0.0
Uninstalling marshmallow-3.0.0:
Successfully uninstalled marshmallow-3.0.0
Successfully installed marshmallow-3.0.0
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager, possibly rendering your system unusable. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv. Use the --root-user-action option if you know what you are doing and want to suppress this warning.
+ git checkout b40a0f4e33823e6d0f341f7e8684e359a99060d1 tests/test_fields.py
Updated 0 paths from 56ab4168
+ git apply -v -
Checking patch tests/test_fields.py...
Applied patch tests/test_fields.py cleanly.
+ : '>>>>> Start Test Output'
+ pytest -rA tests/test_fields.py
ImportError while loading conftest '/testbed/tests/conftest.py'.
tests/conftest.py:4: in <module>
from tests.base import User, UserSchema, Blog
tests/base.py:9: in <module>
from marshmallow import Schema, fields, post_load, validate, missing
src/marshmallow/__init__.py:1: in <module>
from marshmallow.schema import Schema, SchemaOpts
E File "/testbed/src/marshmallow/schema.py", line 388
E elif field_obj
E ^
E SyntaxError: invalid syntax
+ : '>>>>> End Test Output'
+ git checkout b40a0f4e33823e6d0f341f7e8684e359a99060d1 tests/test_fields.py
Updated 1 path from 56ab4168
Open in DaytonaBenchmark context
Task input
3.0: DateTime fields cannot be used as inner field for List or Tuple fields
Between releases 3.0.0rc8 and 3.0.0rc9, `DateTime` fields have started throwing an error when being instantiated as inner fields of container fields like `List` or `Tuple`. The snippet below works in <=3.0.0rc8 and throws the error below in >=3.0.0rc9 (and, worryingly, 3.0.0):
```python
from marshmallow import fields, Schema
class MySchema(Schema):
times = fields.List(fields.DateTime())
s = MySchema()
```
Traceback:
```
Traceback (most recent call last):
File "test-mm.py", line 8, in <module>
s = MySchema()
File "/Users/victor/.pyenv/versions/marshmallow/lib/python3.6/site-packages/marshmallow/schema.py", line 383, in __init__
self.fields = self._init_fields()
File "/Users/victor/.pyenv/versions/marshmallow/lib/python3.6/site-packages/marshmallow/schema.py", line 913, in _init_fields
self._bind_field(field_name, field_obj)
File "/Users/victor/.pyenv/versions/marshmallow/lib/python3.6/site-packages/marshmallow/schema.py", line 969, in _bind_field
field_obj._bind_to_schema(field_name, self)
File "/Users/victor/.pyenv/versions/marshmallow/lib/python3.6/site-packages/marshmallow/fields.py", line 636, in _bind_to_schema
self.inner._bind_to_schema(field_name, self)
File "/Users/victor/.pyenv/versions/marshmallow/lib/python3.6/site-packages/marshmallow/fields.py", line 1117, in _bind_to_schema
or getattr(schema.opts, self.SCHEMA_OPTS_VAR_NAME)
AttributeError: 'List' object has no attribute 'opts'
```
It seems like it's treating the parent field as a Schema without checking that it is indeed a schema, so the `schema.opts` statement fails as fields don't have an `opts` attribute.
Fix tests
tests/test_fields.py::TestParentAndName::test_datetime_list_inner_format
Regression tests
tests/test_fields.py::test_field_aliases[Integer-Integer] tests/test_fields.py::test_field_aliases[String-String] tests/test_fields.py::test_field_aliases[Boolean-Boolean] tests/test_fields.py::test_field_aliases[Url-Url] tests/test_fields.py::TestField::test_repr tests/test_fields.py::TestField::test_error_raised_if_uncallable_validator_passed tests/test_fields.py::TestField::test_error_raised_if_missing_is_set_on_required_field tests/test_fields.py::TestField::test_custom_field_receives_attr_and_obj tests/test_fields.py::TestField::test_custom_field_receives_data_key_if_set tests/test_fields.py::TestField::test_custom_field_follows_data_key_if_set tests/test_fields.py::TestParentAndName::test_simple_field_parent_and_name tests/test_fields.py::TestParentAndName::test_unbound_field_root_returns_none tests/test_fields.py::TestParentAndName::test_list_field_inner_parent_and_name tests/test_fields.py::TestParentAndName::test_tuple_field_inner_parent_and_name tests/test_fields.py::TestParentAndName::test_mapping_field_inner_parent_and_name tests/test_fields.py::TestParentAndName::test_simple_field_root tests/test_fields.py::TestParentAndName::test_list_field_inner_root tests/test_fields.py::TestParentAndName::test_tuple_field_inner_root tests/test_fields.py::TestParentAndName::test_list_root_inheritance tests/test_fields.py::TestParentAndName::test_dict_root_inheritance tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[String] tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Integer] tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Boolean] tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Float] tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Number] tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[DateTime] tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Time] tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Date] tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[TimeDelta] tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Dict] tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Url] tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Email] tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[UUID] tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Decimal] tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages_cstm_msg tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages tests/test_fields.py::TestErrorMessages::test_make_error[required-Missing tests/test_fields.py::TestErrorMessages::test_make_error[null-Field tests/test_fields.py::TestErrorMessages::test_make_error[custom-Custom tests/test_fields.py::TestErrorMessages::test_make_error[validator_failed-Invalid tests/test_fields.py::TestErrorMessages::test_fail[required-Missing tests/test_fields.py::TestErrorMessages::test_fail[null-Field tests/test_fields.py::TestErrorMessages::test_fail[custom-Custom tests/test_fields.py::TestErrorMessages::test_fail[validator_failed-Invalid tests/test_fields.py::TestErrorMessages::test_make_error_key_doesnt_exist tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[only] tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[exclude] tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-exclude] tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-include] tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-raise] tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-exclude] tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-include] tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-raise] tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-exclude] tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-include] tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-raise] tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-exclude] tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-include] tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-raise] tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[only] tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude] tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only] tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only] tests/test_fields.py::TestListNested::test_list_nested_only_and_exclude_merged_with_nested[only-expected0] tests/test_fields.py::TestListNested::test_list_nested_only_and_exclude_merged_with_nested[exclude-expected1] tests/test_fields.py::TestListNested::test_list_nested_partial_propagated_to_nested tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only] tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only] tests/test_fields.py::TestTupleNested::test_tuple_nested_partial_propagated_to_nested tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[only] tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude] tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only] tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only] tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[only-expected0] tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[exclude-expected1] tests/test_fields.py::TestDictNested::test_dict_nested_partial_propagated_to_nested
Execution
Scorer detail
Not resolved by official SWE-bench grading. Fail-to-pass: 0%. Pass-to-pass: 0%.
Patch text
diff --git a/src/marshmallow/schema.py b/src/marshmallow/schema.py
index 520ffb44..7c428285 100644
--- a/src/marshmallow/schema.py
+++ b/src/marshmallow/schema.py
@@ -385,756 +385,4 @@ class BaseSchema(base.SchemaABC):
for field_name, field_obj in self.fields.items():
if field_obj.load_only:
self.load_fields[field_name] = field_obj
- elif field_obj.dump_only:
- self.dump_fields[field_name] = field_obj
- else:
- self.load_fields[field_name] = field_obj
- self.dump_fields[field_name] = field_obj
- messages = {}
- messages.update(self._default_error_messages)
- for cls in reversed(self.__class__.__mro__):
- messages.update(getattr(cls, "error_messages", {}))
- messages.update(self.error_messages or {})
- self.error_messages = messages
-
- def __repr__(self):
- return "<{ClassName}(many={self.many})>".format(
- ClassName=self.__class__.__name__, self=self
- )
-
- @property
- def dict_class(self):
- return OrderedDict if self.ordered else dict
-
- @property
- def set_class(self):
- return OrderedSet if self.ordered else set
-
- @classmethod
- def from_dict(
- cls, fields: typing.Dict[str, ma_fields.Field], *, name: str = "GeneratedSchema"
- ) -> typing.Type["Schema"]:
- """Generate a `Schema` class given a dictionary of fields.
-
- .. code-block:: python
-
- from marshmallow import Schema, fields
-
- PersonSchema = Schema.from_dict({"name": fields.Str()})
- print(PersonSchema().load({"name": "David"})) # => {'name': 'David'}
-
- Generated schemas are not added to the class registry and therefore cannot
- be referred to by name in `Nested` fields.
-
- :param dict fields: Dictionary mapping field names to field instances.
- :param str name: Optional name for the class, which will appear in
- the ``repr`` for the class.
-
- .. versionadded:: 3.0.0
- """
- attrs = fields.copy()
- attrs["Meta"] = type(
- "GeneratedMeta", (getattr(cls, "Meta", object),), {"register": False}
- )
- schema_cls = type(name, (cls,), attrs)
- return schema_cls
-
- ##### Override-able methods #####
-
- def handle_error(self, error, data, *, many, **kwargs):
- """Custom error handler function for the schema.
-
- :param ValidationError error: The `ValidationError` raised during (de)serialization.
- :param data: The original input data.
- :param bool many: Value of ``many`` on dump or load.
- :param bool partial: Value of ``partial`` on load.
-
- .. versionadded:: 2.0.0
-
- .. versionchanged:: 3.0.0rc9
- Receives `many` and `partial` (on deserialization) as keyword arguments.
- """
- pass
-
- def get_attribute(self, obj, attr, default):
- """Defines how to pull values from an object to serialize.
-
- .. versionadded:: 2.0.0
-
- .. versionchanged:: 3.0.0a1
- Changed position of ``obj`` and ``attr``.
- """
- return get_value(obj, attr, default)
-
- ##### Serialization/Deserialization API #####
-
- @staticmethod
- def _call_and_store(getter_func, data, *, field_name, error_store, index=None):
- """Call ``getter_func`` with ``data`` as its argument, and store any `ValidationErrors`.
-
- :param callable getter_func: Function for getting the serialized/deserialized
- value from ``data``.
- :param data: The data passed to ``getter_func``.
- :param str field_name: Field name.
- :param int index: Index of the item being validated, if validating a collection,
- otherwise `None`.
- """
- try:
- value = getter_func(data)
- except ValidationError as error:
- error_store.store_error(error.messages, field_name, index=index)
- # When a Nested field fails validation, the marshalled data is stored
- # on the ValidationError's valid_data attribute
- return error.valid_data or missing
- return value
-
- def _serialize(self, obj, *, many=False):
- """Serialize ``obj``.
-
- :param obj: The object(s) to serialize.
- :param bool many: `True` if ``data`` should be serialized as a collection.
- :return: A dictionary of the serialized data
-
- .. versionchanged:: 1.0.0
- Renamed from ``marshal``.
- """
- if many and obj is not None:
- return [self._serialize(d, many=False) for d in obj]
- ret = self.dict_class()
- for attr_name, field_obj in self.dump_fields.items():
- value = field_obj.serialize(attr_name, obj, accessor=self.get_attribute)
- if value is missing:
- continue
- key = field_obj.data_key or attr_name
- ret[key] = value
- return ret
-
- def dump(self, obj, *, many=None):
- """Serialize an object to native Python data types according to this
- Schema's fields.
-
- :param obj: The object to serialize.
- :param bool many: Whether to serialize `obj` as a collection. If `None`, the value
- for `self.many` is used.
- :return: A dict of serialized data
- :rtype: dict
-
- .. versionadded:: 1.0.0
- .. versionchanged:: 3.0.0b7
- This method returns the serialized data rather than a ``(data, errors)`` duple.
- A :exc:`ValidationError <marshmallow.exceptions.ValidationError>` is raised
- if ``obj`` is invalid.
- .. versionchanged:: 3.0.0rc9
- Validation no longer occurs upon serialization.
- """
- many = self.many if many is None else bool(many)
- if many and is_iterable_but_not_string(obj):
- obj = list(obj)
-
- if self._has_processors(PRE_DUMP):
- processed_obj = self._invoke_dump_processors(
- PRE_DUMP, obj, many=many, original_data=obj
- )
- else:
- processed_obj = obj
-
- result = self._serialize(processed_obj, many=many)
-
- if self._has_processors(POST_DUMP):
- result = self._invoke_dump_processors(
- POST_DUMP, result, many=many, original_data=obj
- )
-
- return result
-
- def dumps(self, obj, *args, many=None, **kwargs):
- """Same as :meth:`dump`, except return a JSON-encoded string.
-
- :param obj: The object to serialize.
- :param bool many: Whether to serialize `obj` as a collection. If `None`, the value
- for `self.many` is used.
- :return: A ``json`` string
- :rtype: str
-
- .. versionadded:: 1.0.0
- .. versionchanged:: 3.0.0b7
- This method returns the serialized data rather than a ``(data, errors)`` duple.
- A :exc:`ValidationError <marshmallow.exceptions.ValidationError>` is raised
- if ``obj`` is invalid.
- """
- serialized = self.dump(obj, many=many)
- return self.opts.render_module.dumps(serialized, *args, **kwargs)
-
- def _deserialize(
- self, data, *, error_store, many=False, partial=False, unknown=RAISE, index=None
- ):
- """Deserialize ``data``.
-
- :param dict data: The data to deserialize.
- :param ErrorStore error_store: Structure to store errors.
- :param bool many: `True` if ``data`` should be deserialized as a collection.
- :param bool|tuple partial: Whether to ignore missing fields and not require
- any fields declared. Propagates down to ``Nested`` fields as well. If
- its value is an iterable, only missing fields listed in that iterable
- will be ignored. Use dot delimiters to specify nested fields.
- :param unknown: Whether to exclude, include, or raise an error for unknown
- fields in the data. Use `EXCLUDE`, `INCLUDE` or `RAISE`.
- :param int index: Index of the item being serialized (for storing errors) if
- serializing a collection, otherwise `None`.
- :return: A dictionary of the deserialized data.
- """
- index_errors = self.opts.index_errors
- index = index if index_errors else None
- if many:
- if not is_collection(data):
- error_store.store_error([self.error_messages["type"]], index=index)
- ret = []
- else:
- ret = [
- self._deserialize(
- d,
- error_store=error_store,
- many=False,
- partial=partial,
- unknown=unknown,
- index=idx,
- )
- for idx, d in enumerate(data)
- ]
- return ret
- ret = self.dict_class()
- # Check data is a dict
- if not isinstance(data, Mapping):
- error_store.store_error([self.error_messages["type"]], index=index)
- else:
- partial_is_collection = is_collection(partial)
- for attr_name, field_obj in self.load_fields.items():
- field_name = field_obj.data_key or attr_name
- raw_value = data.get(field_name, missing)
- if raw_value is missing:
- # Ignore missing field if we're allowed to.
- if partial is True or (
- partial_is_collection and attr_name in partial
- ):
- continue
- d_kwargs = {}
- # Allow partial loading of nested schemas.
- if partial_is_collection:
- prefix = field_name + "."
- len_prefix = len(prefix)
- sub_partial = [
- f[len_prefix:] for f in partial if f.startswith(prefix)
- ]
- d_kwargs["partial"] = sub_partial
- else:
- d_kwargs["partial"] = partial
- getter = lambda val: field_obj.deserialize(
- val, field_name, data, **d_kwargs
- )
- value = self._call_and_store(
- getter_func=getter,
- data=raw_value,
- field_name=field_name,
- error_store=error_store,
- index=index,
- )
- if value is not missing:
- key = field_obj.attribute or attr_name
- set_value(ret, key, value)
- if unknown != EXCLUDE:
- fields = {
- field_obj.data_key or field_name
- for field_name, field_obj in self.load_fields.items()
- }
- for key in set(data) - fields:
- value = data[key]
- if unknown == INCLUDE:
- set_value(ret, key, value)
- elif unknown == RAISE:
- error_store.store_error(
- [self.error_messages["unknown"]],
- key,
- (index if index_errors else None),
- )
- return ret
-
- def load(self, data, *, many=None, partial=None, unknown=None):
- """Deserialize a data structure to an object defined by this Schema's fields.
-
- :param dict data: The data to deserialize.
- :param bool many: Whether to deserialize `data` as a collection. If `None`, the
- value for `self.many` is used.
- :param bool|tuple partial: Whether to ignore missing fields and not require
- any fields declared. Propagates down to ``Nested`` fields as well. If
- its value is an iterable, only missing fields listed in that iterable
- will be ignored. Use dot delimiters to specify nested fields.
- :param unknown: Whether to exclude, include, or raise an error for unknown
- fields in the data. Use `EXCLUDE`, `INCLUDE` or `RAISE`.
- If `None`, the value for `self.unknown` is used.
- :return: A dict of deserialized data
- :rtype: dict
-
- .. versionadded:: 1.0.0
- .. versionchanged:: 3.0.0b7
- This method returns the deserialized data rather than a ``(data, errors)`` duple.
- A :exc:`ValidationError <marshmallow.exceptions.ValidationError>` is raised
- if invalid data are passed.
- """
- return self._do_load(
- data, many=many, partial=partial, unknown=unknown, postprocess=True
- )
-
- def loads(self, json_data, *, many=None, partial=None, unknown=None, **kwargs):
- """Same as :meth:`load`, except it takes a JSON string as input.
-
- :param str json_data: A JSON string of the data to deserialize.
- :param bool many: Whether to deserialize `obj` as a collection. If `None`, the
- value for `self.many` is used.
- :param bool|tuple partial: Whether to ignore missing fields and not require
- any fields declared. Propagates down to ``Nested`` fields as well. If
- its value is an iterable, only missing fields listed in that iterable
- will be ignored. Use dot delimiters to specify nested fields.
- :param unknown: Whether to exclude, include, or raise an error for unknown
- fields in the data. Use `EXCLUDE`, `INCLUDE` or `RAISE`.
- If `None`, the value for `self.unknown` is used.
- :return: A dict of deserialized data
- :rtype: dict
-
- .. versionadded:: 1.0.0
- .. versionchanged:: 3.0.0b7
- This method returns the deserialized data rather than a ``(data, errors)`` duple.
- A :exc:`ValidationError <marshmallow.exceptions.ValidationError>` is raised
- if invalid data are passed.
- """
- data = self.opts.render_module.loads(json_data, **kwargs)
- return self.load(data, many=many, partial=partial, unknown=unknown)
-
- def _run_validator(
- self,
- validator_func,
- output,
- *,
- original_data,
- error_store,
- many,
- partial,
- pass_original,
- index=None
- ):
- try:
- if pass_original: # Pass original, raw data (before unmarshalling)
- validator_func(output, original_data, partial=partial, many=many)
- else:
- validator_func(output, partial=partial, many=many)
- except ValidationError as err:
- error_store.store_error(err.messages, err.field_name, index=index)
-
- def validate(self, data, *, many=None, partial=None):
- """Validate `data` against the schema, returning a dictionary of
- validation errors.
-
- :param dict data: The data to validate.
- :param bool many: Whether to validate `data` as a collection. If `None`, the
- value for `self.many` is used.
- :param bool|tuple partial: Whether to ignore missing fields and not require
- any fields declared. Propagates down to ``Nested`` fields as well. If
- its value is an iterable, only missing fields listed in that iterable
- will be ignored. Use dot delimiters to specify nested fields.
- :return: A dictionary of validation errors.
- :rtype: dict
-
- .. versionadded:: 1.1.0
- """
- try:
- self._do_load(data, many=many, partial=partial, postprocess=False)
- except ValidationError as exc:
- return exc.messages
- return {}
-
- ##### Private Helpers #####
-
- def _do_load(
- self, data, *, many=None, partial=None, unknown=None, postprocess=True
- ):
- """Deserialize `data`, returning the deserialized result.
-
- :param data: The data to deserialize.
- :param bool many: Whether to deserialize `data` as a collection. If `None`, the
- value for `self.many` is used.
- :param bool|tuple partial: Whether to validate required fields. If its
- value is an iterable, only fields listed in that iterable will be
- ignored will be allowed missing. If `True`, all fields will be allowed missing.
- If `None`, the value for `self.partial` is used.
- :param unknown: Whether to exclude, include, or raise an error for unknown
- fields in the data. Use `EXCLUDE`, `INCLUDE` or `RAISE`.
- If `None`, the value for `self.unknown` is used.
- :param bool postprocess: Whether to run post_load methods..
- :return: A dict of deserialized data
- :rtype: dict
- """
- error_store = ErrorStore()
- errors = {}
- many = self.many if many is None else bool(many)
- unknown = unknown or self.unknown
- if partial is None:
- partial = self.partial
- # Run preprocessors
- if self._has_processors(PRE_LOAD):
- try:
- processed_data = self._invoke_load_processors(
- PRE_LOAD, data, many=many, original_data=data, partial=partial
- )
- except ValidationError as err:
- errors = err.normalized_messages()
- result = None
- else:
- processed_data = data
- if not errors:
- # Deserialize data
- result = self._deserialize(
- processed_data,
- error_store=error_store,
- many=many,
- partial=partial,
- unknown=unknown,
- )
- # Run field-level validation
- self._invoke_field_validators(
- error_store=error_store, data=result, many=many
- )
- # Run schema-level validation
- if self._has_processors(VALIDATES_SCHEMA):
- field_errors = bool(error_store.errors)
- self._invoke_schema_validators(
- error_store=error_store,
- pass_many=True,
- data=result,
- original_data=data,
- many=many,
- partial=partial,
- field_errors=field_errors,
- )
- self._invoke_schema_validators(
- error_store=error_store,
- pass_many=False,
- data=result,
- original_data=data,
- many=many,
- partial=partial,
- field_errors=field_errors,
- )
- errors = error_store.errors
- # Run post processors
- if not errors and postprocess and self._has_processors(POST_LOAD):
- try:
- result = self._invoke_load_processors(
- POST_LOAD,
- result,
- many=many,
- original_data=data,
- partial=partial,
- )
- except ValidationError as err:
- errors = err.normalized_messages()
- if errors:
- exc = ValidationError(errors, data=data, valid_data=result)
- self.handle_error(exc, data, many=many, partial=partial)
- raise exc
-
- return result
-
- def _normalize_nested_options(self):
- """Apply then flatten nested schema options"""
- if self.only is not None:
- # Apply the only option to nested fields.
- self.__apply_nested_option("only", self.only, "intersection")
- # Remove the child field names from the only option.
- self.only = self.set_class([field.split(".", 1)[0] for field in self.only])
- if self.exclude:
- # Apply the exclude option to nested fields.
- self.__apply_nested_option("exclude", self.exclude, "union")
- # Remove the parent field names from the exclude option.
- self.exclude = self.set_class(
- [field for field in self.exclude if "." not in field]
- )
-
- def __apply_nested_option(self, option_name, field_names, set_operation):
- """Apply nested options to nested fields"""
- # Split nested field names on the first dot.
- nested_fields = [name.split(".", 1) for name in field_names if "." in name]
- # Partition the nested field names by parent field.
- nested_options = defaultdict(list)
- for parent, nested_names in nested_fields:
- nested_options[parent].append(nested_names)
- # Apply the nested field options.
- for key, options in iter(nested_options.items()):
- new_options = self.set_class(options)
- original_options = getattr(self.declared_fields[key], option_name, ())
- if original_options:
- if set_operation == "union":
- new_options |= self.set_class(original_options)
- if set_operation == "intersection":
- new_options &= self.set_class(original_options)
- setattr(self.declared_fields[key], option_name, new_options)
-
- def _init_fields(self):
- """Update fields based on schema options."""
- if self.opts.fields:
- available_field_names = self.set_class(self.opts.fields)
- else:
- available_field_names = self.set_class(self.declared_fields.keys())
- if self.opts.additional:
- available_field_names |= self.set_class(self.opts.additional)
-
- invalid_fields = self.set_class()
-
- if self.only is not None:
- # Return only fields specified in only option
- field_names = self.set_class(self.only)
-
- invalid_fields |= field_names - available_field_names
- else:
- field_names = available_field_names
-
- # If "exclude" option or param is specified, remove those fields.
- if self.exclude:
- # Note that this isn't available_field_names, since we want to
- # apply "only" for the actual calculation.
- field_names = field_names - self.exclude
- invalid_fields |= self.exclude - available_field_names
-
- if invalid_fields:
- message = "Invalid fields for {}: {}.".format(self, invalid_fields)
- raise ValueError(message)
-
- fields_dict = self.dict_class()
- for field_name in field_names:
- field_obj = self.declared_fields.get(field_name, ma_fields.Inferred())
- self._bind_field(field_name, field_obj)
- fields_dict[field_name] = field_obj
-
- dump_data_keys = [
- obj.data_key or name
- for name, obj in fields_dict.items()
- if not obj.load_only
- ]
- if len(dump_data_keys) != len(set(dump_data_keys)):
- data_keys_duplicates = {
- x for x in dump_data_keys if dump_data_keys.count(x) > 1
- }
- raise ValueError(
- "The data_key argument for one or more fields collides "
- "with another field's name or data_key argument. "
- "Check the following field names and "
- "data_key arguments: {}".format(list(data_keys_duplicates))
- )
-
- load_attributes = [
- obj.attribute or name
- for name, obj in fields_dict.items()
- if not obj.dump_only
- ]
- if len(load_attributes) != len(set(load_attributes)):
- attributes_duplicates = {
- x for x in load_attributes if load_attributes.count(x) > 1
- }
- raise ValueError(
- "The attribute argument for one or more fields collides "
- "with another field's name or attribute argument. "
- "Check the following field names and "
- "attribute arguments: {}".format(list(attributes_duplicates))
- )
-
- return fields_dict
-
- def on_bind_field(self, field_name, field_obj):
- """Hook to modify a field when it is bound to the `Schema`.
-
- No-op by default.
- """
- return None
-
- def _bind_field(self, field_name, field_obj):
- """Bind field to the schema, setting any necessary attributes on the
- field (e.g. parent and name).
-
- Also set field load_only and dump_only values if field_name was
- specified in ``class Meta``.
- """
- try:
- if field_name in self.load_only:
- field_obj.load_only = True
- if field_name in self.dump_only:
- field_obj.dump_only = True
- field_obj._bind_to_schema(field_name, self)
- self.on_bind_field(field_name, field_obj)
- except TypeError as error:
- # field declared as a class, not an instance
- if isinstance(field_obj, type) and issubclass(field_obj, base.FieldABC):
- msg = (
- 'Field for "{}" must be declared as a '
- "Field instance, not a class. "
- 'Did you mean "fields.{}()"?'.format(field_name, field_obj.__name__)
- )
- raise TypeError(msg) from error
-
- @lru_cache(maxsize=8)
- def _has_processors(self, tag):
- return self._hooks[(tag, True)] or self._hooks[(tag, False)]
-
- def _invoke_dump_processors(self, tag, data, *, many, original_data=None):
- # The pass_many post-dump processors may do things like add an envelope, so
- # invoke those after invoking the non-pass_many processors which will expect
- # to get a list of items.
- data = self._invoke_processors(
- tag, pass_many=False, data=data, many=many, original_data=original_data
- )
- data = self._invoke_processors(
- tag, pass_many=True, data=data, many=many, original_data=original_data
- )
- return data
-
- def _invoke_load_processors(self, tag, data, *, many, original_data, partial):
- # This has to invert the order of the dump processors, so run the pass_many
- # processors first.
- data = self._invoke_processors(
- tag,
- pass_many=True,
- data=data,
- many=many,
- original_data=original_data,
- partial=partial,
- )
- data = self._invoke_processors(
- tag,
- pass_many=False,
- data=data,
- many=many,
- original_data=original_data,
- partial=partial,
- )
- return data
-
- def _invoke_field_validators(self, *, error_store, data, many):
- for attr_name in self._hooks[VALIDATES]:
- validator = getattr(self, attr_name)
- validator_kwargs = validator.__marshmallow_hook__[VALIDATES]
- field_name = validator_kwargs["field_name"]
-
- try:
- field_obj = self.fields[field_name]
- except KeyError as error:
- if field_name in self.declared_fields:
- continue
- raise ValueError(
- '"{}" field does not exist.'.format(field_name)
- ) from error
-
- if many:
- for idx, item in enumerate(data):
- try:
- value = item[field_obj.attribute or field_name]
- except KeyError:
- pass
- else:
- validated_value = self._call_and_store(
- getter_func=validator,
- data=value,
- field_name=field_obj.data_key or field_name,
- error_store=error_store,
- index=(idx if self.opts.index_errors else None),
- )
- if validated_value is missing:
- data[idx].pop(field_name, None)
- else:
- try:
- value = data[field_obj.attribute or field_name]
- except KeyError:
- pass
- else:
- validated_value = self._call_and_store(
- getter_func=validator,
- data=value,
- field_name=field_obj.data_key or field_name,
- error_store=error_store,
- )
- if validated_value is missing:
- data.pop(field_name, None)
-
- def _invoke_schema_validators(
- self,
- *,
- error_store,
- pass_many,
- data,
- original_data,
- many,
- partial,
- field_errors=False
- ):
- for attr_name in self._hooks[(VALIDATES_SCHEMA, pass_many)]:
- validator = getattr(self, attr_name)
- validator_kwargs = validator.__marshmallow_hook__[
- (VALIDATES_SCHEMA, pass_many)
- ]
- if field_errors and validator_kwargs["skip_on_field_errors"]:
- continue
- pass_original = validator_kwargs.get("pass_original", False)
-
- if many and not pass_many:
- for idx, (item, orig) in enumerate(zip(data, original_data)):
- self._run_validator(
- validator,
- item,
- original_data=orig,
- error_store=error_store,
- many=many,
- partial=partial,
- index=idx,
- pass_original=pass_original,
- )
- else:
- self._run_validator(
- validator,
- data,
- original_data=original_data,
- error_store=error_store,
- many=many,
- pass_original=pass_original,
- partial=partial,
- )
-
- def _invoke_processors(
- self, tag, *, pass_many, data, many, original_data=None, **kwargs
- ):
- key = (tag, pass_many)
- for attr_name in self._hooks[key]:
- # This will be a bound method.
- processor = getattr(self, attr_name)
-
- processor_kwargs = processor.__marshmallow_hook__[key]
- pass_original = processor_kwargs.get("pass_original", False)
-
- if pass_many:
- if pass_original:
- data = processor(data, original_data, many=many, **kwargs)
- else:
- data = processor(data, many=many, **kwargs)
- elif many:
- if pass_original:
- data = [
- processor(item, original, many=many, **kwargs)
- for item, original in zip(data, original_data)
- ]
- else:
- data = [processor(item, many=many, **kwargs) for item in data]
- else:
- if pass_original:
- data = processor(data, original_data, many=many, **kwargs)
- else:
- data = processor(data, many=many, **kwargs)
- return data
-
-
-class Schema(BaseSchema, metaclass=SchemaMeta):
- __doc__ = BaseSchema.__doc__
+ elif field_obj
\ No newline at end of fileStdout
[anthropic-agent] instance=marshmallow-code__marshmallow-1359 [anthropic-agent] repo=marshmallow-code/marshmallow [anthropic-agent] sandbox=5834ecbb-75b1-466d-9322-68bc15d3ba2e [anthropic-agent] model=claude-sonnet-4-5-20250929 [anthropic-agent] context_files=6 [anthropic-agent] full_file_context=yes [anthropic-agent] edit_attempts=2
Stderr
[anthropic-agent] Attempt 1: File-rewrite plan contained no files.
Agent output
diff --git a/src/marshmallow/schema.py b/src/marshmallow/schema.py
index 520ffb44..7c428285 100644
--- a/src/marshmallow/schema.py
+++ b/src/marshmallow/schema.py
@@ -385,756 +385,4 @@ class BaseSchema(base.SchemaABC):
for field_name, field_obj in self.fields.items():
if field_obj.load_only:
self.load_fields[field_name] = field_obj
- elif field_obj.dump_only:
- self.dump_fields[field_name] = field_obj
- else:
- self.load_fields[field_name] = field_obj
- self.dump_fields[field_name] = field_obj
- messages = {}
- messages.update(self._default_error_messages)
- for cls in reversed(self.__class__.__mro__):
- messages.update(getattr(cls, "error_messages", {}))
- messages.update(self.error_messages or {})
- self.error_messages = messages
-
- def __repr__(self):
- return "<{ClassName}(many={self.many})>".format(
- ClassName=self.__class__.__name__, self=self
- )
-
- @property
- def dict_class(self):
- return OrderedDict if self.ordered else dict
-
- @property
- def set_class(self):
- return OrderedSet if self.ordered else set
-
- @classmethod
- def from_dict(
- cls, fields: typing.Dict[str, ma_fields.Field], *, name: str = "GeneratedSchema"
- ) -> typing.Type["Schema"]:
- """Generate a `Schema` class given a dictionary of fields.
-
- .. code-block:: python
-
- from marshmallow import Schema, fields
-
- PersonSchema = Schema.from_dict({"name": fields.Str()})
- print(PersonSchema().load({"name": "David"})) # => {'name': 'David'}
-
- Generated schemas are not added to the class registry and therefore cannot
- be referred to by name in `Nested` fields.
-
- :param dict fields: Dictionary mapping field names to field instances.
- :param str name: Optional name for the class, which will appear in
- the ``repr`` for the class.
-
- .. versionadded:: 3.0.0
- """
- attrs = fields.copy()
- attrs["Meta"] = type(
- "GeneratedMeta", (getattr(cls, "Meta", object),), {"register": False}
- )
- schema_cls = type(name, (cls,), attrs)
- return schema_cls
-
- ##### Override-able methods #####
-
- def handle_error(self, error, data, *, many, **kwargs):
- """Custom error handler function for the schema.
-
- :param ValidationError error: The `ValidationError` raised during (de)serialization.
- :param data: The original input data.
- :param bool many: Value of ``many`` on dump or load.
- :param bool partial: Value of ``partial`` on load.
-
- .. versionadded:: 2.0.0
-
- .. versionchanged:: 3.0.0rc9
- Receives `many` and `partial` (on deserialization) as keyword arguments.
- """
- pass
-
- def get_attribute(self, obj, attr, default):
- """Defines how to pull values from an object to serialize.
-
- .. versionadded:: 2.0.0
-
- .. versionchanged:: 3.0.0a1
- Changed position of ``obj`` and ``attr``.
- """
- return get_value(obj, attr, default)
-
- ##### Serialization/Deserialization API #####
-
- @staticmethod
- def _call_and_store(getter_func, data, *, field_name, error_store, index=None):
- """Call ``getter_func`` with ``data`` as its argument, and store any `ValidationErrors`.
-
- :param callable getter_func: Function for getting the serialized/deserialized
- value from ``data``.
- :param data: The data passed to ``getter_func``.
- :param str field_name: Field name.
- :param int index: Index of the item being validated, if validating a collection,
- otherwise `None`.
- """
- try:
- value = getter_func(data)
- except ValidationError as error:
- error_store.store_error(error.messages, field_name, index=index)
- # When a Nested field fails validation, the marshalled data is stored
- # on the ValidationError's valid_data attribute
- return error.valid_data or missing
- return value
-
- def _serialize(self, obj, *, many=False):
- """Serialize ``obj``.
-
- :param obj: The object(s) to serialize.
- :param bool many: `True` if ``data`` should be serialized as a collection.
- :return: A dictionary of the serialized data
-
- .. versionchanged:: 1.0.0
- Renamed from ``marshal``.
- """
- if many and obj is not None:
- return [self._serialize(d, many=False) for d in obj]
- ret = self.dict_class()
- for attr_name, field_obj in self.dump_fields.items():
- value = field_obj.serialize(attr_name, obj, accessor=self.get_attribute)
- if value is missing:
- continue
- key = field_obj.data_key or attr_name
- ret[key] = value
- return ret
-
- def dump(self, obj, *, many=None):
- """Serialize an object to native Python data types according to this
- Schema's fields.
-
- :param obj: The object to serialize.
- :param bool many: Whether to serialize `obj` as a collection. If `None`, the value
- for `self.many` is used.
- :return: A dict of serialized data
- :rtype: dict
-
- .. versionadded:: 1.0.0
- .. versionchanged:: 3.0.0b7
- This method returns the serialized data rather than a ``(data, errors)`` duple.
- A :exc:`ValidationError <marshmallow.exceptions.ValidationError>` is raised
- if ``obj`` is invalid.
- .. versionchanged:: 3.0.0rc9
- Validation no longer occurs upon serialization.
- """
- many = self.many if many is None else bool(many)
- if many and is_iterable_but_not_string(obj):
- obj = list(obj)
-
- if self._has_processors(PRE_DUMP):
- processed_obj = self._invoke_dump_processors(
- PRE_DUMP, obj, many=many, original_data=obj
- )
- else:
- processed_obj = obj
-
- result = self._serialize(processed_obj, many=many)
-
- if self._has_processors(POST_DUMP):
- result = self._invoke_dump_processors(
- POST_DUMP, result, many=many, original_data=obj
- )
-
- return result
-
- def dumps(self, obj, *args, many=None, **kwargs):
- """Same as :meth:`dump`, except return a JSON-encoded string.
-
- :param obj: The object to serialize.
- :param bool many: Whether to serialize `obj` as a collection. If `None`, the value
- for `self.many` is used.
- :return: A ``json`` string
- :rtype: str
-
- .. versionadded:: 1.0.0
- .. versionchanged:: 3.0.0b7
- This method returns the serialized data rather than a ``(data, errors)`` duple.
- A :exc:`ValidationError <marshmallow.exceptions.ValidationError>` is raised
- if ``obj`` is invalid.
- """
- serialized = self.dump(obj, many=many)
- return self.opts.render_module.dumps(serialized, *args, **kwargs)
-
- def _deserialize(
- self, data, *, error_store, many=False, partial=False, unknown=RAISE, index=None
- ):
- """Deserialize ``data``.
-
- :param dict data: The data to deserialize.
- :param ErrorStore error_store: Structure to store errors.
- :param bool many: `True` if ``data`` should be deserialized as a collection.
- :param bool|tuple partial: Whether to ignore missing fields and not require
- any fields declared. Propagates down to ``Nested`` fields as well. If
- its value is an iterable, only missing fields listed in that iterable
- will be ignored. Use dot delimiters to specify nested fields.
- :param unknown: Whether to exclude, include, or raise an error for unknown
- fields in the data. Use `EXCLUDE`, `INCLUDE` or `RAISE`.
- :param int index: Index of the item being serialized (for storing errors) if
- serializing a collection, otherwise `None`.
- :return: A dictionary of the deserialized data.
- """
- index_errors = self.opts.index_errors
- index = index if index_errors else None
- if many:
- if not is_collection(data):
- error_store.store_error([self.error_messages["type"]], index=index)
- ret = []
- else:
- ret = [
- self._deserialize(
- d,
- error_store=error_store,
- many=False,
- partial=partial,
- unknown=unknown,
- index=idx,
- )
- for idx, d in enumerate(data)
- ]
- return ret
- ret = self.dict_class()
- # Check data is a dict
- if not isinstance(data, Mapping):
- error_store.store_error([self.error_messages["type"]], index=index)
- else:
- partial_is_collection = is_collection(partial)
- for attr_name, field_obj in self.load_fields.items():
- field_name = field_obj.data_key or attr_name
- raw_value = data.get(field_name, missing)
- if raw_value is missing:
- # Ignore missing field if we're allowed to.
- if partial is True or (
- partial_is_collection and attr_name in partial
- ):
- continue
- d_kwargs = {}
- # Allow partial loading of nested schemas.
- if partial_is_collection:
- prefix = field_name + "."
- len_prefix = len(prefix)
- sub_partial = [
- f[len_prefix:] for f in partial if f.startswith(prefix)
- ]
- d_kwargs["partial"] = sub_partial
- else:
- d_kwargs["partial"] = partial
- getter = lambda val: field_obj.deserialize(
- val, field_name, data, **d_kwargs
- )
- value = self._call_and_store(
- getter_func=getter,
- data=raw_value,
- field_name=field_name,
- error_store=error_store,
- index=index,
- )
- if value is not missing:
- key = field_obj.attribute or attr_name
- set_value(ret, key, value)
- if unknown != EXCLUDE:
- fields = {
- field_obj.data_key or field_name
- for field_name, field_obj in self.load_fields.items()
- }
- for key in set(data) - fields:
- value = data[key]
- if unknown == INCLUDE:
- set_value(ret, key, value)
- elif unknown == RAISE:
- error_store.store_error(
- [self.error_messages["unknown"]],
- key,
- (index if index_errors else None),
- )
- return ret
-
- def load(self, data, *, many=None, partial=None, unknown=None):
- """Deserialize a data structure to an object defined by this Schema's fields.
-
- :param dict data: The data to deserialize.
- :param bool many: Whether to deserialize `data` as a collection. If `None`, the
- value for `self.many` is used.
- :param bool|tuple partial: Whether to ignore missing fields and not require
- any fields declared. Propagates down to ``Nested`` fields as well. If
- its value is an iterable, only missing fields listed in that iterable
- will be ignored. Use dot delimiters to specify nested fields.
- :param unknown: Whether to exclude, include, or raise an error for unknown
- fields in the data. Use `EXCLUDE`, `INCLUDE` or `RAISE`.
- If `None`, the value for `self.unknown` is used.
- :return: A dict of deserialized data
- :rtype: dict
-
- .. versionadded:: 1.0.0
- .. versionchanged:: 3.0.0b7
- This method returns the deserialized data rather than a ``(data, errors)`` duple.
- A :exc:`ValidationError <marshmallow.exceptions.ValidationError>` is raised
- if invalid data are passed.
- """
- return self._do_load(
- data, many=many, partial=partial, unknown=unknown, postprocess=True
- )
-
- def loads(self, json_data, *, many=None, partial=None, unknown=None, **kwargs):
- """Same as :meth:`load`, except it takes a JSON string as input.
-
- :param str json_data: A JSON string of the data to deserialize.
- :param bool many: Whether to deserialize `obj` as a collection. If `None`, the
- value for `self.many` is used.
- :param bool|tuple partial: Whether to ignore missing fields and not require
- any fields declared. Propagates down to ``Nested`` fields as well. If
- its value is an iterable, only missing fields listed in that iterable
- will be ignored. Use dot delimiters to specify nested fields.
- :param unknown: Whether to exclude, include, or raise an error for unknown
- fields in the data. Use `EXCLUDE`, `INCLUDE` or `RAISE`.
- If `None`, the value for `self.unknown` is used.
- :return: A dict of deserialized data
- :rtype: dict
-
- .. versionadded:: 1.0.0
- .. versionchanged:: 3.0.0b7
- This method returns the deserialized data rather than a ``(data, errors)`` duple.
- A :exc:`ValidationError <marshmallow.exceptions.ValidationError>` is raised
- if invalid data are passed.
- """
- data = self.opts.render_module.loads(json_data, **kwargs)
- return self.load(data, many=many, partial=partial, unknown=unknown)
-
- def _run_validator(
- self,
- validator_func,
- output,
- *,
- original_data,
- error_store,
- many,
- partial,
- pass_original,
- index=None
- ):
- try:
- if pass_original: # Pass original, raw data (before unmarshalling)
- validator_func(output, original_data, partial=partial, many=many)
- else:
- validator_func(output, partial=partial, many=many)
- except ValidationError as err:
- error_store.store_error(err.messages, err.field_name, index=index)
-
- def validate(self, data, *, many=None, partial=None):
- """Validate `data` against the schema, returning a dictionary of
- validation errors.
-
- :param dict data: The data to validate.
- :param bool many: Whether to validate `data` as a collection. If `None`, the
- value for `self.many` is used.
- :param bool|tuple partial: Whether to ignore missing fields and not require
- any fields declared. Propagates down to ``Nested`` fields as well. If
- its value is an iterable, only missing fields listed in that iterable
- will be ignored. Use dot delimiters to specify nested fields.
- :return: A dictionary of validation errors.
- :rtype: dict
-
- .. versionadded:: 1.1.0
- """
- try:
- self._do_load(data, many=many, partial=partial, postprocess=False)
- except ValidationError as exc:
- return exc.messages
- return {}
-
- ##### Private Helpers #####
-
- def _do_load(
- self, data, *, many=None, partial=None, unknown=None, postprocess=True
- ):
- """Deserialize `data`, returning the deserialized result.
-
- :param data: The data to deserialize.
- :param bool many: Whether to deserialize `data` as a collection. If `None`, the
- value for `self.many` is used.
- :param bool|tuple partial: Whether to validate required fields. If its
- value is an iterable, only fields listed in that iterable will be
- ignored will be allowed missing. If `True`, all fields will be allowed missing.
- If `None`, the value for `self.partial` is used.
- :param unknown: Whether to exclude, include, or raise an error for unknown
- fields in the data. Use `EXCLUDE`, `INCLUDE` or `RAISE`.
- If `None`, the value for `self.unknown` is used.
- :param bool postprocess: Whether to run post_load methods..
- :return: A dict of deserialized data
- :rtype: dict
- """
- error_store = ErrorStore()
- errors = {}
- many = self.many if many is None else bool(many)
- unknown = unknown or self.unknown
- if partial is None:
- partial = self.partial
- # Run preprocessors
- if self._has_processors(PRE_LOAD):
- try:
- processed_data = self._invoke_load_processors(
- PRE_LOAD, data, many=many, original_data=data, partial=partial
- )
- except ValidationError as err:
- errors = err.normalized_messages()
- result = None
- else:
- processed_data = data
- if not errors:
- # Deserialize data
- result = self._deserialize(
- processed_data,
- error_store=error_store,
- many=many,
- partial=partial,
- unknown=unknown,
- )
- # Run field-level validation
- self._invoke_field_validators(
- error_store=error_store, data=result, many=many
- )
- # Run schema-level validation
- if self._has_processors(VALIDATES_SCHEMA):
- field_errors = bool(error_store.errors)
- self._invoke_schema_validators(
- error_store=error_store,
- pass_many=True,
- data=result,
- original_data=data,
- many=many,
- partial=partial,
- field_errors=field_errors,
- )
- self._invoke_schema_validators(
- error_store=error_store,
- pass_many=False,
- data=result,
- original_data=data,
- many=many,
- partial=partial,
- field_errors=field_errors,
- )
- errors = error_store.errors
- # Run post processors
- if not errors and postprocess and self._has_processors(POST_LOAD):
- try:
- result = self._invoke_load_processors(
- POST_LOAD,
- result,
- many=many,
- original_data=data,
- partial=partial,
- )
- except ValidationError as err:
- errors = err.normalized_messages()
- if errors:
- exc = ValidationError(errors, data=data, valid_data=result)
- self.handle_error(exc, data, many=many, partial=partial)
- raise exc
-
- return result
-
- def _normalize_nested_options(self):
- """Apply then flatten nested schema options"""
- if self.only is not None:
- # Apply the only option to nested fields.
- self.__apply_nested_option("only", self.only, "intersection")
- # Remove the child field names from the only option.
- self.only = self.set_class([field.split(".", 1)[0] for field in self.only])
- if self.exclude:
- # Apply the exclude option to nested fields.
- self.__apply_nested_option("exclude", self.exclude, "union")
- # Remove the parent field names from the exclude option.
- self.exclude = self.set_class(
- [field for field in self.exclude if "." not in field]
- )
-
- def __apply_nested_option(self, option_name, field_names, set_operation):
- """Apply nested options to nested fields"""
- # Split nested field names on the first dot.
- nested_fields = [name.split(".", 1) for name in field_names if "." in name]
- # Partition the nested field names by parent field.
- nested_options = defaultdict(list)
- for parent, nested_names in nested_fields:
- nested_options[parent].append(nested_names)
- # Apply the nested field options.
- for key, options in iter(nested_options.items()):
- new_options = self.set_class(options)
- original_options = getattr(self.declared_fields[key], option_name, ())
- if original_options:
- if set_operation == "union":
- new_options |= self.set_class(original_options)
- if set_operation == "intersection":
- new_options &= self.set_class(original_options)
- setattr(self.declared_fields[key], option_name, new_options)
-
- def _init_fields(self):
- """Update fields based on schema options."""
- if self.opts.fields:
- available_field_names = self.set_class(self.opts.fields)
- else:
- available_field_names = self.set_class(self.declared_fields.keys())
- if self.opts.additional:
- available_field_names |= self.set_class(self.opts.additional)
-
- invalid_fields = self.set_class()
-
- if self.only is not None:
- # Return only fields specified in only option
- field_names = self.set_class(self.only)
-
- invalid_fields |= field_names - available_field_names
- else:
- field_names = available_field_names
-
- # If "exclude" option or param is specified, remove those fields.
- if self.exclude:
- # Note that this isn't available_field_names, since we want to
- # apply "only" for the actual calculation.
- field_names = field_names - self.exclude
- invalid_fields |= self.exclude - available_field_names
-
- if invalid_fields:
- message = "Invalid fields for {}: {}.".format(self, invalid_fields)
- raise ValueError(message)
-
- fields_dict = self.dict_class()
- for field_name in field_names:
- field_obj = self.declared_fields.get(field_name, ma_fields.Inferred())
- self._bind_field(field_name, field_obj)
- fields_dict[field_name] = field_obj
-
- dump_data_keys = [
- obj.data_key or name
- for name, obj in fields_dict.items()
- if not obj.load_only
- ]
- if len(dump_data_keys) != len(set(dump_data_keys)):
- data_keys_duplicates = {
- x for x in dump_data_keys if dump_data_keys.count(x) > 1
- }
- raise ValueError(
- "The data_key argument for one or more fields collides "
- "with another field's name or data_key argument. "
- "Check the following field names and "
- "data_key arguments: {}".format(list(data_keys_duplicates))
- )
-
- load_attributes = [
- obj.attribute or name
- for name, obj in fields_dict.items()
- if not obj.dump_only
- ]
- if len(load_attributes) != len(set(load_attributes)):
- attributes_duplicates = {
- x for x in load_attributes if load_attributes.count(x) > 1
- }
- raise ValueError(
- "The attribute argument for one or more fields collides "
- "with another field's name or attribute argument. "
- "Check the following field names and "
- "attribute arguments: {}".format(list(attributes_duplicates))
- )
-
- return fields_dict
-
- def on_bind_field(self, field_name, field_obj):
- """Hook to modify a field when it is bound to the `Schema`.
-
- No-op by default.
- """
- return None
-
- def _bind_field(self, field_name, field_obj):
- """Bind field to the schema, setting any necessary attributes on the
- field (e.g. parent and name).
-
- Also set field load_only and dump_only values if field_name was
- specified in ``class Meta``.
- """
- try:
- if field_name in self.load_only:
- field_obj.load_only = True
- if field_name in self.dump_only:
- field_obj.dump_only = True
- field_obj._bind_to_schema(field_name, self)
- self.on_bind_field(field_name, field_obj)
- except TypeError as error:
- # field declared as a class, not an instance
- if isinstance(field_obj, type) and issubclass(field_obj, base.FieldABC):
- msg = (
- 'Field for "{}" must be declared as a '
- "Field instance, not a class. "
- 'Did you mean "fields.{}()"?'.format(field_name, field_obj.__name__)
- )
- raise TypeError(msg) from error
-
- @lru_cache(maxsize=8)
- def _has_processors(self, tag):
- return self._hooks[(tag, True)] or self._hooks[(tag, False)]
-
- def _invoke_dump_processors(self, tag, data, *, many, original_data=None):
- # The pass_many post-dump processors may do things like add an envelope, so
- # invoke those after invoking the non-pass_many processors which will expect
- # to get a list of items.
- data = self._invoke_processors(
- tag, pass_many=False, data=data, many=many, original_data=original_data
- )
- data = self._invoke_processors(
- tag, pass_many=True, data=data, many=many, original_data=original_data
- )
- return data
-
- def _invoke_load_processors(self, tag, data, *, many, original_data, partial):
- # This has to invert the order of the dump processors, so run the pass_many
- # processors first.
- data = self._invoke_processors(
- tag,
- pass_many=True,
- data=data,
- many=many,
- original_data=original_data,
- partial=partial,
- )
- data = self._invoke_processors(
- tag,
- pass_many=False,
- data=data,
- many=many,
- original_data=original_data,
- partial=partial,
- )
- return data
-
- def _invoke_field_validators(self, *, error_store, data, many):
- for attr_name in self._hooks[VALIDATES]:
- validator = getattr(self, attr_name)
- validator_kwargs = validator.__marshmallow_hook__[VALIDATES]
- field_name = validator_kwargs["field_name"]
-
- try:
- field_obj = self.fields[field_name]
- except KeyError as error:
- if field_name in self.declared_fields:
- continue
- raise ValueError(
- '"{}" field does not exist.'.format(field_name)
- ) from error
-
- if many:
- for idx, item in enumerate(data):
- try:
- value = item[field_obj.attribute or field_name]
- except KeyError:
- pass
- else:
- validated_value = self._call_and_store(
- getter_func=validator,
- data=value,
- field_name=field_obj.data_key or field_name,
- error_store=error_store,
- index=(idx if self.opts.index_errors else None),
- )
- if validated_value is missing:
- data[idx].pop(field_name, None)
- else:
- try:
- value = data[field_obj.attribute or field_name]
- except KeyError:
- pass
- else:
- validated_value = self._call_and_store(
- getter_func=validator,
- data=value,
- field_name=field_obj.data_key or field_name,
- error_store=error_store,
- )
- if validated_value is missing:
- data.pop(field_name, None)
-
- def _invoke_schema_validators(
- self,
- *,
- error_store,
- pass_many,
- data,
- original_data,
- many,
- partial,
- field_errors=False
- ):
- for attr_name in self._hooks[(VALIDATES_SCHEMA, pass_many)]:
- validator = getattr(self, attr_name)
- validator_kwargs = validator.__marshmallow_hook__[
- (VALIDATES_SCHEMA, pass_many)
- ]
- if field_errors and validator_kwargs["skip_on_field_errors"]:
- continue
- pass_original = validator_kwargs.get("pass_original", False)
-
- if many and not pass_many:
- for idx, (item, orig) in enumerate(zip(data, original_data)):
- self._run_validator(
- validator,
- item,
- original_data=orig,
- error_store=error_store,
- many=many,
- partial=partial,
- index=idx,
- pass_original=pass_original,
- )
- else:
- self._run_validator(
- validator,
- data,
- original_data=original_data,
- error_store=error_store,
- many=many,
- pass_original=pass_original,
- partial=partial,
- )
-
- def _invoke_processors(
- self, tag, *, pass_many, data, many, original_data=None, **kwargs
- ):
- key = (tag, pass_many)
- for attr_name in self._hooks[key]:
- # This will be a bound method.
- processor = getattr(self, attr_name)
-
- processor_kwargs = processor.__marshmallow_hook__[key]
- pass_original = processor_kwargs.get("pass_original", False)
-
- if pass_many:
- if pass_original:
- data = processor(data, original_data, many=many, **kwargs)
- else:
- data = processor(data, many=many, **kwargs)
- elif many:
- if pass_original:
- data = [
- processor(item, original, many=many, **kwargs)
- for item, original in zip(data, original_data)
- ]
- else:
- data = [processor(item, many=many, **kwargs) for item in data]
- else:
- if pass_original:
- data = processor(data, original_data, many=many, **kwargs)
- else:
- data = processor(data, many=many, **kwargs)
- return data
-
-
-class Schema(BaseSchema, metaclass=SchemaMeta):
- __doc__ = BaseSchema.__doc__
+ elif field_obj
\ No newline at end of fileScoring
Passing target tests
No fail-to-pass successes recorded yet.
Failing target tests
tests/test_fields.py::TestParentAndName::test_datetime_list_inner_format
Maintained regression tests
No pass-to-pass successes recorded yet.
Regressed tests
tests/test_fields.py::test_field_aliases[Integer-Integer] tests/test_fields.py::test_field_aliases[String-String] tests/test_fields.py::test_field_aliases[Boolean-Boolean] tests/test_fields.py::test_field_aliases[Url-Url] tests/test_fields.py::TestField::test_repr tests/test_fields.py::TestField::test_error_raised_if_uncallable_validator_passed tests/test_fields.py::TestField::test_error_raised_if_missing_is_set_on_required_field tests/test_fields.py::TestField::test_custom_field_receives_attr_and_obj tests/test_fields.py::TestField::test_custom_field_receives_data_key_if_set tests/test_fields.py::TestField::test_custom_field_follows_data_key_if_set tests/test_fields.py::TestParentAndName::test_simple_field_parent_and_name tests/test_fields.py::TestParentAndName::test_unbound_field_root_returns_none tests/test_fields.py::TestParentAndName::test_list_field_inner_parent_and_name tests/test_fields.py::TestParentAndName::test_tuple_field_inner_parent_and_name tests/test_fields.py::TestParentAndName::test_mapping_field_inner_parent_and_name tests/test_fields.py::TestParentAndName::test_simple_field_root tests/test_fields.py::TestParentAndName::test_list_field_inner_root tests/test_fields.py::TestParentAndName::test_tuple_field_inner_root tests/test_fields.py::TestParentAndName::test_list_root_inheritance tests/test_fields.py::TestParentAndName::test_dict_root_inheritance tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[String] tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Integer] tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Boolean] tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Float] tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Number] tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[DateTime] tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Time] tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Date] tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[TimeDelta] tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Dict] tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Url] tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Email] tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[UUID] tests/test_fields.py::TestMetadata::test_extra_metadata_may_be_added_to_field[Decimal] tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages_cstm_msg tests/test_fields.py::TestErrorMessages::test_default_error_messages_get_merged_with_parent_error_messages tests/test_fields.py::TestErrorMessages::test_make_error[required-Missing tests/test_fields.py::TestErrorMessages::test_make_error[null-Field tests/test_fields.py::TestErrorMessages::test_make_error[custom-Custom tests/test_fields.py::TestErrorMessages::test_make_error[validator_failed-Invalid tests/test_fields.py::TestErrorMessages::test_fail[required-Missing tests/test_fields.py::TestErrorMessages::test_fail[null-Field tests/test_fields.py::TestErrorMessages::test_fail[custom-Custom tests/test_fields.py::TestErrorMessages::test_fail[validator_failed-Invalid tests/test_fields.py::TestErrorMessages::test_make_error_key_doesnt_exist tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[only] tests/test_fields.py::TestNestedField::test_nested_only_and_exclude_as_string[exclude] tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-exclude] tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-include] tests/test_fields.py::TestNestedField::test_nested_unknown_override[None-raise] tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-exclude] tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-include] tests/test_fields.py::TestNestedField::test_nested_unknown_override[exclude-raise] tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-exclude] tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-include] tests/test_fields.py::TestNestedField::test_nested_unknown_override[include-raise] tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-exclude] tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-include] tests/test_fields.py::TestNestedField::test_nested_unknown_override[raise-raise] tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[only] tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude] tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only] tests/test_fields.py::TestListNested::test_list_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only] tests/test_fields.py::TestListNested::test_list_nested_only_and_exclude_merged_with_nested[only-expected0] tests/test_fields.py::TestListNested::test_list_nested_only_and_exclude_merged_with_nested[exclude-expected1] tests/test_fields.py::TestListNested::test_list_nested_partial_propagated_to_nested tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only] tests/test_fields.py::TestTupleNested::test_tuple_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only] tests/test_fields.py::TestTupleNested::test_tuple_nested_partial_propagated_to_nested tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[only] tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[exclude] tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[dump_only] tests/test_fields.py::TestDictNested::test_dict_nested_only_exclude_dump_only_load_only_propagated_to_nested[load_only] tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[only-expected0] tests/test_fields.py::TestDictNested::test_dict_nested_only_and_exclude_merged_with_nested[exclude-expected1] tests/test_fields.py::TestDictNested::test_dict_nested_partial_propagated_to_nested
Harness output
+ source /opt/miniconda3/bin/activate
++ _CONDA_ROOT=/opt/miniconda3
++ . /opt/miniconda3/etc/profile.d/conda.sh
+++ export CONDA_EXE=/opt/miniconda3/bin/conda
+++ CONDA_EXE=/opt/miniconda3/bin/conda
+++ export _CE_M=
+++ _CE_M=
+++ export _CE_CONDA=
+++ _CE_CONDA=
+++ export CONDA_PYTHON_EXE=/opt/miniconda3/bin/python
+++ CONDA_PYTHON_EXE=/opt/miniconda3/bin/python
+++ '[' -z x ']'
++ conda activate
++ local cmd=activate
++ case "$cmd" in
++ __conda_activate activate
++ '[' -n '' ']'
++ local ask_conda
+++ PS1=
+++ __conda_exe shell.posix activate
+++ /opt/miniconda3/bin/conda shell.posix activate
++ ask_conda='PS1='\''(base) '\''
export PATH='\''/opt/miniconda3/bin:/opt/miniconda3/condabin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'\''
export CONDA_PREFIX='\''/opt/miniconda3'\''
export CONDA_SHLVL='\''2'\''
export CONDA_DEFAULT_ENV='\''base'\''
export CONDA_PROMPT_MODIFIER='\''(base) '\''
export CONDA_PREFIX_1='\''/opt/miniconda3/envs/testbed'\''
export CONDA_EXE='\''/opt/miniconda3/bin/conda'\''
export _CE_M='\'''\''
export _CE_CONDA='\'''\''
export CONDA_PYTHON_EXE='\''/opt/miniconda3/bin/python'\'''
++ eval 'PS1='\''(base) '\''
export PATH='\''/opt/miniconda3/bin:/opt/miniconda3/condabin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'\''
export CONDA_PREFIX='\''/opt/miniconda3'\''
export CONDA_SHLVL='\''2'\''
export CONDA_DEFAULT_ENV='\''base'\''
export CONDA_PROMPT_MODIFIER='\''(base) '\''
export CONDA_PREFIX_1='\''/opt/miniconda3/envs/testbed'\''
export CONDA_EXE='\''/opt/miniconda3/bin/conda'\''
export _CE_M='\'''\''
export _CE_CONDA='\'''\''
export CONDA_PYTHON_EXE='\''/opt/miniconda3/bin/python'\'''
+++ PS1='(base) '
+++ export PATH=/opt/miniconda3/bin:/opt/miniconda3/condabin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+++ PATH=/opt/miniconda3/bin:/opt/miniconda3/condabin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+++ export CONDA_PREFIX=/opt/miniconda3
+++ CONDA_PREFIX=/opt/miniconda3
+++ export CONDA_SHLVL=2
+++ CONDA_SHLVL=2
+++ export CONDA_DEFAULT_ENV=base
+++ CONDA_DEFAULT_ENV=base
+++ export 'CONDA_PROMPT_MODIFIER=(base) '
+++ CONDA_PROMPT_MODIFIER='(base) '
+++ export CONDA_PREFIX_1=/opt/miniconda3/envs/testbed
+++ CONDA_PREFIX_1=/opt/miniconda3/envs/testbed
+++ export CONDA_EXE=/opt/miniconda3/bin/conda
+++ CONDA_EXE=/opt/miniconda3/bin/conda
+++ export _CE_M=
+++ _CE_M=
+++ export _CE_CONDA=
+++ _CE_CONDA=
+++ export CONDA_PYTHON_EXE=/opt/miniconda3/bin/python
+++ CONDA_PYTHON_EXE=/opt/miniconda3/bin/python
++ __conda_hashr
++ '[' -n '' ']'
++ '[' -n '' ']'
++ hash -r
+ conda activate testbed
+ local cmd=activate
+ case "$cmd" in
+ __conda_activate activate testbed
+ '[' -n '' ']'
+ local ask_conda
++ PS1='(base) '
++ __conda_exe shell.posix activate testbed
++ /opt/miniconda3/bin/conda shell.posix activate testbed
+ ask_conda='PS1='\''(testbed) '\''
export PATH='\''/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/condabin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'\''
export CONDA_PREFIX='\''/opt/miniconda3/envs/testbed'\''
export CONDA_SHLVL='\''3'\''
export CONDA_DEFAULT_ENV='\''testbed'\''
export CONDA_PROMPT_MODIFIER='\''(testbed) '\''
export CONDA_PREFIX_2='\''/opt/miniconda3'\''
export CONDA_EXE='\''/opt/miniconda3/bin/conda'\''
export _CE_M='\'''\''
export _CE_CONDA='\'''\''
export CONDA_PYTHON_EXE='\''/opt/miniconda3/bin/python'\'''
+ eval 'PS1='\''(testbed) '\''
export PATH='\''/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/condabin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'\''
export CONDA_PREFIX='\''/opt/miniconda3/envs/testbed'\''
export CONDA_SHLVL='\''3'\''
export CONDA_DEFAULT_ENV='\''testbed'\''
export CONDA_PROMPT_MODIFIER='\''(testbed) '\''
export CONDA_PREFIX_2='\''/opt/miniconda3'\''
export CONDA_EXE='\''/opt/miniconda3/bin/conda'\''
export _CE_M='\'''\''
export _CE_CONDA='\'''\''
export CONDA_PYTHON_EXE='\''/opt/miniconda3/bin/python'\'''
++ PS1='(testbed) '
++ export PATH=/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/condabin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
++ PATH=/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/condabin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
++ export CONDA_PREFIX=/opt/miniconda3/envs/testbed
++ CONDA_PREFIX=/opt/miniconda3/envs/testbed
++ export CONDA_SHLVL=3
++ CONDA_SHLVL=3
++ export CONDA_DEFAULT_ENV=testbed
++ CONDA_DEFAULT_ENV=testbed
++ export 'CONDA_PROMPT_MODIFIER=(testbed) '
++ CONDA_PROMPT_MODIFIER='(testbed) '
++ export CONDA_PREFIX_2=/opt/miniconda3
++ CONDA_PREFIX_2=/opt/miniconda3
++ export CONDA_EXE=/opt/miniconda3/bin/conda
++ CONDA_EXE=/opt/miniconda3/bin/conda
++ export _CE_M=
++ _CE_M=
++ export _CE_CONDA=
++ _CE_CONDA=
++ export CONDA_PYTHON_EXE=/opt/miniconda3/bin/python
++ CONDA_PYTHON_EXE=/opt/miniconda3/bin/python
+ __conda_hashr
+ '[' -n '' ']'
+ '[' -n '' ']'
+ hash -r
+ cd /testbed
+ git config --global --add safe.directory /testbed
+ cd /testbed
+ git status
On branch dev
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: src/marshmallow/schema.py
no changes added to commit (use "git add" and/or "git commit -a")
+ git show
commit 8ad28316545371a1d1d7c2ad0b32d5f8ab206853
Author: SWE-bench <setup@swebench.config>
Date: Tue May 6 23:07:21 2025 +0000
SWE-bench
+ git -c core.fileMode=false diff b40a0f4e33823e6d0f341f7e8684e359a99060d1
diff --git a/src/marshmallow/schema.py b/src/marshmallow/schema.py
index 520ffb44..7c428285 100644
--- a/src/marshmallow/schema.py
+++ b/src/marshmallow/schema.py
@@ -385,756 +385,4 @@ class BaseSchema(base.SchemaABC):
for field_name, field_obj in self.fields.items():
if field_obj.load_only:
self.load_fields[field_name] = field_obj
- elif field_obj.dump_only:
- self.dump_fields[field_name] = field_obj
- else:
- self.load_fields[field_name] = field_obj
- self.dump_fields[field_name] = field_obj
- messages = {}
- messages.update(self._default_error_messages)
- for cls in reversed(self.__class__.__mro__):
- messages.update(getattr(cls, "error_messages", {}))
- messages.update(self.error_messages or {})
- self.error_messages = messages
-
- def __repr__(self):
- return "<{ClassName}(many={self.many})>".format(
- ClassName=self.__class__.__name__, self=self
- )
-
- @property
- def dict_class(self):
- return OrderedDict if self.ordered else dict
-
- @property
- def set_class(self):
- return OrderedSet if self.ordered else set
-
- @classmethod
- def from_dict(
- cls, fields: typing.Dict[str, ma_fields.Field], *, name: str = "GeneratedSchema"
- ) -> typing.Type["Schema"]:
- """Generate a `Schema` class given a dictionary of fields.
-
- .. code-block:: python
-
- from marshmallow import Schema, fields
-
- PersonSchema = Schema.from_dict({"name": fields.Str()})
- print(PersonSchema().load({"name": "David"})) # => {'name': 'David'}
-
- Generated schemas are not added to the class registry and therefore cannot
- be referred to by name in `Nested` fields.
-
- :param dict fields: Dictionary mapping field names to field instances.
- :param str name: Optional name for the class, which will appear in
- the ``repr`` for the class.
-
- .. versionadded:: 3.0.0
- """
- attrs = fields.copy()
- attrs["Meta"] = type(
- "GeneratedMeta", (getattr(cls, "Meta", object),), {"register": False}
- )
- schema_cls = type(name, (cls,), attrs)
- return schema_cls
-
- ##### Override-able methods #####
-
- def handle_error(self, error, data, *, many, **kwargs):
- """Custom error handler function for the schema.
-
- :param ValidationError error: The `ValidationError` raised during (de)serialization.
- :param data: The original input data.
- :param bool many: Value of ``many`` on dump or load.
- :param bool partial: Value of ``partial`` on load.
-
- .. versionadded:: 2.0.0
-
- .. versionchanged:: 3.0.0rc9
- Receives `many` and `partial` (on deserialization) as keyword arguments.
- """
- pass
-
- def get_attribute(self, obj, attr, default):
- """Defines how to pull values from an object to serialize.
-
- .. versionadded:: 2.0.0
-
- .. versionchanged:: 3.0.0a1
- Changed position of ``obj`` and ``attr``.
- """
- return get_value(obj, attr, default)
-
- ##### Serialization/Deserialization API #####
-
- @staticmethod
- def _call_and_store(getter_func, data, *, field_name, error_store, index=None):
- """Call ``getter_func`` with ``data`` as its argument, and store any `ValidationErrors`.
-
- :param callable getter_func: Function for getting the serialized/deserialized
- value from ``data``.
- :param data: The data passed to ``getter_func``.
- :param str field_name: Field name.
- :param int index: Index of the item being validated, if validating a collection,
- otherwise `None`.
- """
- try:
- value = getter_func(data)
- except ValidationError as error:
- error_store.store_error(error.messages, field_name, index=index)
- # When a Nested field fails validation, the marshalled data is stored
- # on the ValidationError's valid_data attribute
- return error.valid_data or missing
- return value
-
- def _serialize(self, obj, *, many=False):
- """Serialize ``obj``.
-
- :param obj: The object(s) to serialize.
- :param bool many: `True` if ``data`` should be serialized as a collection.
- :return: A dictionary of the serialized data
-
- .. versionchanged:: 1.0.0
- Renamed from ``marshal``.
- """
- if many and obj is not None:
- return [self._serialize(d, many=False) for d in obj]
- ret = self.dict_class()
- for attr_name, field_obj in self.dump_fields.items():
- value = field_obj.serialize(attr_name, obj, accessor=self.get_attribute)
- if value is missing:
- continue
- key = field_obj.data_key or attr_name
- ret[key] = value
- return ret
-
- def dump(self, obj, *, many=None):
- """Serialize an object to native Python data types according to this
- Schema's fields.
-
- :param obj: The object to serialize.
- :param bool many: Whether to serialize `obj` as a collection. If `None`, the value
- for `self.many` is used.
- :return: A dict of serialized data
- :rtype: dict
-
- .. versionadded:: 1.0.0
- .. versionchanged:: 3.0.0b7
- This method returns the serialized data rather than a ``(data, errors)`` duple.
- A :exc:`ValidationError <marshmallow.exceptions.ValidationError>` is raised
- if ``obj`` is invalid.
- .. versionchanged:: 3.0.0rc9
- Validation no longer occurs upon serialization.
- """
- many = self.many if many is None else bool(many)
- if many and is_iterable_but_not_string(obj):
- obj = list(obj)
-
- if self._has_processors(PRE_DUMP):
- processed_obj = self._invoke_dump_processors(
- PRE_DUMP, obj, many=many, original_data=obj
- )
- else:
- processed_obj = obj
-
- result = self._serialize(processed_obj, many=many)
-
- if self._has_processors(POST_DUMP):
- result = self._invoke_dump_processors(
- POST_DUMP, result, many=many, original_data=obj
- )
-
- return result
-
- def dumps(self, obj, *args, many=None, **kwargs):
- """Same as :meth:`dump`, except return a JSON-encoded string.
-
- :param obj: The object to serialize.
- :param bool many: Whether to serialize `obj` as a collection. If `None`, the value
- for `self.many` is used.
- :return: A ``json`` string
- :rtype: str
-
- .. versionadded:: 1.0.0
- .. versionchanged:: 3.0.0b7
- This method returns the serialized data rather than a ``(data, errors)`` duple.
- A :exc:`ValidationError <marshmallow.exceptions.ValidationError>` is raised
- if ``obj`` is invalid.
- """
- serialized = self.dump(obj, many=many)
- return self.opts.render_module.dumps(serialized, *args, **kwargs)
-
- def _deserialize(
- self, data, *, error_store, many=False, partial=False, unknown=RAISE, index=None
- ):
- """Deserialize ``data``.
-
- :param dict data: The data to deserialize.
- :param ErrorStore error_store: Structure to store errors.
- :param bool many: `True` if ``data`` should be deserialized as a collection.
- :param bool|tuple partial: Whether to ignore missing fields and not require
- any fields declared. Propagates down to ``Nested`` fields as well. If
- its value is an iterable, only missing fields listed in that iterable
- will be ignored. Use dot delimiters to specify nested fields.
- :param unknown: Whether to exclude, include, or raise an error for unknown
- fields in the data. Use `EXCLUDE`, `INCLUDE` or `RAISE`.
- :param int index: Index of the item being serialized (for storing errors) if
- serializing a collection, otherwise `None`.
- :return: A dictionary of the deserialized data.
- """
- index_errors = self.opts.index_errors
- index = index if index_errors else None
- if many:
- if not is_collection(data):
- error_store.store_error([self.error_messages["type"]], index=index)
- ret = []
- else:
- ret = [
- self._deserialize(
- d,
- error_store=error_store,
- many=False,
- partial=partial,
- unknown=unknown,
- index=idx,
- )
- for idx, d in enumerate(data)
- ]
- return ret
- ret = self.dict_class()
- # Check data is a dict
- if not isinstance(data, Mapping):
- error_store.store_error([self.error_messages["type"]], index=index)
- else:
- partial_is_collection = is_collection(partial)
- for attr_name, field_obj in self.load_fields.items():
- field_name = field_obj.data_key or attr_name
- raw_value = data.get(field_name, missing)
- if raw_value is missing:
- # Ignore missing field if we're allowed to.
- if partial is True or (
- partial_is_collection and attr_name in partial
- ):
- continue
- d_kwargs = {}
- # Allow partial loading of nested schemas.
- if partial_is_collection:
- prefix = field_name + "."
- len_prefix = len(prefix)
- sub_partial = [
- f[len_prefix:] for f in partial if f.startswith(prefix)
- ]
- d_kwargs["partial"] = sub_partial
- else:
- d_kwargs["partial"] = partial
- getter = lambda val: field_obj.deserialize(
- val, field_name, data, **d_kwargs
- )
- value = self._call_and_store(
- getter_func=getter,
- data=raw_value,
- field_name=field_name,
- error_store=error_store,
- index=index,
- )
- if value is not missing:
- key = field_obj.attribute or attr_name
- set_value(ret, key, value)
- if unknown != EXCLUDE:
- fields = {
- field_obj.data_key or field_name
- for field_name, field_obj in self.load_fields.items()
- }
- for key in set(data) - fields:
- value = data[key]
- if unknown == INCLUDE:
- set_value(ret, key, value)
- elif unknown == RAISE:
- error_store.store_error(
- [self.error_messages["unknown"]],
- key,
- (index if index_errors else None),
- )
- return ret
-
- def load(self, data, *, many=None, partial=None, unknown=None):
- """Deserialize a data structure to an object defined by this Schema's fields.
-
- :param dict data: The data to deserialize.
- :param bool many: Whether to deserialize `data` as a collection. If `None`, the
- value for `self.many` is used.
- :param bool|tuple partial: Whether to ignore missing fields and not require
- any fields declared. Propagates down to ``Nested`` fields as well. If
- its value is an iterable, only missing fields listed in that iterable
- will be ignored. Use dot delimiters to specify nested fields.
- :param unknown: Whether to exclude, include, or raise an error for unknown
- fields in the data. Use `EXCLUDE`, `INCLUDE` or `RAISE`.
- If `None`, the value for `self.unknown` is used.
- :return: A dict of deserialized data
- :rtype: dict
-
- .. versionadded:: 1.0.0
- .. versionchanged:: 3.0.0b7
- This method returns the deserialized data rather than a ``(data, errors)`` duple.
- A :exc:`ValidationError <marshmallow.exceptions.ValidationError>` is raised
- if invalid data are passed.
- """
- return self._do_load(
- data, many=many, partial=partial, unknown=unknown, postprocess=True
- )
-
- def loads(self, json_data, *, many=None, partial=None, unknown=None, **kwargs):
- """Same as :meth:`load`, except it takes a JSON string as input.
-
- :param str json_data: A JSON string of the data to deserialize.
- :param bool many: Whether to deserialize `obj` as a collection. If `None`, the
- value for `self.many` is used.
- :param bool|tuple partial: Whether to ignore missing fields and not require
- any fields declared. Propagates down to ``Nested`` fields as well. If
- its value is an iterable, only missing fields listed in that iterable
- will be ignored. Use dot delimiters to specify nested fields.
- :param unknown: Whether to exclude, include, or raise an error for unknown
- fields in the data. Use `EXCLUDE`, `INCLUDE` or `RAISE`.
- If `None`, the value for `self.unknown` is used.
- :return: A dict of deserialized data
- :rtype: dict
-
- .. versionadded:: 1.0.0
- .. versionchanged:: 3.0.0b7
- This method returns the deserialized data rather than a ``(data, errors)`` duple.
- A :exc:`ValidationError <marshmallow.exceptions.ValidationError>` is raised
- if invalid data are passed.
- """
- data = self.opts.render_module.loads(json_data, **kwargs)
- return self.load(data, many=many, partial=partial, unknown=unknown)
-
- def _run_validator(
- self,
- validator_func,
- output,
- *,
- original_data,
- error_store,
- many,
- partial,
- pass_original,
- index=None
- ):
- try:
- if pass_original: # Pass original, raw data (before unmarshalling)
- validator_func(output, original_data, partial=partial, many=many)
- else:
- validator_func(output, partial=partial, many=many)
- except ValidationError as err:
- error_store.store_error(err.messages, err.field_name, index=index)
-
- def validate(self, data, *, many=None, partial=None):
- """Validate `data` against the schema, returning a dictionary of
- validation errors.
-
- :param dict data: The data to validate.
- :param bool many: Whether to validate `data` as a collection. If `None`, the
- value for `self.many` is used.
- :param bool|tuple partial: Whether to ignore missing fields and not require
- any fields declared. Propagates down to ``Nested`` fields as well. If
- its value is an iterable, only missing fields listed in that iterable
- will be ignored. Use dot delimiters to specify nested fields.
- :return: A dictionary of validation errors.
- :rtype: dict
-
- .. versionadded:: 1.1.0
- """
- try:
- self._do_load(data, many=many, partial=partial, postprocess=False)
- except ValidationError as exc:
- return exc.messages
- return {}
-
- ##### Private Helpers #####
-
- def _do_load(
- self, data, *, many=None, partial=None, unknown=None, postprocess=True
- ):
- """Deserialize `data`, returning the deserialized result.
-
- :param data: The data to deserialize.
- :param bool many: Whether to deserialize `data` as a collection. If `None`, the
- value for `self.many` is used.
- :param bool|tuple partial: Whether to validate required fields. If its
- value is an iterable, only fields listed in that iterable will be
- ignored will be allowed missing. If `True`, all fields will be allowed missing.
- If `None`, the value for `self.partial` is used.
- :param unknown: Whether to exclude, include, or raise an error for unknown
- fields in the data. Use `EXCLUDE`, `INCLUDE` or `RAISE`.
- If `None`, the value for `self.unknown` is used.
- :param bool postprocess: Whether to run post_load methods..
- :return: A dict of deserialized data
- :rtype: dict
- """
- error_store = ErrorStore()
- errors = {}
- many = self.many if many is None else bool(many)
- unknown = unknown or self.unknown
- if partial is None:
- partial = self.partial
- # Run preprocessors
- if self._has_processors(PRE_LOAD):
- try:
- processed_data = self._invoke_load_processors(
- PRE_LOAD, data, many=many, original_data=data, partial=partial
- )
- except ValidationError as err:
- errors = err.normalized_messages()
- result = None
- else:
- processed_data = data
- if not errors:
- # Deserialize data
- result = self._deserialize(
- processed_data,
- error_store=error_store,
- many=many,
- partial=partial,
- unknown=unknown,
- )
- # Run field-level validation
- self._invoke_field_validators(
- error_store=error_store, data=result, many=many
- )
- # Run schema-level validation
- if self._has_processors(VALIDATES_SCHEMA):
- field_errors = bool(error_store.errors)
- self._invoke_schema_validators(
- error_store=error_store,
- pass_many=True,
- data=result,
- original_data=data,
- many=many,
- partial=partial,
- field_errors=field_errors,
- )
- self._invoke_schema_validators(
- error_store=error_store,
- pass_many=False,
- data=result,
- original_data=data,
- many=many,
- partial=partial,
- field_errors=field_errors,
- )
- errors = error_store.errors
- # Run post processors
- if not errors and postprocess and self._has_processors(POST_LOAD):
- try:
- result = self._invoke_load_processors(
- POST_LOAD,
- result,
- many=many,
- original_data=data,
- partial=partial,
- )
- except ValidationError as err:
- errors = err.normalized_messages()
- if errors:
- exc = ValidationError(errors, data=data, valid_data=result)
- self.handle_error(exc, data, many=many, partial=partial)
- raise exc
-
- return result
-
- def _normalize_nested_options(self):
- """Apply then flatten nested schema options"""
- if self.only is not None:
- # Apply the only option to nested fields.
- self.__apply_nested_option("only", self.only, "intersection")
- # Remove the child field names from the only option.
- self.only = self.set_class([field.split(".", 1)[0] for field in self.only])
- if self.exclude:
- # Apply the exclude option to nested fields.
- self.__apply_nested_option("exclude", self.exclude, "union")
- # Remove the parent field names from the exclude option.
- self.exclude = self.set_class(
- [field for field in self.exclude if "." not in field]
- )
-
- def __apply_nested_option(self, option_name, field_names, set_operation):
- """Apply nested options to nested fields"""
- # Split nested field names on the first dot.
- nested_fields = [name.split(".", 1) for name in field_names if "." in name]
- # Partition the nested field names by parent field.
- nested_options = defaultdict(list)
- for parent, nested_names in nested_fields:
- nested_options[parent].append(nested_names)
- # Apply the nested field options.
- for key, options in iter(nested_options.items()):
- new_options = self.set_class(options)
- original_options = getattr(self.declared_fields[key], option_name, ())
- if original_options:
- if set_operation == "union":
- new_options |= self.set_class(original_options)
- if set_operation == "intersection":
- new_options &= self.set_class(original_options)
- setattr(self.declared_fields[key], option_name, new_options)
-
- def _init_fields(self):
- """Update fields based on schema options."""
- if self.opts.fields:
- available_field_names = self.set_class(self.opts.fields)
- else:
- available_field_names = self.set_class(self.declared_fields.keys())
- if self.opts.additional:
- available_field_names |= self.set_class(self.opts.additional)
-
- invalid_fields = self.set_class()
-
- if self.only is not None:
- # Return only fields specified in only option
- field_names = self.set_class(self.only)
-
- invalid_fields |= field_names - available_field_names
- else:
- field_names = available_field_names
-
- # If "exclude" option or param is specified, remove those fields.
- if self.exclude:
- # Note that this isn't available_field_names, since we want to
- # apply "only" for the actual calculation.
- field_names = field_names - self.exclude
- invalid_fields |= self.exclude - available_field_names
-
- if invalid_fields:
- message = "Invalid fields for {}: {}.".format(self, invalid_fields)
- raise ValueError(message)
-
- fields_dict = self.dict_class()
- for field_name in field_names:
- field_obj = self.declared_fields.get(field_name, ma_fields.Inferred())
- self._bind_field(field_name, field_obj)
- fields_dict[field_name] = field_obj
-
- dump_data_keys = [
- obj.data_key or name
- for name, obj in fields_dict.items()
- if not obj.load_only
- ]
- if len(dump_data_keys) != len(set(dump_data_keys)):
- data_keys_duplicates = {
- x for x in dump_data_keys if dump_data_keys.count(x) > 1
- }
- raise ValueError(
- "The data_key argument for one or more fields collides "
- "with another field's name or data_key argument. "
- "Check the following field names and "
- "data_key arguments: {}".format(list(data_keys_duplicates))
- )
-
- load_attributes = [
- obj.attribute or name
- for name, obj in fields_dict.items()
- if not obj.dump_only
- ]
- if len(load_attributes) != len(set(load_attributes)):
- attributes_duplicates = {
- x for x in load_attributes if load_attributes.count(x) > 1
- }
- raise ValueError(
- "The attribute argument for one or more fields collides "
- "with another field's name or attribute argument. "
- "Check the following field names and "
- "attribute arguments: {}".format(list(attributes_duplicates))
- )
-
- return fields_dict
-
- def on_bind_field(self, field_name, field_obj):
- """Hook to modify a field when it is bound to the `Schema`.
-
- No-op by default.
- """
- return None
-
- def _bind_field(self, field_name, field_obj):
- """Bind field to the schema, setting any necessary attributes on the
- field (e.g. parent and name).
-
- Also set field load_only and dump_only values if field_name was
- specified in ``class Meta``.
- """
- try:
- if field_name in self.load_only:
- field_obj.load_only = True
- if field_name in self.dump_only:
- field_obj.dump_only = True
- field_obj._bind_to_schema(field_name, self)
- self.on_bind_field(field_name, field_obj)
- except TypeError as error:
- # field declared as a class, not an instance
- if isinstance(field_obj, type) and issubclass(field_obj, base.FieldABC):
- msg = (
- 'Field for "{}" must be declared as a '
- "Field instance, not a class. "
- 'Did you mean "fields.{}()"?'.format(field_name, field_obj.__name__)
- )
- raise TypeError(msg) from error
-
- @lru_cache(maxsize=8)
- def _has_processors(self, tag):
- return self._hooks[(tag, True)] or self._hooks[(tag, False)]
-
- def _invoke_dump_processors(self, tag, data, *, many, original_data=None):
- # The pass_many post-dump processors may do things like add an envelope, so
- # invoke those after invoking the non-pass_many processors which will expect
- # to get a list of items.
- data = self._invoke_processors(
- tag, pass_many=False, data=data, many=many, original_data=original_data
- )
- data = self._invoke_processors(
- tag, pass_many=True, data=data, many=many, original_data=original_data
- )
- return data
-
- def _invoke_load_processors(self, tag, data, *, many, original_data, partial):
- # This has to invert the order of the dump processors, so run the pass_many
- # processors first.
- data = self._invoke_processors(
- tag,
- pass_many=True,
- data=data,
- many=many,
- original_data=original_data,
- partial=partial,
- )
- data = self._invoke_processors(
- tag,
- pass_many=False,
- data=data,
- many=many,
- original_data=original_data,
- partial=partial,
- )
- return data
-
- def _invoke_field_validators(self, *, error_store, data, many):
- for attr_name in self._hooks[VALIDATES]:
- validator = getattr(self, attr_name)
- validator_kwargs = validator.__marshmallow_hook__[VALIDATES]
- field_name = validator_kwargs["field_name"]
-
- try:
- field_obj = self.fields[field_name]
- except KeyError as error:
- if field_name in self.declared_fields:
- continue
- raise ValueError(
- '"{}" field does not exist.'.format(field_name)
- ) from error
-
- if many:
- for idx, item in enumerate(data):
- try:
- value = item[field_obj.attribute or field_name]
- except KeyError:
- pass
- else:
- validated_value = self._call_and_store(
- getter_func=validator,
- data=value,
- field_name=field_obj.data_key or field_name,
- error_store=error_store,
- index=(idx if self.opts.index_errors else None),
- )
- if validated_value is missing:
- data[idx].pop(field_name, None)
- else:
- try:
- value = data[field_obj.attribute or field_name]
- except KeyError:
- pass
- else:
- validated_value = self._call_and_store(
- getter_func=validator,
- data=value,
- field_name=field_obj.data_key or field_name,
- error_store=error_store,
- )
- if validated_value is missing:
- data.pop(field_name, None)
-
- def _invoke_schema_validators(
- self,
- *,
- error_store,
- pass_many,
- data,
- original_data,
- many,
- partial,
- field_errors=False
- ):
- for attr_name in self._hooks[(VALIDATES_SCHEMA, pass_many)]:
- validator = getattr(self, attr_name)
- validator_kwargs = validator.__marshmallow_hook__[
- (VALIDATES_SCHEMA, pass_many)
- ]
- if field_errors and validator_kwargs["skip_on_field_errors"]:
- continue
- pass_original = validator_kwargs.get("pass_original", False)
-
- if many and not pass_many:
- for idx, (item, orig) in enumerate(zip(data, original_data)):
- self._run_validator(
- validator,
- item,
- original_data=orig,
- error_store=error_store,
- many=many,
- partial=partial,
- index=idx,
- pass_original=pass_original,
- )
- else:
- self._run_validator(
- validator,
- data,
- original_data=original_data,
- error_store=error_store,
- many=many,
- pass_original=pass_original,
- partial=partial,
- )
-
- def _invoke_processors(
- self, tag, *, pass_many, data, many, original_data=None, **kwargs
- ):
- key = (tag, pass_many)
- for attr_name in self._hooks[key]:
- # This will be a bound method.
- processor = getattr(self, attr_name)
-
- processor_kwargs = processor.__marshmallow_hook__[key]
- pass_original = processor_kwargs.get("pass_original", False)
-
- if pass_many:
- if pass_original:
- data = processor(data, original_data, many=many, **kwargs)
- else:
- data = processor(data, many=many, **kwargs)
- elif many:
- if pass_original:
- data = [
- processor(item, original, many=many, **kwargs)
- for item, original in zip(data, original_data)
- ]
- else:
- data = [processor(item, many=many, **kwargs) for item in data]
- else:
- if pass_original:
- data = processor(data, original_data, many=many, **kwargs)
- else:
- data = processor(data, many=many, **kwargs)
- return data
-
-
-class Schema(BaseSchema, metaclass=SchemaMeta):
- __doc__ = BaseSchema.__doc__
+ elif field_obj
\ No newline at end of file
+ source /opt/miniconda3/bin/activate
++ _CONDA_ROOT=/opt/miniconda3
++ . /opt/miniconda3/etc/profile.d/conda.sh
+++ export CONDA_EXE=/opt/miniconda3/bin/conda
+++ CONDA_EXE=/opt/miniconda3/bin/conda
+++ export _CE_M=
+++ _CE_M=
+++ export _CE_CONDA=
+++ _CE_CONDA=
+++ export CONDA_PYTHON_EXE=/opt/miniconda3/bin/python
+++ CONDA_PYTHON_EXE=/opt/miniconda3/bin/python
+++ '[' -z x ']'
++ conda activate
++ local cmd=activate
++ case "$cmd" in
++ __conda_activate activate
++ '[' -n '' ']'
++ local ask_conda
+++ PS1='(testbed) '
+++ __conda_exe shell.posix activate
+++ /opt/miniconda3/bin/conda shell.posix activate
++ ask_conda='PS1='\''(base) '\''
export PATH='\''/opt/miniconda3/bin:/opt/miniconda3/condabin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'\''
export CONDA_PREFIX='\''/opt/miniconda3'\''
export CONDA_SHLVL='\''4'\''
export CONDA_DEFAULT_ENV='\''base'\''
export CONDA_PROMPT_MODIFIER='\''(base) '\''
export CONDA_PREFIX_3='\''/opt/miniconda3/envs/testbed'\''
export CONDA_EXE='\''/opt/miniconda3/bin/conda'\''
export _CE_M='\'''\''
export _CE_CONDA='\'''\''
export CONDA_PYTHON_EXE='\''/opt/miniconda3/bin/python'\'''
++ eval 'PS1='\''(base) '\''
export PATH='\''/opt/miniconda3/bin:/opt/miniconda3/condabin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'\''
export CONDA_PREFIX='\''/opt/miniconda3'\''
export CONDA_SHLVL='\''4'\''
export CONDA_DEFAULT_ENV='\''base'\''
export CONDA_PROMPT_MODIFIER='\''(base) '\''
export CONDA_PREFIX_3='\''/opt/miniconda3/envs/testbed'\''
export CONDA_EXE='\''/opt/miniconda3/bin/conda'\''
export _CE_M='\'''\''
export _CE_CONDA='\'''\''
export CONDA_PYTHON_EXE='\''/opt/miniconda3/bin/python'\'''
+++ PS1='(base) '
+++ export PATH=/opt/miniconda3/bin:/opt/miniconda3/condabin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+++ PATH=/opt/miniconda3/bin:/opt/miniconda3/condabin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+++ export CONDA_PREFIX=/opt/miniconda3
+++ CONDA_PREFIX=/opt/miniconda3
+++ export CONDA_SHLVL=4
+++ CONDA_SHLVL=4
+++ export CONDA_DEFAULT_ENV=base
+++ CONDA_DEFAULT_ENV=base
+++ export 'CONDA_PROMPT_MODIFIER=(base) '
+++ CONDA_PROMPT_MODIFIER='(base) '
+++ export CONDA_PREFIX_3=/opt/miniconda3/envs/testbed
+++ CONDA_PREFIX_3=/opt/miniconda3/envs/testbed
+++ export CONDA_EXE=/opt/miniconda3/bin/conda
+++ CONDA_EXE=/opt/miniconda3/bin/conda
+++ export _CE_M=
+++ _CE_M=
+++ export _CE_CONDA=
+++ _CE_CONDA=
+++ export CONDA_PYTHON_EXE=/opt/miniconda3/bin/python
+++ CONDA_PYTHON_EXE=/opt/miniconda3/bin/python
++ __conda_hashr
++ '[' -n '' ']'
++ '[' -n '' ']'
++ hash -r
+ conda activate testbed
+ local cmd=activate
+ case "$cmd" in
+ __conda_activate activate testbed
+ '[' -n '' ']'
+ local ask_conda
++ PS1='(base) '
++ __conda_exe shell.posix activate testbed
++ /opt/miniconda3/bin/conda shell.posix activate testbed
+ ask_conda='PS1='\''(testbed) '\''
export PATH='\''/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/condabin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'\''
export CONDA_PREFIX='\''/opt/miniconda3/envs/testbed'\''
export CONDA_SHLVL='\''5'\''
export CONDA_DEFAULT_ENV='\''testbed'\''
export CONDA_PROMPT_MODIFIER='\''(testbed) '\''
export CONDA_PREFIX_4='\''/opt/miniconda3'\''
export CONDA_EXE='\''/opt/miniconda3/bin/conda'\''
export _CE_M='\'''\''
export _CE_CONDA='\'''\''
export CONDA_PYTHON_EXE='\''/opt/miniconda3/bin/python'\'''
+ eval 'PS1='\''(testbed) '\''
export PATH='\''/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/condabin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'\''
export CONDA_PREFIX='\''/opt/miniconda3/envs/testbed'\''
export CONDA_SHLVL='\''5'\''
export CONDA_DEFAULT_ENV='\''testbed'\''
export CONDA_PROMPT_MODIFIER='\''(testbed) '\''
export CONDA_PREFIX_4='\''/opt/miniconda3'\''
export CONDA_EXE='\''/opt/miniconda3/bin/conda'\''
export _CE_M='\'''\''
export _CE_CONDA='\'''\''
export CONDA_PYTHON_EXE='\''/opt/miniconda3/bin/python'\'''
++ PS1='(testbed) '
++ export PATH=/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/condabin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
++ PATH=/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/condabin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
++ export CONDA_PREFIX=/opt/miniconda3/envs/testbed
++ CONDA_PREFIX=/opt/miniconda3/envs/testbed
++ export CONDA_SHLVL=5
++ CONDA_SHLVL=5
++ export CONDA_DEFAULT_ENV=testbed
++ CONDA_DEFAULT_ENV=testbed
++ export 'CONDA_PROMPT_MODIFIER=(testbed) '
++ CONDA_PROMPT_MODIFIER='(testbed) '
++ export CONDA_PREFIX_4=/opt/miniconda3
++ CONDA_PREFIX_4=/opt/miniconda3
++ export CONDA_EXE=/opt/miniconda3/bin/conda
++ CONDA_EXE=/opt/miniconda3/bin/conda
++ export _CE_M=
++ _CE_M=
++ export _CE_CONDA=
++ _CE_CONDA=
++ export CONDA_PYTHON_EXE=/opt/miniconda3/bin/python
++ CONDA_PYTHON_EXE=/opt/miniconda3/bin/python
+ __conda_hashr
+ '[' -n '' ']'
+ '[' -n '' ']'
+ hash -r
+ python -m pip install -e '.[dev]'
Obtaining file:///testbed
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Checking if build backend supports build_editable: started
Checking if build backend supports build_editable: finished with status 'done'
Getting requirements to build editable: started
Getting requirements to build editable: finished with status 'done'
Preparing editable metadata (pyproject.toml): started
Preparing editable metadata (pyproject.toml): finished with status 'done'
Requirement already satisfied: pytest in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from marshmallow==3.0.0) (8.3.5)
Requirement already satisfied: pytz in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from marshmallow==3.0.0) (2025.2)
Requirement already satisfied: simplejson in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from marshmallow==3.0.0) (3.20.1)
Requirement already satisfied: flake8==3.7.8 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from marshmallow==3.0.0) (3.7.8)
Requirement already satisfied: flake8-bugbear==19.8.0 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from marshmallow==3.0.0) (19.8.0)
Requirement already satisfied: pre-commit~=1.17 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from marshmallow==3.0.0) (1.21.0)
Requirement already satisfied: tox in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from marshmallow==3.0.0) (4.25.0)
Requirement already satisfied: entrypoints<0.4.0,>=0.3.0 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from flake8==3.7.8->marshmallow==3.0.0) (0.3)
Requirement already satisfied: pyflakes<2.2.0,>=2.1.0 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from flake8==3.7.8->marshmallow==3.0.0) (2.1.1)
Requirement already satisfied: pycodestyle<2.6.0,>=2.5.0 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from flake8==3.7.8->marshmallow==3.0.0) (2.5.0)
Requirement already satisfied: mccabe<0.7.0,>=0.6.0 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from flake8==3.7.8->marshmallow==3.0.0) (0.6.1)
Requirement already satisfied: attrs in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from flake8-bugbear==19.8.0->marshmallow==3.0.0) (25.3.0)
Requirement already satisfied: aspy.yaml in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pre-commit~=1.17->marshmallow==3.0.0) (1.3.0)
Requirement already satisfied: cfgv>=2.0.0 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pre-commit~=1.17->marshmallow==3.0.0) (3.4.0)
Requirement already satisfied: identify>=1.0.0 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pre-commit~=1.17->marshmallow==3.0.0) (2.6.10)
Requirement already satisfied: nodeenv>=0.11.1 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pre-commit~=1.17->marshmallow==3.0.0) (1.9.1)
Requirement already satisfied: pyyaml in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pre-commit~=1.17->marshmallow==3.0.0) (6.0.2)
Requirement already satisfied: six in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pre-commit~=1.17->marshmallow==3.0.0) (1.17.0)
Requirement already satisfied: toml in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pre-commit~=1.17->marshmallow==3.0.0) (0.10.2)
Requirement already satisfied: virtualenv>=15.2 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pre-commit~=1.17->marshmallow==3.0.0) (20.31.1)
Requirement already satisfied: distlib<1,>=0.3.7 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from virtualenv>=15.2->pre-commit~=1.17->marshmallow==3.0.0) (0.3.9)
Requirement already satisfied: filelock<4,>=3.12.2 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from virtualenv>=15.2->pre-commit~=1.17->marshmallow==3.0.0) (3.18.0)
Requirement already satisfied: platformdirs<5,>=3.9.1 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from virtualenv>=15.2->pre-commit~=1.17->marshmallow==3.0.0) (4.3.7)
Requirement already satisfied: exceptiongroup>=1.0.0rc8 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pytest->marshmallow==3.0.0) (1.2.2)
Requirement already satisfied: iniconfig in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pytest->marshmallow==3.0.0) (2.1.0)
Requirement already satisfied: packaging in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pytest->marshmallow==3.0.0) (25.0)
Requirement already satisfied: pluggy<2,>=1.5 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pytest->marshmallow==3.0.0) (1.5.0)
Requirement already satisfied: tomli>=1 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pytest->marshmallow==3.0.0) (2.2.1)
Requirement already satisfied: cachetools>=5.5.1 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from tox->marshmallow==3.0.0) (5.5.2)
Requirement already satisfied: chardet>=5.2 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from tox->marshmallow==3.0.0) (5.2.0)
Requirement already satisfied: colorama>=0.4.6 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from tox->marshmallow==3.0.0) (0.4.6)
Requirement already satisfied: pyproject-api>=1.8 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from tox->marshmallow==3.0.0) (1.9.0)
Requirement already satisfied: typing-extensions>=4.12.2 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from tox->marshmallow==3.0.0) (4.15.0)
Building wheels for collected packages: marshmallow
Building editable for marshmallow (pyproject.toml): started
Building editable for marshmallow (pyproject.toml): finished with status 'done'
Created wheel for marshmallow: filename=marshmallow-3.0.0-0.editable-py2.py3-none-any.whl size=4552 sha256=ebe6eb9a87531162a1aad15a1bfe051c79e014f4baef10744174f7f0438b2dd4
Stored in directory: /tmp/pip-ephem-wheel-cache-c5v2wpmt/wheels/7d/66/67/70d1ee2124ccf21d601c352e25cdca10f611f7c8b3f9ffb9e4
Successfully built marshmallow
Installing collected packages: marshmallow
Attempting uninstall: marshmallow
Found existing installation: marshmallow 3.0.0
Uninstalling marshmallow-3.0.0:
Successfully uninstalled marshmallow-3.0.0
Successfully installed marshmallow-3.0.0
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager, possibly rendering your system unusable. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv. Use the --root-user-action option if you know what you are doing and want to suppress this warning.
+ git checkout b40a0f4e33823e6d0f341f7e8684e359a99060d1 tests/test_fields.py
Updated 0 paths from 56ab4168
+ git apply -v -
Checking patch tests/test_fields.py...
Applied patch tests/test_fields.py cleanly.
+ : '>>>>> Start Test Output'
+ pytest -rA tests/test_fields.py
ImportError while loading conftest '/testbed/tests/conftest.py'.
tests/conftest.py:4: in <module>
from tests.base import User, UserSchema, Blog
tests/base.py:9: in <module>
from marshmallow import Schema, fields, post_load, validate, missing
src/marshmallow/__init__.py:1: in <module>
from marshmallow.schema import Schema, SchemaOpts
E File "/testbed/src/marshmallow/schema.py", line 388
E elif field_obj
E ^
E SyntaxError: invalid syntax
+ : '>>>>> End Test Output'
+ git checkout b40a0f4e33823e6d0f341f7e8684e359a99060d1 tests/test_fields.py
Updated 1 path from 56ab4168
Reference output
diff --git a/src/marshmallow/fields.py b/src/marshmallow/fields.py
--- a/src/marshmallow/fields.py
+++ b/src/marshmallow/fields.py
@@ -1114,7 +1114,7 @@ def _bind_to_schema(self, field_name, schema):
super()._bind_to_schema(field_name, schema)
self.format = (
self.format
- or getattr(schema.opts, self.SCHEMA_OPTS_VAR_NAME)
+ or getattr(self.root.opts, self.SCHEMA_OPTS_VAR_NAME)
or self.DEFAULT_FORMAT
)
marshmallow-code__marshmallow-1343
marshmallow-code/marshmallow
Score
100%
Outcome
Passed benchmark
Task cost
$0.30
Duration
152 s
Summary
Passed benchmark
Resolved by official SWE-bench grading. Fail-to-pass: 100%. Pass-to-pass: 100%.
View task details
Run metadata
Benchmark
swe_bench/lite/dev
Model
claude-sonnet-4-5-20250929
Started
Mar 31, 2026, 2:06 AM UTC
Completed
Mar 31, 2026, 2:09 AM UTC
Sandbox
6749ab42-6b66-419a-80ea-f4c328b0063b
Tokens
In 20,294 / out 4,676
F2P / P2P
100% / 100%
Passed benchmark
Yes
Completed
]
tests/test_marshalling.py::TestUnmarshaller::test_deserialize_stores_errors PASSED [ 76%]
tests/test_marshalling.py::TestUnmarshaller::test_deserialize_fields_with_attribute_param PASSED [ 80%]
tests/test_marshalling.py::TestUnmarshaller::test_deserialize_fields_with_load_from_param PASSED [ 84%]
tests/test_marshalling.py::TestUnmarshaller::test_deserialize_fields_with_dump_only_param PASSED [ 88%]
tests/test_marshalling.py::TestUnmarshaller::test_deserialize_wrong_type_root_data PASSED [ 92%]
tests/test_marshalling.py::TestUnmarshaller::test_deserialize_wrong_type_nested_data PASSED [ 96%]
tests/test_marshalling.py::TestUnmarshaller::test_deserialize_wrong_nested_type_with_validates_method PASSED [100%]
=============================== warnings summary ===============================
src/marshmallow/__init__.py:19
/testbed/src/marshmallow/__init__.py:19: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
__version_info__ = tuple(LooseVersion(__version__).version)
tests/test_marshalling.py::TestUnmarshaller::test_extra_data_is_ignored
/testbed/src/marshmallow/marshalling.py:253: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.10 it will stop working
if not isinstance(data, collections.Mapping):
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
==================================== PASSES ====================================
=========================== short test summary info ============================
PASSED tests/test_marshalling.py::test_missing_is_falsy
PASSED tests/test_marshalling.py::TestMarshaller::test_prefix
PASSED tests/test_marshalling.py::TestMarshaller::test_marshalling_generator
PASSED tests/test_marshalling.py::TestMarshaller::test_default_to_missing
PASSED tests/test_marshalling.py::TestMarshaller::test_serialize_fields_with_load_only_param
PASSED tests/test_marshalling.py::TestMarshaller::test_missing_data_are_skipped
PASSED tests/test_marshalling.py::TestMarshaller::test_serialize_with_load_only_doesnt_validate
PASSED tests/test_marshalling.py::TestMarshaller::test_serialize_fields_with_dump_to_param
PASSED tests/test_marshalling.py::TestMarshaller::test_serialize_fields_with_dump_to_and_prefix_params
PASSED tests/test_marshalling.py::TestMarshaller::test_stores_indices_of_errors_when_many_equals_true
PASSED tests/test_marshalling.py::TestMarshaller::test_doesnt_store_errors_when_index_errors_equals_false
PASSED tests/test_marshalling.py::TestUnmarshaller::test_extra_data_is_ignored
PASSED tests/test_marshalling.py::TestUnmarshaller::test_stores_errors
PASSED tests/test_marshalling.py::TestUnmarshaller::test_stores_indices_of_errors_when_many_equals_true
PASSED tests/test_marshalling.py::TestUnmarshaller::test_doesnt_store_errors_when_index_errors_equals_false
PASSED tests/test_marshalling.py::TestUnmarshaller::test_deserialize
PASSED tests/test_marshalling.py::TestUnmarshaller::test_extra_fields
PASSED tests/test_marshalling.py::TestUnmarshaller::test_deserialize_many
PASSED tests/test_marshalling.py::TestUnmarshaller::test_deserialize_stores_errors
PASSED tests/test_marshalling.py::TestUnmarshaller::test_deserialize_fields_with_attribute_param
PASSED tests/test_marshalling.py::TestUnmarshaller::test_deserialize_fields_with_load_from_param
PASSED tests/test_marshalling.py::TestUnmarshaller::test_deserialize_fields_with_dump_only_param
PASSED tests/test_marshalling.py::TestUnmarshaller::test_deserialize_wrong_type_root_data
PASSED tests/test_marshalling.py::TestUnmarshaller::test_deserialize_wrong_type_nested_data
PASSED tests/test_marshalling.py::TestUnmarshaller::test_deserialize_wrong_nested_type_with_validates_method
======================== 25 passed, 2 warnings in 0.04s ========================
+ : '>>>>> End Test Output'
+ git checkout 2be2d83a1a9a6d3d9b85804f3ab545cecc409bb0 tests/test_marshalling.py
Updated 1 path from a3815758
Open in DaytonaBenchmark context
Task input
[version 2.20.0] TypeError: 'NoneType' object is not subscriptable
After update from version 2.19.5 to 2.20.0 I got error for code like:
```python
from marshmallow import Schema, fields, validates
class Bar(Schema):
value = fields.String()
@validates('value') # <- issue here
def validate_value(self, value):
pass
class Foo(Schema):
bar = fields.Nested(Bar)
sch = Foo()
sch.validate({
'bar': 'invalid',
})
```
```
Traceback (most recent call last):
File "/_/bug_mschema.py", line 19, in <module>
'bar': 'invalid',
File "/_/env/lib/python3.7/site-packages/marshmallow/schema.py", line 628, in validate
_, errors = self._do_load(data, many, partial=partial, postprocess=False)
File "/_/env/lib/python3.7/site-packages/marshmallow/schema.py", line 670, in _do_load
index_errors=self.opts.index_errors,
File "/_/env/lib/python3.7/site-packages/marshmallow/marshalling.py", line 292, in deserialize
index=(index if index_errors else None)
File "/_/env/lib/python3.7/site-packages/marshmallow/marshalling.py", line 65, in call_and_store
value = getter_func(data)
File "/_/env/lib/python3.7/site-packages/marshmallow/marshalling.py", line 285, in <lambda>
data
File "/_/env/lib/python3.7/site-packages/marshmallow/fields.py", line 265, in deserialize
output = self._deserialize(value, attr, data)
File "/_/env/lib/python3.7/site-packages/marshmallow/fields.py", line 465, in _deserialize
data, errors = self.schema.load(value)
File "/_/env/lib/python3.7/site-packages/marshmallow/schema.py", line 588, in load
result, errors = self._do_load(data, many, partial=partial, postprocess=True)
File "/_/env/lib/python3.7/site-packages/marshmallow/schema.py", line 674, in _do_load
self._invoke_field_validators(unmarshal, data=result, many=many)
File "/_/env/lib/python3.7/site-packages/marshmallow/schema.py", line 894, in _invoke_field_validators
value = data[field_obj.attribute or field_name]
TypeError: 'NoneType' object is not subscriptable
```
Fix tests
tests/test_marshalling.py::TestUnmarshaller::test_deserialize_wrong_nested_type_with_validates_method
Regression tests
tests/test_marshalling.py::test_missing_is_falsy tests/test_marshalling.py::TestMarshaller::test_prefix tests/test_marshalling.py::TestMarshaller::test_marshalling_generator tests/test_marshalling.py::TestMarshaller::test_default_to_missing tests/test_marshalling.py::TestMarshaller::test_serialize_fields_with_load_only_param tests/test_marshalling.py::TestMarshaller::test_missing_data_are_skipped tests/test_marshalling.py::TestMarshaller::test_serialize_with_load_only_doesnt_validate tests/test_marshalling.py::TestMarshaller::test_serialize_fields_with_dump_to_param tests/test_marshalling.py::TestMarshaller::test_serialize_fields_with_dump_to_and_prefix_params tests/test_marshalling.py::TestMarshaller::test_stores_indices_of_errors_when_many_equals_true tests/test_marshalling.py::TestMarshaller::test_doesnt_store_errors_when_index_errors_equals_false tests/test_marshalling.py::TestUnmarshaller::test_extra_data_is_ignored tests/test_marshalling.py::TestUnmarshaller::test_stores_errors tests/test_marshalling.py::TestUnmarshaller::test_stores_indices_of_errors_when_many_equals_true tests/test_marshalling.py::TestUnmarshaller::test_doesnt_store_errors_when_index_errors_equals_false tests/test_marshalling.py::TestUnmarshaller::test_deserialize tests/test_marshalling.py::TestUnmarshaller::test_extra_fields tests/test_marshalling.py::TestUnmarshaller::test_deserialize_many tests/test_marshalling.py::TestUnmarshaller::test_deserialize_stores_errors tests/test_marshalling.py::TestUnmarshaller::test_deserialize_fields_with_attribute_param tests/test_marshalling.py::TestUnmarshaller::test_deserialize_fields_with_load_from_param tests/test_marshalling.py::TestUnmarshaller::test_deserialize_fields_with_dump_only_param tests/test_marshalling.py::TestUnmarshaller::test_deserialize_wrong_type_root_data tests/test_marshalling.py::TestUnmarshaller::test_deserialize_wrong_type_nested_data
Execution
Scorer detail
Resolved by official SWE-bench grading. Fail-to-pass: 100%. Pass-to-pass: 100%.
Patch text
diff --git a/src/marshmallow/schema.py b/src/marshmallow/schema.py
index 085c509b..e245283a 100644
--- a/src/marshmallow/schema.py
+++ b/src/marshmallow/schema.py
@@ -858,8 +858,6 @@ class BaseSchema(base.SchemaABC):
data=data, many=many, original_data=original_data)
data = self._invoke_processors(tag_name, pass_many=False,
data=data, many=many, original_data=original_data)
- return data
-
def _invoke_field_validators(self, unmarshal, data, many):
for attr_name in self.__processors__[(VALIDATES, False)]:
validator = getattr(self, attr_name)
@@ -873,8 +871,10 @@ class BaseSchema(base.SchemaABC):
continue
raise ValueError('"{0}" field does not exist.'.format(field_name))
+ if data is None:
+ continue
+
if many:
- for idx, item in enumerate(data):
try:
value = item[field_obj.attribute or field_name]
except KeyError:Stdout
[anthropic-agent] instance=marshmallow-code__marshmallow-1343 [anthropic-agent] repo=marshmallow-code/marshmallow [anthropic-agent] sandbox=6749ab42-6b66-419a-80ea-f4c328b0063b [anthropic-agent] model=claude-sonnet-4-5-20250929 [anthropic-agent] context_files=5 [anthropic-agent] full_file_context=yes [anthropic-agent] edit_attempts=4
Stderr
[anthropic-agent] Attempt 1: File-rewrite plan contained no files.
[anthropic-agent] Attempt 2: Anthropic call failed for single_file_rewrite: Anthropic request failed: HTTPStatusError: Client error '429 Too Many Requests' for url 'https://api.anthropic.com/v1/messages'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429. Response body: {"type":"error","error":{"type":"rate_limit_error","message":"This request would exceed your organization's rate limit of 30,000 input tokens per minute (org: 7cd50861-f334-4b49-afb7-3c1da9371b1a, model: claude-sonnet-4-5-20250929). For details, refer to: https://docs.claude.com/en/api/rate-limits. You can see the response headers for current usage. Please reduce the prompt length or the maximum t
[anthropic-agent] Attempt 3: Anthropic call failed for line_ranges: Anthropic request failed: HTTPStatusError: Client error '429 Too Many Requests' for url 'https://api.anthropic.com/v1/messages'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429. Response body: {"type":"error","error":{"type":"rate_limit_error","message":"This request would exceed your organization's rate limit of 30,000 input tokens per minute (org: 7cd50861-f334-4b49-afb7-3c1da9371b1a, model: claude-sonnet-4-5-20250929). For details, refer to: https://docs.claude.com/en/api/rate-limits. You can see the response headers for current usage. Please reduce the prompt length or the maximum tAgent output
diff --git a/src/marshmallow/schema.py b/src/marshmallow/schema.py
index 085c509b..e245283a 100644
--- a/src/marshmallow/schema.py
+++ b/src/marshmallow/schema.py
@@ -858,8 +858,6 @@ class BaseSchema(base.SchemaABC):
data=data, many=many, original_data=original_data)
data = self._invoke_processors(tag_name, pass_many=False,
data=data, many=many, original_data=original_data)
- return data
-
def _invoke_field_validators(self, unmarshal, data, many):
for attr_name in self.__processors__[(VALIDATES, False)]:
validator = getattr(self, attr_name)
@@ -873,8 +871,10 @@ class BaseSchema(base.SchemaABC):
continue
raise ValueError('"{0}" field does not exist.'.format(field_name))
+ if data is None:
+ continue
+
if many:
- for idx, item in enumerate(data):
try:
value = item[field_obj.attribute or field_name]
except KeyError:Scoring
Passing target tests
tests/test_marshalling.py::TestUnmarshaller::test_deserialize_wrong_nested_type_with_validates_method
Failing target tests
No fail-to-pass failures recorded yet.
Maintained regression tests
tests/test_marshalling.py::test_missing_is_falsy tests/test_marshalling.py::TestMarshaller::test_prefix tests/test_marshalling.py::TestMarshaller::test_marshalling_generator tests/test_marshalling.py::TestMarshaller::test_default_to_missing tests/test_marshalling.py::TestMarshaller::test_serialize_fields_with_load_only_param tests/test_marshalling.py::TestMarshaller::test_missing_data_are_skipped tests/test_marshalling.py::TestMarshaller::test_serialize_with_load_only_doesnt_validate tests/test_marshalling.py::TestMarshaller::test_serialize_fields_with_dump_to_param tests/test_marshalling.py::TestMarshaller::test_serialize_fields_with_dump_to_and_prefix_params tests/test_marshalling.py::TestMarshaller::test_stores_indices_of_errors_when_many_equals_true tests/test_marshalling.py::TestMarshaller::test_doesnt_store_errors_when_index_errors_equals_false tests/test_marshalling.py::TestUnmarshaller::test_extra_data_is_ignored tests/test_marshalling.py::TestUnmarshaller::test_stores_errors tests/test_marshalling.py::TestUnmarshaller::test_stores_indices_of_errors_when_many_equals_true tests/test_marshalling.py::TestUnmarshaller::test_doesnt_store_errors_when_index_errors_equals_false tests/test_marshalling.py::TestUnmarshaller::test_deserialize tests/test_marshalling.py::TestUnmarshaller::test_extra_fields tests/test_marshalling.py::TestUnmarshaller::test_deserialize_many tests/test_marshalling.py::TestUnmarshaller::test_deserialize_stores_errors tests/test_marshalling.py::TestUnmarshaller::test_deserialize_fields_with_attribute_param tests/test_marshalling.py::TestUnmarshaller::test_deserialize_fields_with_load_from_param tests/test_marshalling.py::TestUnmarshaller::test_deserialize_fields_with_dump_only_param tests/test_marshalling.py::TestUnmarshaller::test_deserialize_wrong_type_root_data tests/test_marshalling.py::TestUnmarshaller::test_deserialize_wrong_type_nested_data
Regressed tests
No regression failures recorded yet.
Harness output
+ source /opt/miniconda3/bin/activate
++ _CONDA_ROOT=/opt/miniconda3
++ . /opt/miniconda3/etc/profile.d/conda.sh
+++ export CONDA_EXE=/opt/miniconda3/bin/conda
+++ CONDA_EXE=/opt/miniconda3/bin/conda
+++ export _CE_M=
+++ _CE_M=
+++ export _CE_CONDA=
+++ _CE_CONDA=
+++ export CONDA_PYTHON_EXE=/opt/miniconda3/bin/python
+++ CONDA_PYTHON_EXE=/opt/miniconda3/bin/python
+++ '[' -z x ']'
++ conda activate
++ local cmd=activate
++ case "$cmd" in
++ __conda_activate activate
++ '[' -n '' ']'
++ local ask_conda
+++ PS1=
+++ __conda_exe shell.posix activate
+++ /opt/miniconda3/bin/conda shell.posix activate
++ ask_conda='PS1='\''(base) '\''
export PATH='\''/opt/miniconda3/bin:/opt/miniconda3/condabin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'\''
export CONDA_PREFIX='\''/opt/miniconda3'\''
export CONDA_SHLVL='\''2'\''
export CONDA_DEFAULT_ENV='\''base'\''
export CONDA_PROMPT_MODIFIER='\''(base) '\''
export CONDA_PREFIX_1='\''/opt/miniconda3/envs/testbed'\''
export CONDA_EXE='\''/opt/miniconda3/bin/conda'\''
export _CE_M='\'''\''
export _CE_CONDA='\'''\''
export CONDA_PYTHON_EXE='\''/opt/miniconda3/bin/python'\'''
++ eval 'PS1='\''(base) '\''
export PATH='\''/opt/miniconda3/bin:/opt/miniconda3/condabin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'\''
export CONDA_PREFIX='\''/opt/miniconda3'\''
export CONDA_SHLVL='\''2'\''
export CONDA_DEFAULT_ENV='\''base'\''
export CONDA_PROMPT_MODIFIER='\''(base) '\''
export CONDA_PREFIX_1='\''/opt/miniconda3/envs/testbed'\''
export CONDA_EXE='\''/opt/miniconda3/bin/conda'\''
export _CE_M='\'''\''
export _CE_CONDA='\'''\''
export CONDA_PYTHON_EXE='\''/opt/miniconda3/bin/python'\'''
+++ PS1='(base) '
+++ export PATH=/opt/miniconda3/bin:/opt/miniconda3/condabin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+++ PATH=/opt/miniconda3/bin:/opt/miniconda3/condabin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+++ export CONDA_PREFIX=/opt/miniconda3
+++ CONDA_PREFIX=/opt/miniconda3
+++ export CONDA_SHLVL=2
+++ CONDA_SHLVL=2
+++ export CONDA_DEFAULT_ENV=base
+++ CONDA_DEFAULT_ENV=base
+++ export 'CONDA_PROMPT_MODIFIER=(base) '
+++ CONDA_PROMPT_MODIFIER='(base) '
+++ export CONDA_PREFIX_1=/opt/miniconda3/envs/testbed
+++ CONDA_PREFIX_1=/opt/miniconda3/envs/testbed
+++ export CONDA_EXE=/opt/miniconda3/bin/conda
+++ CONDA_EXE=/opt/miniconda3/bin/conda
+++ export _CE_M=
+++ _CE_M=
+++ export _CE_CONDA=
+++ _CE_CONDA=
+++ export CONDA_PYTHON_EXE=/opt/miniconda3/bin/python
+++ CONDA_PYTHON_EXE=/opt/miniconda3/bin/python
++ __conda_hashr
++ '[' -n '' ']'
++ '[' -n '' ']'
++ hash -r
+ conda activate testbed
+ local cmd=activate
+ case "$cmd" in
+ __conda_activate activate testbed
+ '[' -n '' ']'
+ local ask_conda
++ PS1='(base) '
++ __conda_exe shell.posix activate testbed
++ /opt/miniconda3/bin/conda shell.posix activate testbed
+ ask_conda='PS1='\''(testbed) '\''
export PATH='\''/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/condabin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'\''
export CONDA_PREFIX='\''/opt/miniconda3/envs/testbed'\''
export CONDA_SHLVL='\''3'\''
export CONDA_DEFAULT_ENV='\''testbed'\''
export CONDA_PROMPT_MODIFIER='\''(testbed) '\''
export CONDA_PREFIX_2='\''/opt/miniconda3'\''
export CONDA_EXE='\''/opt/miniconda3/bin/conda'\''
export _CE_M='\'''\''
export _CE_CONDA='\'''\''
export CONDA_PYTHON_EXE='\''/opt/miniconda3/bin/python'\'''
+ eval 'PS1='\''(testbed) '\''
export PATH='\''/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/condabin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'\''
export CONDA_PREFIX='\''/opt/miniconda3/envs/testbed'\''
export CONDA_SHLVL='\''3'\''
export CONDA_DEFAULT_ENV='\''testbed'\''
export CONDA_PROMPT_MODIFIER='\''(testbed) '\''
export CONDA_PREFIX_2='\''/opt/miniconda3'\''
export CONDA_EXE='\''/opt/miniconda3/bin/conda'\''
export _CE_M='\'''\''
export _CE_CONDA='\'''\''
export CONDA_PYTHON_EXE='\''/opt/miniconda3/bin/python'\'''
++ PS1='(testbed) '
++ export PATH=/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/condabin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
++ PATH=/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/condabin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
++ export CONDA_PREFIX=/opt/miniconda3/envs/testbed
++ CONDA_PREFIX=/opt/miniconda3/envs/testbed
++ export CONDA_SHLVL=3
++ CONDA_SHLVL=3
++ export CONDA_DEFAULT_ENV=testbed
++ CONDA_DEFAULT_ENV=testbed
++ export 'CONDA_PROMPT_MODIFIER=(testbed) '
++ CONDA_PROMPT_MODIFIER='(testbed) '
++ export CONDA_PREFIX_2=/opt/miniconda3
++ CONDA_PREFIX_2=/opt/miniconda3
++ export CONDA_EXE=/opt/miniconda3/bin/conda
++ CONDA_EXE=/opt/miniconda3/bin/conda
++ export _CE_M=
++ _CE_M=
++ export _CE_CONDA=
++ _CE_CONDA=
++ export CONDA_PYTHON_EXE=/opt/miniconda3/bin/python
++ CONDA_PYTHON_EXE=/opt/miniconda3/bin/python
+ __conda_hashr
+ '[' -n '' ']'
+ '[' -n '' ']'
+ hash -r
+ cd /testbed
+ git config --global --add safe.directory /testbed
+ cd /testbed
+ git status
On branch dev
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: src/marshmallow/schema.py
no changes added to commit (use "git add" and/or "git commit -a")
+ git show
commit d4f98233971ee3e73bba47026cd77b4ba69a25bb
Author: SWE-bench <setup@swebench.config>
Date: Tue May 6 23:07:21 2025 +0000
SWE-bench
+ git -c core.fileMode=false diff 2be2d83a1a9a6d3d9b85804f3ab545cecc409bb0
diff --git a/src/marshmallow/schema.py b/src/marshmallow/schema.py
index 085c509b..e245283a 100644
--- a/src/marshmallow/schema.py
+++ b/src/marshmallow/schema.py
@@ -858,8 +858,6 @@ class BaseSchema(base.SchemaABC):
data=data, many=many, original_data=original_data)
data = self._invoke_processors(tag_name, pass_many=False,
data=data, many=many, original_data=original_data)
- return data
-
def _invoke_field_validators(self, unmarshal, data, many):
for attr_name in self.__processors__[(VALIDATES, False)]:
validator = getattr(self, attr_name)
@@ -873,8 +871,10 @@ class BaseSchema(base.SchemaABC):
continue
raise ValueError('"{0}" field does not exist.'.format(field_name))
+ if data is None:
+ continue
+
if many:
- for idx, item in enumerate(data):
try:
value = item[field_obj.attribute or field_name]
except KeyError:
+ source /opt/miniconda3/bin/activate
++ _CONDA_ROOT=/opt/miniconda3
++ . /opt/miniconda3/etc/profile.d/conda.sh
+++ export CONDA_EXE=/opt/miniconda3/bin/conda
+++ CONDA_EXE=/opt/miniconda3/bin/conda
+++ export _CE_M=
+++ _CE_M=
+++ export _CE_CONDA=
+++ _CE_CONDA=
+++ export CONDA_PYTHON_EXE=/opt/miniconda3/bin/python
+++ CONDA_PYTHON_EXE=/opt/miniconda3/bin/python
+++ '[' -z x ']'
++ conda activate
++ local cmd=activate
++ case "$cmd" in
++ __conda_activate activate
++ '[' -n '' ']'
++ local ask_conda
+++ PS1='(testbed) '
+++ __conda_exe shell.posix activate
+++ /opt/miniconda3/bin/conda shell.posix activate
++ ask_conda='PS1='\''(base) '\''
export PATH='\''/opt/miniconda3/bin:/opt/miniconda3/condabin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'\''
export CONDA_PREFIX='\''/opt/miniconda3'\''
export CONDA_SHLVL='\''4'\''
export CONDA_DEFAULT_ENV='\''base'\''
export CONDA_PROMPT_MODIFIER='\''(base) '\''
export CONDA_PREFIX_3='\''/opt/miniconda3/envs/testbed'\''
export CONDA_EXE='\''/opt/miniconda3/bin/conda'\''
export _CE_M='\'''\''
export _CE_CONDA='\'''\''
export CONDA_PYTHON_EXE='\''/opt/miniconda3/bin/python'\'''
++ eval 'PS1='\''(base) '\''
export PATH='\''/opt/miniconda3/bin:/opt/miniconda3/condabin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'\''
export CONDA_PREFIX='\''/opt/miniconda3'\''
export CONDA_SHLVL='\''4'\''
export CONDA_DEFAULT_ENV='\''base'\''
export CONDA_PROMPT_MODIFIER='\''(base) '\''
export CONDA_PREFIX_3='\''/opt/miniconda3/envs/testbed'\''
export CONDA_EXE='\''/opt/miniconda3/bin/conda'\''
export _CE_M='\'''\''
export _CE_CONDA='\'''\''
export CONDA_PYTHON_EXE='\''/opt/miniconda3/bin/python'\'''
+++ PS1='(base) '
+++ export PATH=/opt/miniconda3/bin:/opt/miniconda3/condabin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+++ PATH=/opt/miniconda3/bin:/opt/miniconda3/condabin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+++ export CONDA_PREFIX=/opt/miniconda3
+++ CONDA_PREFIX=/opt/miniconda3
+++ export CONDA_SHLVL=4
+++ CONDA_SHLVL=4
+++ export CONDA_DEFAULT_ENV=base
+++ CONDA_DEFAULT_ENV=base
+++ export 'CONDA_PROMPT_MODIFIER=(base) '
+++ CONDA_PROMPT_MODIFIER='(base) '
+++ export CONDA_PREFIX_3=/opt/miniconda3/envs/testbed
+++ CONDA_PREFIX_3=/opt/miniconda3/envs/testbed
+++ export CONDA_EXE=/opt/miniconda3/bin/conda
+++ CONDA_EXE=/opt/miniconda3/bin/conda
+++ export _CE_M=
+++ _CE_M=
+++ export _CE_CONDA=
+++ _CE_CONDA=
+++ export CONDA_PYTHON_EXE=/opt/miniconda3/bin/python
+++ CONDA_PYTHON_EXE=/opt/miniconda3/bin/python
++ __conda_hashr
++ '[' -n '' ']'
++ '[' -n '' ']'
++ hash -r
+ conda activate testbed
+ local cmd=activate
+ case "$cmd" in
+ __conda_activate activate testbed
+ '[' -n '' ']'
+ local ask_conda
++ PS1='(base) '
++ __conda_exe shell.posix activate testbed
++ /opt/miniconda3/bin/conda shell.posix activate testbed
+ ask_conda='PS1='\''(testbed) '\''
export PATH='\''/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/condabin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'\''
export CONDA_PREFIX='\''/opt/miniconda3/envs/testbed'\''
export CONDA_SHLVL='\''5'\''
export CONDA_DEFAULT_ENV='\''testbed'\''
export CONDA_PROMPT_MODIFIER='\''(testbed) '\''
export CONDA_PREFIX_4='\''/opt/miniconda3'\''
export CONDA_EXE='\''/opt/miniconda3/bin/conda'\''
export _CE_M='\'''\''
export _CE_CONDA='\'''\''
export CONDA_PYTHON_EXE='\''/opt/miniconda3/bin/python'\'''
+ eval 'PS1='\''(testbed) '\''
export PATH='\''/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/condabin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'\''
export CONDA_PREFIX='\''/opt/miniconda3/envs/testbed'\''
export CONDA_SHLVL='\''5'\''
export CONDA_DEFAULT_ENV='\''testbed'\''
export CONDA_PROMPT_MODIFIER='\''(testbed) '\''
export CONDA_PREFIX_4='\''/opt/miniconda3'\''
export CONDA_EXE='\''/opt/miniconda3/bin/conda'\''
export _CE_M='\'''\''
export _CE_CONDA='\'''\''
export CONDA_PYTHON_EXE='\''/opt/miniconda3/bin/python'\'''
++ PS1='(testbed) '
++ export PATH=/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/condabin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
++ PATH=/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/condabin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
++ export CONDA_PREFIX=/opt/miniconda3/envs/testbed
++ CONDA_PREFIX=/opt/miniconda3/envs/testbed
++ export CONDA_SHLVL=5
++ CONDA_SHLVL=5
++ export CONDA_DEFAULT_ENV=testbed
++ CONDA_DEFAULT_ENV=testbed
++ export 'CONDA_PROMPT_MODIFIER=(testbed) '
++ CONDA_PROMPT_MODIFIER='(testbed) '
++ export CONDA_PREFIX_4=/opt/miniconda3
++ CONDA_PREFIX_4=/opt/miniconda3
++ export CONDA_EXE=/opt/miniconda3/bin/conda
++ CONDA_EXE=/opt/miniconda3/bin/conda
++ export _CE_M=
++ _CE_M=
++ export _CE_CONDA=
++ _CE_CONDA=
++ export CONDA_PYTHON_EXE=/opt/miniconda3/bin/python
++ CONDA_PYTHON_EXE=/opt/miniconda3/bin/python
+ __conda_hashr
+ '[' -n '' ']'
+ '[' -n '' ']'
+ hash -r
+ python -m pip install -e '.[dev]'
Obtaining file:///testbed
Preparing metadata (setup.py): started
Preparing metadata (setup.py): finished with status 'done'
Requirement already satisfied: python-dateutil in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from marshmallow==2.20.0) (2.9.0.post0)
Requirement already satisfied: simplejson in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from marshmallow==2.20.0) (3.20.1)
Requirement already satisfied: pytest in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from marshmallow==2.20.0) (8.3.5)
Requirement already satisfied: pytz in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from marshmallow==2.20.0) (2025.2)
Requirement already satisfied: flake8==3.7.4 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from marshmallow==2.20.0) (3.7.4)
Requirement already satisfied: tox in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from marshmallow==2.20.0) (4.25.0)
Requirement already satisfied: entrypoints<0.4.0,>=0.3.0 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from flake8==3.7.4->marshmallow==2.20.0) (0.3)
Requirement already satisfied: pyflakes<2.2.0,>=2.1.0 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from flake8==3.7.4->marshmallow==2.20.0) (2.1.1)
Requirement already satisfied: pycodestyle<2.6.0,>=2.5.0 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from flake8==3.7.4->marshmallow==2.20.0) (2.5.0)
Requirement already satisfied: mccabe<0.7.0,>=0.6.0 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from flake8==3.7.4->marshmallow==2.20.0) (0.6.1)
Requirement already satisfied: exceptiongroup>=1.0.0rc8 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pytest->marshmallow==2.20.0) (1.2.2)
Requirement already satisfied: iniconfig in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pytest->marshmallow==2.20.0) (2.1.0)
Requirement already satisfied: packaging in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pytest->marshmallow==2.20.0) (25.0)
Requirement already satisfied: pluggy<2,>=1.5 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pytest->marshmallow==2.20.0) (1.5.0)
Requirement already satisfied: tomli>=1 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from pytest->marshmallow==2.20.0) (2.2.1)
Requirement already satisfied: six>=1.5 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from python-dateutil->marshmallow==2.20.0) (1.17.0)
Requirement already satisfied: cachetools>=5.5.1 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from tox->marshmallow==2.20.0) (5.5.2)
Requirement already satisfied: chardet>=5.2 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from tox->marshmallow==2.20.0) (5.2.0)
Requirement already satisfied: colorama>=0.4.6 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from tox->marshmallow==2.20.0) (0.4.6)
Requirement already satisfied: filelock>=3.16.1 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from tox->marshmallow==2.20.0) (3.18.0)
Requirement already satisfied: platformdirs>=4.3.6 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from tox->marshmallow==2.20.0) (4.3.7)
Requirement already satisfied: pyproject-api>=1.8 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from tox->marshmallow==2.20.0) (1.9.0)
Requirement already satisfied: typing-extensions>=4.12.2 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from tox->marshmallow==2.20.0) (4.15.0)
Requirement already satisfied: virtualenv>=20.29.1 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from tox->marshmallow==2.20.0) (20.31.1)
Requirement already satisfied: distlib<1,>=0.3.7 in /opt/miniconda3/envs/testbed/lib/python3.9/site-packages (from virtualenv>=20.29.1->tox->marshmallow==2.20.0) (0.3.9)
Installing collected packages: marshmallow
Attempting uninstall: marshmallow
Found existing installation: marshmallow 2.20.0
Uninstalling marshmallow-2.20.0:
Successfully uninstalled marshmallow-2.20.0
DEPRECATION: Legacy editable install of marshmallow[dev]==2.20.0 from file:///testbed (setup.py develop) is deprecated. pip 25.3 will enforce this behaviour change. A possible replacement is to add a pyproject.toml or enable --use-pep517, and use setuptools >= 64. If the resulting installation is not behaving as expected, try using --config-settings editable_mode=compat. Please consult the setuptools documentation for more information. Discussion can be found at https://github.com/pypa/pip/issues/11457
Running setup.py develop for marshmallow
Successfully installed marshmallow
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager, possibly rendering your system unusable. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv. Use the --root-user-action option if you know what you are doing and want to suppress this warning.
+ git checkout 2be2d83a1a9a6d3d9b85804f3ab545cecc409bb0 tests/test_marshalling.py
Updated 0 paths from a3815758
+ git apply -v -
Checking patch tests/test_marshalling.py...
Applied patch tests/test_marshalling.py cleanly.
+ : '>>>>> Start Test Output'
+ pytest -rA tests/test_marshalling.py
============================= test session starts ==============================
platform linux -- Python 3.9.21, pytest-8.3.5, pluggy-1.5.0 -- /opt/miniconda3/envs/testbed/bin/python
cachedir: .pytest_cache
rootdir: /testbed
configfile: setup.cfg
plugins: anyio-4.12.1
collecting ... collected 25 items
tests/test_marshalling.py::test_missing_is_falsy PASSED [ 4%]
tests/test_marshalling.py::TestMarshaller::test_prefix PASSED [ 8%]
tests/test_marshalling.py::TestMarshaller::test_marshalling_generator PASSED [ 12%]
tests/test_marshalling.py::TestMarshaller::test_default_to_missing PASSED [ 16%]
tests/test_marshalling.py::TestMarshaller::test_serialize_fields_with_load_only_param PASSED [ 20%]
tests/test_marshalling.py::TestMarshaller::test_missing_data_are_skipped PASSED [ 24%]
tests/test_marshalling.py::TestMarshaller::test_serialize_with_load_only_doesnt_validate PASSED [ 28%]
tests/test_marshalling.py::TestMarshaller::test_serialize_fields_with_dump_to_param PASSED [ 32%]
tests/test_marshalling.py::TestMarshaller::test_serialize_fields_with_dump_to_and_prefix_params PASSED [ 36%]
tests/test_marshalling.py::TestMarshaller::test_stores_indices_of_errors_when_many_equals_true PASSED [ 40%]
tests/test_marshalling.py::TestMarshaller::test_doesnt_store_errors_when_index_errors_equals_false PASSED [ 44%]
tests/test_marshalling.py::TestUnmarshaller::test_extra_data_is_ignored PASSED [ 48%]
tests/test_marshalling.py::TestUnmarshaller::test_stores_errors PASSED [ 52%]
tests/test_marshalling.py::TestUnmarshaller::test_stores_indices_of_errors_when_many_equals_true PASSED [ 56%]
tests/test_marshalling.py::TestUnmarshaller::test_doesnt_store_errors_when_index_errors_equals_false PASSED [ 60%]
tests/test_marshalling.py::TestUnmarshaller::test_deserialize PASSED [ 64%]
tests/test_marshalling.py::TestUnmarshaller::test_extra_fields PASSED [ 68%]
tests/test_marshalling.py::TestUnmarshaller::test_deserialize_many PASSED [ 72%]
tests/test_marshalling.py::TestUnmarshaller::test_deserialize_stores_errors PASSED [ 76%]
tests/test_marshalling.py::TestUnmarshaller::test_deserialize_fields_with_attribute_param PASSED [ 80%]
tests/test_marshalling.py::TestUnmarshaller::test_deserialize_fields_with_load_from_param PASSED [ 84%]
tests/test_marshalling.py::TestUnmarshaller::test_deserialize_fields_with_dump_only_param PASSED [ 88%]
tests/test_marshalling.py::TestUnmarshaller::test_deserialize_wrong_type_root_data PASSED [ 92%]
tests/test_marshalling.py::TestUnmarshaller::test_deserialize_wrong_type_nested_data PASSED [ 96%]
tests/test_marshalling.py::TestUnmarshaller::test_deserialize_wrong_nested_type_with_validates_method PASSED [100%]
=============================== warnings summary ===============================
src/marshmallow/__init__.py:19
/testbed/src/marshmallow/__init__.py:19: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
__version_info__ = tuple(LooseVersion(__version__).version)
tests/test_marshalling.py::TestUnmarshaller::test_extra_data_is_ignored
/testbed/src/marshmallow/marshalling.py:253: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.10 it will stop working
if not isinstance(data, collections.Mapping):
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
==================================== PASSES ====================================
=========================== short test summary info ============================
PASSED tests/test_marshalling.py::test_missing_is_falsy
PASSED tests/test_marshalling.py::TestMarshaller::test_prefix
PASSED tests/test_marshalling.py::TestMarshaller::test_marshalling_generator
PASSED tests/test_marshalling.py::TestMarshaller::test_default_to_missing
PASSED tests/test_marshalling.py::TestMarshaller::test_serialize_fields_with_load_only_param
PASSED tests/test_marshalling.py::TestMarshaller::test_missing_data_are_skipped
PASSED tests/test_marshalling.py::TestMarshaller::test_serialize_with_load_only_doesnt_validate
PASSED tests/test_marshalling.py::TestMarshaller::test_serialize_fields_with_dump_to_param
PASSED tests/test_marshalling.py::TestMarshaller::test_serialize_fields_with_dump_to_and_prefix_params
PASSED tests/test_marshalling.py::TestMarshaller::test_stores_indices_of_errors_when_many_equals_true
PASSED tests/test_marshalling.py::TestMarshaller::test_doesnt_store_errors_when_index_errors_equals_false
PASSED tests/test_marshalling.py::TestUnmarshaller::test_extra_data_is_ignored
PASSED tests/test_marshalling.py::TestUnmarshaller::test_stores_errors
PASSED tests/test_marshalling.py::TestUnmarshaller::test_stores_indices_of_errors_when_many_equals_true
PASSED tests/test_marshalling.py::TestUnmarshaller::test_doesnt_store_errors_when_index_errors_equals_false
PASSED tests/test_marshalling.py::TestUnmarshaller::test_deserialize
PASSED tests/test_marshalling.py::TestUnmarshaller::test_extra_fields
PASSED tests/test_marshalling.py::TestUnmarshaller::test_deserialize_many
PASSED tests/test_marshalling.py::TestUnmarshaller::test_deserialize_stores_errors
PASSED tests/test_marshalling.py::TestUnmarshaller::test_deserialize_fields_with_attribute_param
PASSED tests/test_marshalling.py::TestUnmarshaller::test_deserialize_fields_with_load_from_param
PASSED tests/test_marshalling.py::TestUnmarshaller::test_deserialize_fields_with_dump_only_param
PASSED tests/test_marshalling.py::TestUnmarshaller::test_deserialize_wrong_type_root_data
PASSED tests/test_marshalling.py::TestUnmarshaller::test_deserialize_wrong_type_nested_data
PASSED tests/test_marshalling.py::TestUnmarshaller::test_deserialize_wrong_nested_type_with_validates_method
======================== 25 passed, 2 warnings in 0.04s ========================
+ : '>>>>> End Test Output'
+ git checkout 2be2d83a1a9a6d3d9b85804f3ab545cecc409bb0 tests/test_marshalling.py
Updated 1 path from a3815758
Reference output
diff --git a/src/marshmallow/schema.py b/src/marshmallow/schema.py
--- a/src/marshmallow/schema.py
+++ b/src/marshmallow/schema.py
@@ -877,7 +877,7 @@ def _invoke_field_validators(self, unmarshal, data, many):
for idx, item in enumerate(data):
try:
value = item[field_obj.attribute or field_name]
- except KeyError:
+ except (KeyError, TypeError):
pass
else:
validated_value = unmarshal.call_and_store(
@@ -892,7 +892,7 @@ def _invoke_field_validators(self, unmarshal, data, many):
else:
try:
value = data[field_obj.attribute or field_name]
- except KeyError:
+ except (KeyError, TypeError):
pass
else:
validated_value = unmarshal.call_and_store(
Rerun config
Reuse this benchmark setup
Copy the config or relaunch the same run shape.
Benchmark
swe_bench / lite / dev
Concurrency
2
Agent image
agentarena-build:53985d1aefd04a729917910d5746f010
Build source
https://github.com/jiviny/Benchmark-Testing@HEAD
Show exact run metadata
4 pinned instances, 3 sandboxes, 1 reported models.
Pinned instance ids
marshmallow-code__marshmallow-1343marshmallow-code__marshmallow-1359pvlib__pvlib-python-1072pvlib__pvlib-python-1154Sandbox ids
6749ab42-6b66-419a-80ea-f4c328b0063b5834ecbb-75b1-466d-9322-68bc15d3ba2ed9e94bdb-84e4-471a-9409-9306300c33b0Run started
Mar 31, 2026, 2:06 AM UTC
Run completed
Mar 31, 2026, 2:19 AM UTC
Reported models
claude-sonnet-4-5-20250929Operational details
Build, live sandboxes, and recent events
Collapsed by default for finished runs.
Build Completed4 events
Operational details
Build, live sandboxes, and recent events
Collapsed by default for finished runs.
Agent build
Status: Completed
Source https://github.com/jiviny/Benchmark-Testing@HEAD | agentarena-build:53985d1aefd04a729917910d5746f010
Started Mar 31, 2026, 2:06 AM UTC | Completed Mar 31, 2026, 2:06 AM UTC
Show build log
Cloning into '/tmp/agentarena-build-wbc0a0x5/repo'...
Sending build context to Docker daemon 99.84kB
Step 1/5 : FROM python:3.11-slim
---> e67db9b14d09
Step 2/5 : WORKDIR /app
---> Using cache
---> 43379e3d4aa6
Step 3/5 : COPY . /app
---> Using cache
---> 6400ff98a934
Step 4/5 : RUN if [ -f requirements.txt ]; then python -m pip install --no-cache-dir -r requirements.txt; fi
---> Using cache
---> 18fe4f81c2a5
Step 5/5 : CMD ["python", "/app/agent.py"]
---> Using cache
---> 7181159b7619
Successfully built 7181159b7619
Successfully tagged agentarena-build:53985d1aefd04a729917910d5746f010
DEPRECATED: The legacy builder is deprecated and will be removed in a future release.
BuildKit is currently disabled; enable it by removing the DOCKER_BUILDKIT=0
environment-variable.Sandbox activity
Active sandboxes
Recent events
Latest run activity
pvlib__pvlib-python-1154
DaytonaError: Failed to execute command: request timeout: command execution timeout
2:19 AM
pvlib__pvlib-python-1072
Not resolved by official SWE-bench grading. Fail-to-pass: 0%. Pass-to-pass: 0%.
2:11 AM
marshmallow-code__marshmallow-1359
Not resolved by official SWE-bench grading. Fail-to-pass: 0%. Pass-to-pass: 0%.
2:09 AM
marshmallow-code__marshmallow-1343
Resolved by official SWE-bench grading. Fail-to-pass: 100%. Pass-to-pass: 100%.
2:09 AM