{
  "id": "python-warnings-table",
  "kind": "table",
  "slug": "python-warnings",
  "iil_id": null,
  "note_url": "https://iinventedlight.com/library/notes/python-warnings/",
  "title": "Python warnings - issue DeprecationWarning, filter warnings, and turn them into errors in tests",
  "columns": [
    "name",
    "source",
    "detail"
  ],
  "rows": [
    {
      "name": "\"error\"",
      "source": "Python docs",
      "detail": "turned into exceptions"
    },
    {
      "name": "\"ignore\"",
      "source": "Python docs",
      "detail": "are never printed"
    },
    {
      "name": "\"always\"",
      "source": "Python docs",
      "detail": "are always printed"
    },
    {
      "name": "\"default\"",
      "source": "Python docs",
      "detail": "print the first occurrence for each location"
    },
    {
      "name": "\"module\"",
      "source": "Python docs",
      "detail": "print the first occurrence for each module"
    },
    {
      "name": "\"once\"",
      "source": "Python docs",
      "detail": "print only the first occurrence, regardless of location"
    },
    {
      "name": "category",
      "source": "Python docs",
      "detail": "defaults to UserWarning."
    },
    {
      "name": "stacklevel=2",
      "source": "Python docs",
      "detail": "makes the warning refer to the caller of your wrapper function rather than the wrapper itself."
    },
    {
      "name": "warnings.deprecated",
      "source": "Python docs",
      "detail": "is a decorator (3.13+) that marks a class or function as deprecated for runtime warnings and static type checkers."
    }
  ],
  "related_slugs": [
    "python-unittest",
    "python-exceptions-hierarchy"
  ],
  "license": "CC-BY-4.0",
  "source_license": "PSF-2.0 (Python docs); PSF-2.0 (python/cpython (GitHub)); prose restates cited source lines in own words",
  "as_of": "2026-11-18",
  "status": "fill-draft-20261118",
  "note": "Restated from the note's GREEN sources; check those sources before relying on a value."
}