Skip to content

warnings.simplefilter("default", DeprecationWarning) at module level in misc.py silently overrides global warning filters for all downstream users #11

@leavetostay

Description

@leavetostay

In masoniteorm/helpers/misc.py, the deprecated decorator calls warnings.simplefilter("default", DeprecationWarning) at module level (line 7). Because simplefilter inserts at the front of the filter list, this
unconditionally enables ALL DeprecationWarning for the entire Python process as soon as any code transitively imports masoniteorm.helpers.misc.

Python’s default behavior is to ignore DeprecationWarning from non-main modules. This line overrides that default globally, so every downstream project that depends on masonite-orm suddenly sees DeprecationWarning
from every library in its stack — Django, asyncio, sqlalchemy, you name it — regardless of the project’s own warning configuration.

masoniteorm/helpers/misc.py (current)

def deprecated(message):
warnings.simplefilter("default", DeprecationWarning) # ← module-level side effect
...


Steps to Reproduce

  1. Install masonite-orm (pip install masonite-orm==3.0.0.post1)
  2. In any Python project that imports masonite-orm, run:

import warnings

Simulate a DeprecationWarning from an unrelated library

warnings.warn("This should be hidden by default", DeprecationWarning)

  1. Observe that the warning is displayed, even though Python’s default filter says DeprecationWarning should be ignored everywhere except main.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions