Skip to content

fix: Resolve R1710 pylint inconsistent-return-statements errors#2101

Open
ayushozha wants to merge 1 commit intomicrosoft:mainfrom
ayushozha:fix/issue-1007-inconsistent-return-statements
Open

fix: Resolve R1710 pylint inconsistent-return-statements errors#2101
ayushozha wants to merge 1 commit intomicrosoft:mainfrom
ayushozha:fix/issue-1007-inconsistent-return-statements

Conversation

@ayushozha
Copy link
Copy Markdown

Summary

Fix all 20 instances of R1710 (inconsistent-return-statements) pylint errors across the codebase.

This is a partial fix for #1007 - focusing on a single, well-defined pylint rule that can be re-enabled after this PR.

Changes

  • Add explicit return None for functions with conditional returns
  • Change elif to else where assert guarantees the condition
  • Add raise ValueError for invalid parameter values in switch-like functions
  • Fix generator function that mixed return [] with yield

Files Modified (18 files)

  • qlib/backtest/profit_attribution.py
  • qlib/backtest/utils.py
  • qlib/contrib/data/utils/sepdf.py
  • qlib/contrib/model/pytorch_adarnn.py
  • qlib/contrib/report/analysis_model/analysis_model_performance.py
  • qlib/contrib/report/analysis_position/*.py (5 files)
  • qlib/contrib/strategy/optimizer/optimizer.py
  • qlib/data/cache.py
  • qlib/data/data.py
  • qlib/utils/index_data.py
  • qlib/workflow/exp.py
  • qlib/workflow/expm.py
  • qlib/workflow/online/update.py
  • qlib/workflow/record_temp.py

Test Plan

  • Verified pylint --enable=R1710 qlib now passes (0 errors)
  • No functional changes - only return statement consistency fixes

Next Steps

After this PR is merged, R1710 can be removed from the disabled list in the Makefile.

Partial fix for #1007

Fix all 20 instances of R1710 (inconsistent-return-statements) pylint
errors across the codebase. This enables the R1710 rule to be removed
from the disabled list in the Makefile.

Changes:
- Add explicit `return None` for functions with conditional returns
- Change `elif` to `else` where assert guarantees the condition
- Add `raise ValueError` for invalid parameter values in switch-like functions
- Fix generator function that mixed `return []` with `yield`

Files modified:
- qlib/backtest/profit_attribution.py
- qlib/backtest/utils.py
- qlib/contrib/data/utils/sepdf.py
- qlib/contrib/model/pytorch_adarnn.py
- qlib/contrib/report/analysis_model/analysis_model_performance.py
- qlib/contrib/report/analysis_position/*.py (5 files)
- qlib/contrib/strategy/optimizer/optimizer.py
- qlib/data/cache.py
- qlib/data/data.py
- qlib/utils/index_data.py
- qlib/workflow/exp.py
- qlib/workflow/expm.py
- qlib/workflow/online/update.py
- qlib/workflow/record_temp.py

Partial fix for microsoft#1007
@ayushozha
Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant