Skip to content

Add simple check for meta-indicator value type#258

Open
danielhuppmann wants to merge 8 commits into
iiasa:mainfrom
danielhuppmann:quickfix/invalid-meta-type
Open

Add simple check for meta-indicator value type#258
danielhuppmann wants to merge 8 commits into
iiasa:mainfrom
danielhuppmann:quickfix/invalid-meta-type

Conversation

@danielhuppmann

Copy link
Copy Markdown
Member

This is an alternative to #257, raising a clear error message when meta-indicator values of an unsupported type are added instead of (trying to) casting everything unexpected to string.

Closes #256

@codecov

codecov Bot commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.7%. Comparing base (9e97d27) to head (f2be6f9).

Additional details and impacted files
@@          Coverage Diff          @@
##            main    #258   +/-   ##
=====================================
  Coverage   96.7%   96.7%           
=====================================
  Files        221     221           
  Lines       9841    9853   +12     
=====================================
+ Hits        9520    9532   +12     
  Misses       321     321           
Files with missing lines Coverage Δ
ixmp4/core/meta.py 98.6% <100.0%> (+<0.1%) ⬆️
ixmp4/data/meta/type.py 100.0% <100.0%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@danielhuppmann

Copy link
Copy Markdown
Member Author

I give up, I don't know which ruff version to use to make the linter pass...

@meksor

meksor commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

The version should not matter or the version in the poetry.lock file should work.
At the bottom of the CI job it says:

Would reformat: tests/core/test_meta.py
1 file would be reformatted, 319 files already formatted

Did you try: ruff format tests/core/test_meta.py ?

Edit: My IDE also sorts imports for me which you may be able to achieve using :
ruff check --select I --fix

@danielhuppmann

Copy link
Copy Markdown
Member Author

Did you try: ruff format tests/core/test_meta.py ?

Of course, and I tried it with both 0.15.12 (per poetry.lock) and 0.15.20 (latest) - locally, all my files are fine...

@meksor

meksor commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

My IDE also sorts imports for me which you may be able to achieve using :
ruff check --select I --fix

@danielhuppmann

Copy link
Copy Markdown
Member Author
image

@meksor

meksor commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

I cleared the cached virtualenv using the github cli and restarted the Code Quality job.
Sometimes this cache bugs out and generates lots of errors like before, not sure why.
Anyway, now we can also see two mypy errors

tests/core/test_meta.py:55: error: Dict entry 1 has incompatible type "str": "Timestamp"; expected "str": "float | int | str | generic[Any] | None"  [dict-item]
tests/core/test_meta.py:59: error: Incompatible types in assignment (expression has type "Timestamp", target has type "bool | float | int | str | generic[Any] | None")  [assignment]

@meksor

meksor commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Wow, thats annoying...
I am not sure how exactly this pre-commit thing works since fridolin set it up, but if it really is a version mismatch (pre-commit is a few versions behind) then you can try changing .pre-commit-config.yaml line 9 to rev: v0.15.12. Maybe I was too confident in ruff backwards compatibility.

@meksor

meksor commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

#259

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.

Improve error message when trying to add non-supported data type as meta data entry

2 participants