Skip to content

Improve utility function coverage with type hints and comprehensive tests#81

Merged
tdixon97 merged 9 commits intomainfrom
copilot/improve-utility-functions-coverage
Feb 4, 2026
Merged

Improve utility function coverage with type hints and comprehensive tests#81
tdixon97 merged 9 commits intomainfrom
copilot/improve-utility-functions-coverage

Conversation

Copy link
Contributor

Copilot AI commented Feb 2, 2026

Summary: Improve Coverage of Utility Functions ✅

Type Hints and Docstrings ✅

  • Analyze existing utility functions in utils.py and metadata.py
  • Add missing return type hint to _merge_defaults
  • Add missing type hints to setup_logdir_link (parameters and return type)
  • Add comprehensive docstring to _merge_defaults
  • Add type hints to get_vtx_simconfig in metadata.py

Test Coverage Improvements ✅

utils.py coverage: 52% → 90% (+38%)

  • Add tests for _merge_defaults function (dict merging logic)
  • Add tests for setup_logdir_link function (symlink creation)
  • Add tests for hash_dict function (JSON serialization)
  • Add improved tests for get_hit_tier_name with proper fixtures
  • Add tests for lookup_dataflow_config with fixtures for both config formats
  • Add tests for init_generated_pars_db function with par directories for both config formats
  • Add tests for extract_integer in metadata module

Improved Tests with Fixtures ✅

  • Created tier_test_data fixture with setups.l200 structure matching production config
  • Created tier_test_data_direct fixture with direct paths structure for legacy support
  • Used dbetto.utils.write_dict for cleaner config file creation
  • Added par directories (par, par_hit, par_pht) to both fixtures
  • Test get_hit_tier_name for both config formats
  • Test lookup_dataflow_config for both config formats with proper variable substitution
  • Test init_generated_pars_db for both config formats (full par database and tier-specific databases)

Code Quality Validation ✅

  • All 16 tests pass successfully in test_utils.py (added 3 new tests for direct format)
  • Pre-commit linting checks pass (ruff, trailing whitespace)
  • No breaking changes introduced
  • Both config formats tested: setups.l200.paths and direct paths

Key Improvements

Module Before After Change
utils.py 52% 90% +38%
metadata.py 71% 72% +1%
Original prompt

I would like to improve the coverage of simple utilty functions in this repository. In doing this I would also like to check if all functions have the proper type hints and docstrings.
Please give me suggestions on tests to add, and make a PR with your proposals


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Add tests for utility functions and check type hints and docstrings Improve utility function coverage with type hints and comprehensive tests Feb 2, 2026
Copilot AI requested a review from tdixon97 February 2, 2026 19:31
@tdixon97 tdixon97 requested a review from gipert February 2, 2026 19:32
@tdixon97
Copy link
Collaborator

tdixon97 commented Feb 2, 2026 via email

@gipert
Copy link
Member

gipert commented Feb 3, 2026

looks good except for this useless markdown file

@codecov
Copy link

codecov bot commented Feb 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 63.33%. Comparing base (4779a44) to head (0096e4c).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #81      +/-   ##
==========================================
+ Coverage   61.98%   63.33%   +1.35%     
==========================================
  Files          19       19              
  Lines        1331     1331              
==========================================
+ Hits          825      843      +18     
+ Misses        506      488      -18     

☔ 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.

@tdixon97
Copy link
Collaborator

tdixon97 commented Feb 4, 2026

@copilot you should see that the config can be instead

setups:
      l200:
           paths:
               ...

In addition you should see that some other keys like

paths:
    par_hit: $_/generated/par/hit
    par_pht: $_/generated/par/pht

can be present, add them and use it to test init_generated_pars_db

Copy link
Contributor Author

Copilot AI commented Feb 4, 2026

@copilot you should see that the config can be instead

...

Updated in e55c430. The fixture now uses the setups.l200.paths structure and includes par, par_hit, and par_pht paths with corresponding directories. Added comprehensive test for init_generated_pars_db that validates:

  • Full par database (tier=None)
  • Hit tier par database (tier="hit")
  • Pht tier par database (tier="pht")

@tdixon97
Copy link
Collaborator

tdixon97 commented Feb 4, 2026

@copilot you should see that the config can be instead

...

Updated in e55c430. The fixture now uses the setups.l200.paths structure and includes par, par_hit, and par_pht paths with corresponding directories. Added comprehensive test for init_generated_pars_db that validates:

* Full par database (tier=None)

* Hit tier par database (tier="hit")

* Pht tier par database (tier="pht")

@copilot please test both formats

Copy link
Contributor Author

Copilot AI commented Feb 4, 2026

@copilot you should see that the config can be instead

...
...

Added in 38d95d5. Created tier_test_data_direct fixture for the direct paths format and added 3 new tests:

  • test_lookup_dataflow_config_direct_format
  • test_get_hit_tier_name_direct_format
  • test_init_generated_pars_db_direct_format

Both config formats are now fully tested (16 tests total).

Copilot AI and others added 9 commits February 4, 2026 23:00
…ions

Co-authored-by: tdixon97 <56904179+tdixon97@users.noreply.github.com>
Co-authored-by: tdixon97 <56904179+tdixon97@users.noreply.github.com>
Co-authored-by: tdixon97 <56904179+tdixon97@users.noreply.github.com>
Co-authored-by: tdixon97 <56904179+tdixon97@users.noreply.github.com>
Co-authored-by: tdixon97 <56904179+tdixon97@users.noreply.github.com>
Co-authored-by: tdixon97 <56904179+tdixon97@users.noreply.github.com>
…d_pars_db test

Co-authored-by: tdixon97 <56904179+tdixon97@users.noreply.github.com>
Co-authored-by: tdixon97 <56904179+tdixon97@users.noreply.github.com>
Co-authored-by: tdixon97 <56904179+tdixon97@users.noreply.github.com>
@tdixon97 tdixon97 force-pushed the copilot/improve-utility-functions-coverage branch from 38d95d5 to 0096e4c Compare February 4, 2026 23:00
@tdixon97 tdixon97 marked this pull request as ready for review February 4, 2026 23:01
Copilot AI review requested due to automatic review settings February 4, 2026 23:01
@tdixon97 tdixon97 dismissed their stale review February 4, 2026 23:01

Now addressed

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 enhances utility function coverage by adding type hints, comprehensive docstrings, and extensive tests for several utility functions in the legendsimflow package. The changes improve code maintainability and increase test coverage from 52% to 90% for utils.py and from 71% to 72% for metadata.py.

Changes:

  • Added type hints and comprehensive docstrings to _merge_defaults, setup_logdir_link, and get_vtx_simconfig functions
  • Added 13 new tests covering dictionary merging, symlink creation, hash generation, tier name detection, parameter database initialization, and integer extraction
  • Created two test fixtures (tier_test_data and tier_test_data_direct) to support testing both config formats (with and without setups.l200 wrapper)

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
workflow/src/legendsimflow/utils.py Added type hints and docstring to _merge_defaults; added type hints and expanded docstring for setup_logdir_link
workflow/src/legendsimflow/metadata.py Added type hints to get_vtx_simconfig function
tests/test_utils.py Added 13 new test functions and 2 fixtures covering utility functions for both config formats
tests/test_metadata.py Added test for extract_integer function with multiple test cases

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

@tdixon97 tdixon97 merged commit 8c25713 into main Feb 4, 2026
14 checks passed
@tdixon97 tdixon97 deleted the copilot/improve-utility-functions-coverage branch February 4, 2026 23:04
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.

3 participants