profile() and compare() raise AttributeError and KeyError when given the wrong kind of object
Maintainers usually reply within 1 day
A pull request for this has already been merged.
- #1124 by @dxnnystyles — merged
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 86/100
Research direction
Read faircode/profiler.py and faircode/compare.py, then inspect tests/test_profiler.py and tests/test_compare.py. Add checks at the start of each function for the expected input types and verify the errors name both expected and received types. Done when both reported mistakes raise TypeError, tests cover them, and valid calls remain unchanged.
Written by the indexing model from the issue text.
Description
Where: faircode/profiler.py (profile), faircode/compare.py (compare), tests/test_profiler.py, tests/test_compare.py.
Current gap: the library functions assume their inputs. profile("data.csv") (a path instead of a DataFrame) fails with AttributeError: 'str' object has no attribute 'columns', and compare(profile(df), {}) or passing a DataFrame instead of a profile result fails with KeyError: 'dimensions'. Both are easy mistakes for someone using the Python API from the README or the MCP tools, and the traceback points into the library.
Repro:
$ python3 -c "from faircode import profile; profile('data.csv')"
AttributeError: 'str' object has no attribute 'columns'
$ python3 -c "import pandas as pd; from faircode import profile, compare; compare(profile(pd.DataFrame({'sex': ['m', 'f'] * 50})), {})"
KeyError: 'dimensions'
Suggested approach: validate at the top of each function and raise TypeError with a sentence that says what was expected (a pandas DataFrame, optionally read with faircode.loaders.read_table; a result dict returned by profile()), and that names the type received.
Done when: both mistakes give a TypeError naming the expected and received types, with tests, and valid calls are unchanged.
- Dominant language
- HTML
- Stars
- 47
- Forks
- 45
- Avg merge
- 3h 2m
- Merged PRs (30d)
- 85
Getting set up
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from yakew7/Fair-Code
-
enhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Maintainers usually reply within 1 day
-
enhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
enhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
enhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
All issues in yakew7/Fair-Code
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 5 days
-
area-multitenancy area-security p1-recommended priority-high technical-debt
Difficulty 2/5 Under an hour Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
[Bug]: REST API URL starting with "http" but no scheme (e.g. httpbin.org/get) is not given an http:// prefixPossibly taken @ItsDeadlyProgrammer claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
appsmithorg/appsmith#42471 · 1 comment ·
Maintainers usually reply within 2 days
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
fossasia/visdom-dev#77 ·
Maintainers usually reply within 4 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 63/100
FriendsofECCE/ECCE#519 ·