Skip to content

Replace deprecated logger.warn() with logger.warning()#5512

Open
Mr-Neutr0n wants to merge 1 commit into
facebookresearch:mainfrom
Mr-Neutr0n:fix/replace-deprecated-logger-warn
Open

Replace deprecated logger.warn() with logger.warning()#5512
Mr-Neutr0n wants to merge 1 commit into
facebookresearch:mainfrom
Mr-Neutr0n:fix/replace-deprecated-logger-warn

Conversation

@Mr-Neutr0n
Copy link
Copy Markdown

Summary

  • Replace all 11 occurrences of the deprecated logging.Logger.warn() method with logging.Logger.warning() across 5 files in the detectron2 package.
  • Logger.warn() has been deprecated since Python 3.2 and is pending removal. It currently emits DeprecationWarning in recent Python versions.
  • warnings.warn() calls (from the warnings module) are intentionally left unchanged, as they are not deprecated.

Files changed

File Occurrences fixed
detectron2/evaluation/sem_seg_evaluation.py 4
detectron2/evaluation/coco_evaluation.py 2
detectron2/evaluation/lvis_evaluation.py 2
detectron2/data/datasets/coco.py 2
detectron2/engine/defaults.py 1

Test plan

  • Verified no remaining logger.warn() calls in the codebase
  • Confirmed warnings.warn() (stdlib) calls are unaffected
  • All existing tests should pass as warning() is the standard method with identical behavior

logging.Logger.warn() has been deprecated since Python 3.2 in favor
of logging.Logger.warning(). This commit replaces all 11 occurrences
of logger.warn() across 5 files in the detectron2 package:

- detectron2/evaluation/coco_evaluation.py
- detectron2/evaluation/sem_seg_evaluation.py
- detectron2/evaluation/lvis_evaluation.py
- detectron2/data/datasets/coco.py
- detectron2/engine/defaults.py

Note: warnings.warn() calls (from the warnings module) are left
unchanged as they are not deprecated.
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant