MNT: Address warnings produced by pybids and dependencies#1136
MNT: Address warnings produced by pybids and dependencies#1136effigies merged 12 commits intobids-standard:masterfrom
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1136 +/- ##
==========================================
- Coverage 89.77% 89.41% -0.36%
==========================================
Files 65 65
Lines 7205 7237 +32
Branches 1137 1142 +5
==========================================
+ Hits 6468 6471 +3
- Misses 536 557 +21
- Partials 201 209 +8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
622ce7e to
3a5cd05
Compare
effigies
left a comment
There was a problem hiding this comment.
A few notes. @adelavega Do you have some time to review?
The only remaining warnings are ResourceWarnings from unclosed database connections. I tried a few things to reduce those, but couldn't eliminate them, so I'm not addressing them in this PR.
| """ | ||
|
|
||
| def __init__(self, root=None, validate=True, absolute_paths=True, | ||
| def __init__(self, root=None, validate=True, absolute_paths=RemovedOption, |
There was a problem hiding this comment.
Significant change: Removing absolute_paths from BIDSLayout.__init__ and BIDSLayout.get, deprecated in 0.14.
| if indexer_kwargs: | ||
| args = ', '.join(f'{key}={val}' for key, val in indexer_kwargs.items()) | ||
| msg = ( | ||
| "Passing kwargs to the BIDSLayoutIndexer is no longer supported. " | ||
| f"Pass `indexer=BIDSLayoutIndexer({args})` instead." | ||
| ) | ||
| raise TypeError(msg) |
There was a problem hiding this comment.
Significant change: No longer passing BIDSLayout kwargs to BIDSLayoutIndexer, deprecated in 0.14.
|
|
||
| root = Column(String, primary_key=True) | ||
| absolute_paths = Column(Boolean) | ||
| absolute_paths = Column(Boolean, default=True) # Removed, but may be in older DBs |
There was a problem hiding this comment.
Seemed best to keep this column and just enforce its value.
| def __getattr__(self, attr): | ||
| # Ensures backwards compatibility with old File_ namedtuple, which is | ||
| # deprecated as of 0.7. | ||
| # _ check first to not mask away access to __setstate__ etc. | ||
| # AFAIK None of the entities are allowed to start with _ anyways | ||
| # so the check is more generic than __ | ||
| if not attr.startswith('_') and attr in self.entities: | ||
| warnings.warn("Accessing entities as attributes is deprecated as " | ||
| "of 0.7. Please use the .entities dictionary instead" | ||
| " (i.e., .entities['%s'] instead of .%s." | ||
| % (attr, attr)) | ||
| return self.entities[attr] | ||
| raise AttributeError("%s object has no attribute named %r" % | ||
| (self.__class__.__name__, attr)) |
There was a problem hiding this comment.
Could have promoted the warning to an error, but it's warning been around so long it doesn't seem worth it.
| except ImportError: | ||
| pytest.skip("Needs bsmschema, available for Python 3.8+") | ||
| BIDSStatsModel.parse_obj(model) | ||
| BIDSStatsModel.model_validate(model) |
There was a problem hiding this comment.
Pydantic 2 update.
|
These changes look reasonable to me! I think we've given ample warning (pun intended) |
Version 0.20.0 (September 24, 2025) New feature release in the 0.20.x series. This release finalizes some deprecations that were started in the 0.7 and 0.14 series. In particular, passing indexer arguments to ``BIDSLayout`` and disabling ``absolute_paths`` mode in ``BIDSLayout()`` or ``BIDSLayout.get()`` will now error. To adjust indexing behavior, create an explicit ``BIDSLayoutIndexer()`` and pass ``BIDSLayout(..., indexer=indexer)``. To access relative paths, use the ``BIDSFile.relative_path`` property on ``BIDSLayout.get()`` return values. * FIX: Check for attribute that can be absent before assigning (#1165) * FIX: Accommodate deprecations in the upcoming Pandas 3 release (#1173) * FIX: Repaired convolution issue that arises when onset values are repeated (#1133) * ENH: StatsModels: Add `invalid_inputs` parameter to allow dropping of missing data columns to run nodes (#1145) * ENH: Add missing root-level path patterns (#1169) * ENH: Parse ``seg-`` entities from dseg or probseg files (#1172) * DOC: Update link to derivatives config file (#1132) * MNT: Address warnings produced by pybids and dependencies (#1136) * MNT: Lock test environment, update with dependabot (#1134)
Given that we're now testing on nightly builds of scientific Python dependencies, seems like a good time to address warnings.
This addresses warnings both in dependencies and generated by pybids itself. We have behavior that was supposedly deprecated in versions 0.7 and 0.14, but was still around. I've mostly kept helpful messages, but turned them into
TypeErrors, which is what they'll be when fully removed.