MNT remove obsolete Python 2 syntax, add some types - #664
Closed
kroq-gar78 wants to merge 2 commits into
Closed
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR modernizes the codebase by removing legacy Python 2/early-Python-3 compatibility patterns, making it easier to adopt newer Python features (e.g., clearer type annotations and super() usage).
Changes:
- Replace Python 2-era class declarations (
class X(object)) with Python 3 syntax (class X), and modernizesuper(...)calls tosuper(). - Convert
dict((k, v) for ...)patterns to dict comprehensions and update string formatting to f-strings. - Remove
builtins/__future__compatibility imports and a Python 2-onlysetdefaultencodingblock.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| cortex/xfm.py | Update class declaration to Python 3 style. |
| cortex/utils.py | Convert dict construction to comprehension (but leaves one Python 3-incompatible expression nearby). |
| cortex/svgoverlay.py | Remove builtins compatibility import and modernize class declarations. |
| cortex/segment.py | Remove Python 2 builtins.input compatibility import. |
| cortex/rois.py | Update class declaration and dict-building syntax. |
| cortex/quickflat/utils.py | Use f-strings and dict comprehensions for cleaner modern Python. |
| cortex/quickflat/composite.py | Use f-strings for exceptions/logging. |
| cortex/mayavi_aligner.py | Use super() and dict comprehensions; modernize legacy patterns. |
| cortex/mapper/mapper.py | Update class declaration to Python 3 style. |
| cortex/mapper/init.py | Use f-string for cache filename construction. |
| cortex/freesurfer.py | Remove __future__/builtins Python 2 compatibility imports; modernize class declaration. |
| cortex/dataset/views.py | Update class declarations, dict comprehension usage, and modern super() calls; refine typing. |
| cortex/dataset/viewRGB.py | Modernize super() calls. |
| cortex/dataset/view2D.py | Modernize super() calls. |
| cortex/dataset/dataset.py | Update class declaration to Python 3 style. |
| cortex/dataset/braindata.py | Modernize super() usage and simplify Python 2 string-type compatibility logic for xfmname. |
| cortex/database.py | Remove Python 2 builtins.input compatibility import; update class declarations and dict-building syntax. |
| cortex/brainctm.py | Update class declarations and modernize super() usage. |
| cortex/appdirs.py | Update class declaration to Python 3 style. |
| cortex/align.py | Remove Python 2 builtins.input compatibility import. |
| cortex/init.py | Update deprecated helper class syntax and remove Python 2-only encoding workaround. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This happens whenever fail_for_missing_rois=False and a requested ROI isn't in overlays.svg.
kroq-gar78
marked this pull request as ready for review
August 13, 2026 00:37
kroq-gar78
marked this pull request as draft
August 13, 2026 08:19
Contributor
Author
|
Superseded by #666 . |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This will make it easier to use newer Python features (e.g. type annotations).