Deprecate passing file paths instead of URLs to `mimetypes.guess_type()`
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 77.2k
- Fork
- 35.9k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
Feature or enhancement
Proposal:
In Python 3.13, mimetypes.guess_file_type() was introduced as the preferred alternative to guess_type() for file paths. The documentation was updated with a .. soft-deprecated:: 3.13 note at the time.
However, the # TODO: Deprecate accepting file paths (in particular path-like objects) comment in Lib/mimetypes.py was never fulfilled, and no actual DeprecationWarning is currently emitted at runtime when paths are passed in.
This proposal is to fulfill the existing # TODO and emit a DeprecationWarning for passing plain strings (with no valid URL scheme), bytes, and os.PathLike objects into mimetypes.guess_type().
This completes the soft-deprecation cycle initiated in Python 3.13.
Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
This fulfills the existing # TODO added during the introduction of guess_file_type() in Python 3.13:
https://github.com/python/cpython/blob/main/Lib/mimetypes.py#L131
Linked PRs
- gh-151576
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia in Lib/mimetypes.py, nel TODO esistente, e ispeziona guess_type() insieme a guess_file_type(). Verifica il comportamento di avviso previsto per le semplici stringhe di percorso, bytes e gli input os.PathLike, preservando la gestione degli URL; il lavoro è completo quando l’avviso di deprecazione è coperto e il comportamento esistente rimane corretto.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- backend-api-design
- Tipo di issue
- Funzionalità
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 20/100