fix: add missing stacklevel=2 to warnings.warn() calls (Fixes #512) - #513
Open
rtmalikian wants to merge 1 commit into
Open
fix: add missing stacklevel=2 to warnings.warn() calls (Fixes #512)#513rtmalikian wants to merge 1 commit into
rtmalikian wants to merge 1 commit into
Conversation
Add stacklevel=2 to 58 warnings.warn() calls across 34 files that were missing it. Without stacklevel, warnings point to edsnlp internals instead of the user code that triggered them, making it impossible for users to identify which of their calls caused the warning. Use stacklevel=3 for deprecated_extension() in utils/deprecation.py since it is called through the deprecated_getter_factory wrapper class. Files changed: - core/pipeline.py, core/stream.py (core module warnings) - processing/multiprocessing.py, processing/deprecated_pipe.py - training/loggers.py, training/optimizer.py, training/trainer.py - pipes/ (20 files: base, sentences, contextual_matcher, dates, etc.) - data/converters.py, data/parquet.py, data/conll.py, data/json.py - utils/deprecation.py, utils/batching.py, utils/spark_dtypes.py - package.py, extensions.py, tune.py, connectors/brat.py - metrics/span_attribute.py Signed-off-by: rtmalikian <rtmalikian@gmail.com>
|
Author
|
Friendly ping — this PR has been ready for review for 8 days. Happy to address any feedback! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Fixes #512
Summary
Add
stacklevel=2to 58warnings.warn()calls across 34 files that were missing it. Withoutstacklevel, warnings point to edsnlp internals instead of the user code that triggered them.Use
stacklevel=3fordeprecated_extension()inutils/deprecation.pysince it is called through thedeprecated_getter_factorywrapper class.Problem
The default
stacklevel=1inwarnings.warn()means the warning location shows the file and line inside edsnlp rather than the caller's code. This makes it impossible for users to identify which of their API calls triggered the warning.Affected Files (34 files, 58 calls)
Core modules:
core/pipeline.py(4 calls) — deprecation warnings forbatch_size, path loadingcore/stream.py(2 calls) — stream processing warningsprocessing/multiprocessing.py(4 calls) — fork/deadlock warningsprocessing/deprecated_pipe.py(1 call) — deprecated pipe warningsTraining:
training/loggers.py(3 calls) — CSV tracker, TensorBoard, Aim warningstraining/optimizer.py(2 calls) — optimizer warningstraining/trainer.py(2 calls) — trainer warningsPipes (20 files):
pipes/base.py,pipes/core/sentences/sentences.py,pipes/core/contextual_matcher/contextual_matcher.pypipes/misc/dates/dates.py(2 calls)pipes/ner/scores/base_score.py,pipes/ner/umls/patterns.py,pipes/ner/tnm/model.pypipes/qualifiers/base.pypipes/trainable/ner_crf/ner_crf.py(4 calls),pipes/trainable/span_classifier/span_classifier.py(4 calls)pipes/llm/llm_span_qualifier/llm_span_qualifier.py,pipes/llm/llm_markup_extractor/llm_markup_extractor.pypipes/trainable/embeddings/transformer/transformer.py,pipes/trainable/embeddings/span_pooler/span_pooler.pypipes/trainable/span_linker/span_linker.pyData:
data/converters.py(2 calls),data/parquet.py(3 calls),data/conll.py,data/json.py(2 calls)Utilities 8000 :
utils/deprecation.py(stacklevel=3),utils/batching.py,utils/spark_dtypes.pypackage.py,extensions.py,tune.py,connectors/brat.py,metrics/span_attribute.pyVerification
All modified files pass
ast.parse()syntax check. Thestacklevel=2additions are syntactically correct and follow the existing indentation pattern.Changelog
Files Changed
Verification
About the Author: Raphael Malikian — Clinical AI Solutions Architect. I specialise in building and fixing AI/ML systems for healthcare, including vector databases, RAG pipelines, and clinical NLP. If you need help with your project or think I can add value to your organisation, feel free to reach out — I'd love to connect.
📧 rtmalikian@gmail.com
🔗 GitHub: https://github.com/rtmalikian
🔗 LinkedIn: http://www.linkedin.com/in/raphael-t-malikian-mbbs-bsc-hons-71075436a
Disclosure: This code was developed with assistance from Hermes Agent (Nous Research). All changes were reviewed, tested against the actual codebase, and verified for correctness.