Skip to content

MAINT: Modernize path handling in misc.py using pathlib#13775

Open
Akhila21-6 wants to merge 21 commits intomne-tools:mainfrom
Akhila21-6:main
Open

MAINT: Modernize path handling in misc.py using pathlib#13775
Akhila21-6 wants to merge 21 commits intomne-tools:mainfrom
Akhila21-6:main

Conversation

@Akhila21-6
Copy link
Copy Markdown

@Akhila21-6 Akhila21-6 commented Mar 22, 2026

Reference issue (if any)
This PR modernizes path handling in mne/misc.py using pathlib. (Note: A previous reference to #1268 was removed as it pertained to the mne-bids repository; however, this migration remains a beneficial standalone improvement for mne-python.)

What does this implement/fix?
This PR modernizes the file handling logic in mne/viz/misc.py by transitioning from traditional open() and os.path methods to the pathlib module.

Key Changes:

Modified parse_config and read_reject_parameters to use pathlib.Path.

Optimized file reading using Path.read_text().splitlines(), making the code more concise and Pythonic.

Ensured compatibility by wrapping fname in Path() to handle both string and path-like inputs.

Removed unused import os to keep the module clean.

Additional information
I am a GSoC 2026 applicant. I have verified these changes by running the following test suite locally on a Windows environment:
python -m pytest mne/viz/tests/test_misc.py

The tests resulted in 5 passed, 5 skipped (skips were due to missing large external datasets, but all relevant code logic tests passed). I successfully resolved local PATH and ModuleNotFoundError issues to ensure the environment was correctly configured for testing.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants