Skip to content

Conversation

@juanitorduz
Copy link
Collaborator

@juanitorduz juanitorduz commented Nov 12, 2025

Add type hints to all code base following on #556


📚 Documentation preview 📚: https://causalpy--557.org.readthedocs.build/en/557/

@juanitorduz juanitorduz marked this pull request as draft November 12, 2025 10:41
@juanitorduz juanitorduz self-assigned this Nov 12, 2025
@juanitorduz juanitorduz changed the base branch from main to mypy November 12, 2025 10:42
@juanitorduz juanitorduz requested a review from Copilot November 12, 2025 10:42
@juanitorduz juanitorduz marked this pull request as ready for review November 12, 2025 10:43
@juanitorduz juanitorduz mentioned this pull request Nov 12, 2025
@codecov
Copy link

codecov bot commented Nov 12, 2025

Codecov Report

❌ Patch coverage is 95.41284% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.52%. Comparing base (f918e84) to head (6034cb3).

Files with missing lines Patch % Lines
causalpy/pymc_models.py 87.50% 3 Missing ⚠️
causalpy/data/simulate_data.py 80.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             mypy     #557      +/-   ##
==========================================
- Coverage   95.54%   95.52%   -0.03%     
==========================================
  Files          29       29              
  Lines        2695     2705      +10     
==========================================
+ Hits         2575     2584       +9     
- Misses        120      121       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot finished reviewing on behalf of juanitorduz November 12, 2025 10:48
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request adds comprehensive type hints to the entire CausalPy codebase, following up on PR #556. The changes improve code maintainability and enable better static type checking.

Key Changes:

  • Added type annotations to function parameters and return types across all modules
  • Updated type hint syntax to use modern Python union syntax (X | None instead of Optional[X])
  • Added type hints to experiment classes, model classes, and utility functions

Reviewed Changes

Copilot reviewed 14 out of 15 changed files in this pull request and generated 27 comments.

Show a summary per file
File Description
docs/source/_static/interrogate_badge.svg Updated documentation coverage badge from 95.8% to 95.1%
causalpy/utils.py Added type hints to utility functions including round_num, _format_sig_figs, and convert_to_string
causalpy/skl_models.py Added type hints to scikit-learn model adaptor classes and methods
causalpy/pymc_models.py Added comprehensive type hints to PyMC model classes including LinearRegression, InstrumentalVariableRegression, and PropensityScore
causalpy/plot_utils.py Updated type hints in plotting utility functions using modern union syntax
causalpy/experiments/synthetic_control.py Added type hints to synthetic control experiment class methods
causalpy/experiments/regression_kink.py Added type hints to regression kink experiment class methods
causalpy/experiments/regression_discontinuity.py Added type hints to regression discontinuity experiment class methods
causalpy/experiments/prepostnegd.py Added type hints to pre-post NEGD experiment class methods
causalpy/experiments/inverse_propensity_weighting.py Added type hints to inverse propensity weighting experiment class methods
causalpy/experiments/interrupted_time_series.py Added type hints to interrupted time series experiment class methods
causalpy/experiments/instrumental_variable.py Added type hints to instrumental variable experiment class methods
causalpy/experiments/diff_in_diff.py Added type hints to difference-in-differences experiment class methods
causalpy/experiments/base.py Added type hints to base experiment class including abstract methods
causalpy/data/simulate_data.py Added comprehensive type hints to all data simulation functions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@juanitorduz juanitorduz added enhancement New feature or request devops DevOps related major refactor Refactor, clean up, or improvement with no visible changes to the user labels Nov 12, 2025
Copy link
Collaborator

@drbenvincent drbenvincent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving. Assuming this is auto run remotely as part of the pre-commit checks? As in, we don't need to add to the GitHub actions?

@juanitorduz
Copy link
Collaborator Author

Exactly, I will rebase and merge

@juanitorduz juanitorduz merged commit 225a498 into mypy Nov 12, 2025
2 of 3 checks passed
@juanitorduz juanitorduz deleted the add-more-type-hints branch November 12, 2025 11:32
juanitorduz added a commit that referenced this pull request Nov 12, 2025
* init

* gemini

* rm unwanted change

* do not use assert and raise instead

* add info to AGENTG.md

* fix mypy

* Add type hints to all code base (#557)

* init

* rm file

* update badge

* Update causalpy/experiments/regression_kink.py

Co-authored-by: Copilot <[email protected]>

* update docstrings

* fix: apply ruff formatting after rebase

---------

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

devops DevOps related enhancement New feature or request major refactor Refactor, clean up, or improvement with no visible changes to the user

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants