Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

MAINT: line ending test cannot run on Windows (check git blobs instead of the working tree?)

Aperta
#14,299 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
68/100
Tipo di issue
Refactoring
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
git, python
Ambito
testing-qa

Direzione di ricerca

Inizia da mne/tests/test_line_endings.py, in particolare da _assert_line_endings e dal relativo elenco skip_files, e verifica come il test attuale legge i byte dell’albero di lavoro. Controlla il comportamento esistente di CI e Git nel repository, quindi verifica che il test possa esaminare in modo coerente i byte sottoposti a commit su Windows e sulle altre piattaforme senza modificare deliberatamente i file CRLF. Il lavoro è completato quando lo skip di Windows non è più necessario e il controllo dei caratteri di fine riga continua a coprire i file previsti.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Problem

mne/tests/test_line_endings.py skips itself unconditionally on Windows:

def _assert_line_endings(dir_):
    """Check line endings for a directory."""
    if sys.platform == "win32":
        pytest.skip("Skipping line endings check on Windows")

The CI matrix currently runs 8 combinations, all ubuntu-* or macos-* — there is no
Windows runner — so between the two, this check never executes on Windows at all.

It has to skip, because the check reads the working-tree bytes:

with open(filename, "rb") as fid:
    text = fid.read().decode("utf-8")
...
crcount = text.count("\r")

With Git for Windows' default core.autocrlf=true, a checkout turns every text file into
CRLF, so crcount would be non-zero for the entire repository and the test would fail for
reasons that have nothing to do with what is committed.

The practical consequence is that a Windows contributor cannot run this check locally; a CRLF
file only gets caught once Linux CI sees it.

A fix that won't work (writing it down so nobody tries it)

Adding a broad .gitattributes (e.g. *.py text eol=lf for every extension in good_exts)
would make the working tree LF and let the test run — but it would also rewrite the files that
are deliberately CRLF. skip_files lists several of them:

  • test_old_layout_latin1_software_filter.vhdr / .vmrk / _longname.vhdr — the comment in
    the test says part of testing compatibility with older BrainVision formats is testing the
    line endings and coding schemes used there
  • FreeSurferColorLUT.txt, test_edf_stim_channel.txt, FieldTrip.py, license.txt,
    searchindex.dat

Forcing those to LF would change the very bytes those compatibility tests depend on. So
.gitattributes is not a safe way to make this test runnable on Windows.

Suggestion

Check the committed bytes rather than the checked-out ones, e.g. via
git ls-files --eol (the i/ field is the index/worktree-independent line ending), or by
reading blobs through git cat-file. That is unaffected by core.autocrlf, so the check
would give the same answer on every platform and the win32 skip could go away.

This is a change to how the test works rather than a bug fix, so I'd rather check the
direction first. Happy to implement it if you think it's worth doing; also completely fine if
you'd rather keep the current behaviour and leave the check to Linux CI.

Lingua principale
Python
Stelle
3.5k
Fork
1.6k
Merge medio
1g 3h
PR unite (30g)
73

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di mne-tools/mne-python

Tutte le issue di mne-tools/mne-python

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.