Skip to content

Commit 3a0ab30

Browse files
committed
mypy complete, added several future refactoring notes
1 parent 4fdc68f commit 3a0ab30

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1103
-955
lines changed

TODO.md

Lines changed: 75 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,74 @@
11
# Project TODO and Notes
22

3-
## TODO
3+
## Refactoring TODOs
44

5-
- [ ] Complete coverage
5+
- Typing
66

7-
- [ ] Get rid of deprecation warnings from test coverage
7+
- Try to get rid of `Optional[Dict[str, Any]]` args
88

9-
- [ ] Finish method naming and typing documentation.
9+
- base.py: reorganize and see what we can move out.
1010

11-
- [ ] Confront MyPy. See https://stackoverflow.com/a/51294709 for json help
11+
- Rename to `_base`? Files it first, makes it clearer that everything in it is
12+
private
13+
- Move the methods for building `curl` commands into a mixin? It's a lot of
14+
code for an isolated and tightly scoped feature.
15+
- refactor `_make_request`.
16+
- do we need both `data` and `json`? Also, could we simplify a lot of typing
17+
if we separated GET, POST, and DELETE methods? Maybe even a separate,
18+
second non-auth GET? Could use `@overload`
19+
- we had to makee a `ParamDict` type in `nutrition.py`. Use this everywhere?
20+
- start by looking at how many methods use which params
1221

13-
- [ ] When typing resource, wrap the actual response type around the JSONType,,
14-
e.g. List[JSONType], Dict[str, JSONType], so that the user can actually know
15-
what to expect (or None, of course)
22+
- client.py:
1623

17-
- [ ] Test that all methods have an alias in `Client` and that the signatures
18-
match
24+
- Creat and Test that all methods have an alias in `Client` and that the
25+
signatures match
26+
- Make sure that `ClientValidationException` is getting used for arbitrary
27+
validations like:
1928

20-
- [ ] Rationalize `ClientValidationException` subclass inheritance
29+
```python
30+
if not food_id and not (food_name and calories):
31+
raise ClientValidationException(
32+
"Must provide either food_id or (food_name and calories)"
33+
)
34+
```
35+
36+
- exceptions.py
37+
38+
- Should ClientValidationException really subclass FitbitAPIException? It
39+
doesn't need the API lookup mapping (`exception_type`) or a `status_code`,
40+
so we may just be able to simplify it. The most important thing is that the
41+
user understands that the message came from the client prior to the API
42+
call.
43+
44+
- Resource docstrings/documentation:
45+
46+
- Update the list of exceptions that are raised in the doctring for
47+
`base._make_request`
48+
- Review all documentation and between **API docs, return types, and
49+
exceptions**, update the doctrings
50+
- Update "Returns" in all resource docstrings
51+
- Review and add link to
52+
https://dev.fitbit.com/build/reference/web-api/developer-guide/best-practices/
53+
in README--they still apply!
2154

22-
- [ ] Set up CI!
55+
- Set up CI!
2356

24-
- [ ] Consider a "replace_food_log" helper that does a delete + an add in one.
25-
(there might be several of these that make sense--just take an ID and then the
26-
signature of the "create" method)
57+
## Longer term TODOs
58+
59+
- Performance profiling
2760

2861
- Docs! https://www.sphinx-doc.org/en/master/#get-started (put on github pages?)
2962

30-
- [ ] Why does this log twice:
63+
- Why does this log twice:
3164

3265
```log
3366
[2025-02-07 16:41:38,471] ERROR [fitbit_client.NutritionResource] ValidationException: Intensity level "MEDIUM" available only if weight objective is to lose weight. [Type: validation, Status: 400], Field: intensity
3467
[2025-02-07 16:41:38,472] ERROR [fitbit_client.NutritionResource] ValidationException in create_food_goal for foods/log/goal.json: Intensity level "MEDIUM" available only if weight objective is to lose weight.
3568
3669
```
3770

38-
- [ ] For methods with paging, figure out how to encapsulate it...do they call
71+
- For methods with paging, figure out how to encapsulate it...do they call
3972
`_make_request` with the URL in the response, or what? Does the response
4073
return a 2-tuple where the first item is the response and second is a
4174
pre-baked function that can me called? See:
@@ -48,49 +81,43 @@
4881
be reused.
4982
- We may need a public version of a generic `make_request` method.
5083

51-
- [ ] For all `create_...`methods, add the ID from the response to logs and
52-
maybe something human readable, like the first n characters of the name??.
53-
Right now:
84+
- For all `create_...`methods, add the ID from the response to logs and maybe
85+
something human readable, like the first n characters of the name??. Right
86+
now:
5487

5588
```log
5689
[2025-02-05 06:09:34,828] INFO [fitbit_client.NutritionResource] create_food_log succeeded for foods/log.json (status 201)
5790
```
5891

59-
- [ ] Review and add link to
60-
https://dev.fitbit.com/build/reference/web-api/developer-guide/best-practices/
61-
in README--they still apply!
62-
63-
- [ ] Form to change scopes are part of OAuth flow? Maybe get rid of the cut and
92+
- Form to change scopes are part of OAuth flow? Maybe get rid of the cut and
6493
paste method altogether? It's less to test...
6594

66-
- [ ] Make the food download_food_logs (rename to `get_food_logs`) and food log
67-
to CSV part of one helper package. It should expand the foods to have their
68-
complete nutrition (a separate call for each unique food) (put this in a
69-
`tools` package??)
95+
- Extension ideas:
7096

71-
- [ ] PyPI deployment
97+
- Make the food download_food_logs method (rename to `get_food_logs`) and food
98+
log to CSV part of one helper package. It should expand the foods to have
99+
their complete nutrition (a separate call for each unique food) (put this in
100+
a `tools` package??)
101+
- PRIVATE filters on methods that return PUBLIC and PRIVATE stuff (API doesn't
102+
seem to have this). Would require a sidecar database or pickle - it just
103+
needs to be a hash with a few elements to facilitate a lookup via the api
104+
- Consider e.g., a "replace_food_log" extension that does a delete + an add in
105+
one. (there might be several of these that make sense--just take an ID and
106+
then the signature of the "create" method).
72107

73-
- [ ] Extension: PRIVATE filters on methods that return PUBLIC and PRIVATE stuff
74-
(API doesn't seem to have this). Maybe a sidecar database?
108+
- PyPI deployment
75109

76-
- [ ] Enum for units? (it'll be big, maybe just common ones?)
110+
- Enum for units? (it'll be big, maybe just common ones?)
77111

78112
## CI/CD/Linting
79113

80-
- [ ] Linting
81-
82-
- [x] black
83-
- [x] isort
84-
- [x] mdformat
85-
- [ ] mypy
86-
87114
- GitHub Actions Setup
88115

89-
- [ ] Linting
90-
- [ ] black
91-
- [ ] isort
92-
- [ ] mdformat
93-
- [ ] mypy
94-
- [ ] Test running (TBD)
95-
- [ ] Coverage reporting (TBD)
96-
- [ ] Automated PyPI deployment
116+
- Linting
117+
- black
118+
- isort
119+
- mdformat
120+
- mypy
121+
- Test running (TBD)
122+
- Coverage reporting (TBD)
123+
- Automated PyPI deployment

0 commit comments

Comments
 (0)