Skip to content
Draft

Dev #21

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
145 commits
Select commit Hold shift + click to select a range
95fffc1
increment dev version
gamesguru Jun 6, 2023
b0617b1
wip nnest, want to color code & tree view `anl`
gamesguru Jun 7, 2023
7d1e574
chatGPT poc nnest
gamesguru Jun 17, 2023
65256a8
update chatGPT nnest
gamesguru Jun 17, 2023
54cdf41
print_header() method in food analysis printout
gamesguru Jul 21, 2023
857117c
small edit, wip stuff, old
gamesguru Jul 21, 2023
409727a
add average 1RM to printout
gamesguru Dec 11, 2023
609e4fb
adjust pylintrc fail-under, differential lint
gamesguru Dec 11, 2023
8e95c7a
pur: update requirements (lint)
gamesguru Dec 11, 2023
55edab7
remove @todo, expand on other one
gamesguru Dec 12, 2023
c8c5325
no f-strings, always remember for this project!
gamesguru Dec 12, 2023
1645028
update mathematica script, small fix initial value
gamesguru Dec 12, 2023
718828b
use ≤ character instead of <=
gamesguru Dec 12, 2023
63aa605
update anl help to show recipes/days too
gamesguru Dec 14, 2023
79f6c20
use --version, no "-v"
gamesguru Dec 14, 2023
2291636
use --debug, no "-d". Update black. Changelog.
gamesguru Dec 14, 2023
3b50045
move nested list nnest blueprint to .rst file
gamesguru Dec 14, 2023
3e474bf
lint RST fix
gamesguru Dec 14, 2023
5bde08a
update lint reqs
gamesguru Dec 22, 2023
e9980c3
add todo note about what to make nnest into
gamesguru Dec 23, 2023
0f83b94
update requirements (lint)
gamesguru Dec 27, 2023
f3b387d
wip bug report
gamesguru Feb 13, 2024
c11dfe8
wip bug report
gamesguru Feb 13, 2024
17ef561
wip bug report
gamesguru Feb 13, 2024
0acffe5
wip bug report
gamesguru Feb 14, 2024
598def4
wip URLS_API (try all available hosts)
gamesguru Feb 14, 2024
e5e4af2
list bugs too (not just submitting)
gamesguru Feb 14, 2024
7be43ba
keep chugging on bugs
gamesguru Feb 14, 2024
ee248a3
upgrade lint requirements
gamesguru Feb 14, 2024
4e36797
wip cache mirrors
gamesguru Feb 15, 2024
458ffc7
[temp] drop coverage 90 -> 85
gamesguru Feb 15, 2024
1b9dca7
bug submission MVP. wip configparser
gamesguru Feb 15, 2024
9569a7c
tweak, don't allow 200s
gamesguru Feb 15, 2024
eedf676
wip nutprogbar stuff
gamesguru Feb 22, 2024
cbf44f4
wip
gamesguru Feb 23, 2024
d96f506
fix both macro bars showing same numbers
gamesguru Feb 24, 2024
f35f9e0
move print_macro_bar to top-level (not sub-func)
gamesguru Feb 24, 2024
e2d3971
upgrade USDA/usda verion, and lint deps
gamesguru Feb 25, 2024
3238f1a
typing Sequence[], Mapping[] vs. list, dict
gamesguru Feb 25, 2024
154eee2
fix URL for usda-sqlite.sql.tar.xz
gamesguru Feb 25, 2024
0056084
suppress exception for now, for testing purposes
gamesguru Feb 25, 2024
59449cf
fix submodule (no such commit was found error)
gamesguru Feb 25, 2024
d2d2910
fix no such file error
gamesguru Feb 25, 2024
d6a1f51
bump 3.10 --> 3.11
gamesguru Feb 25, 2024
c4c7c99
more typing indictaors/casting
gamesguru Feb 25, 2024
887fc96
truncate food name > 50 characters
gamesguru Feb 25, 2024
82f38ff
update comments
gamesguru Feb 25, 2024
a7b1f79
wip
gamesguru Feb 25, 2024
1bf5de3
wip
gamesguru Feb 25, 2024
addedc7
wip
gamesguru Feb 25, 2024
9d40a82
wip, but `anl` is working somewhat okay now again
gamesguru Feb 25, 2024
6e17fbc
test coverage, *shrugs*
gamesguru Feb 25, 2024
95cf615
wip testing, bleh
gamesguru Feb 25, 2024
e2b9231
test coverage
gamesguru Feb 25, 2024
232a661
test coverage ApiClient.get() not used yet anyway
gamesguru Feb 25, 2024
ca39f4f
add recipe_csv_util tests
gamesguru Feb 25, 2024
a50f994
usda init: pragma: no cover
gamesguru Feb 25, 2024
7907280
test bug
gamesguru Feb 25, 2024
4012ca7
aaa test package (test order, test_bug depends)
gamesguru Feb 25, 2024
e2827eb
tidy, remove pointless nested simulate_bug()
gamesguru Feb 25, 2024
407579e
split repr (exc_type/exc_msg), store more bug data
gamesguru Feb 25, 2024
1e28606
header for bug in argparser funcs
gamesguru Feb 25, 2024
c0c85b4
fix quadratic with -g | --grams
gamesguru Feb 26, 2024
db4e73c
pylint
gamesguru Feb 26, 2024
c441f41
Revert "pylint"
gamesguru Feb 26, 2024
9bd53c1
pylintrc
gamesguru Feb 26, 2024
97b4fbd
appease pycharm
gamesguru Feb 26, 2024
194f66c
pragma cover, and fall through non 200 errors
gamesguru Feb 26, 2024
af5c117
add dev URL explicitly to API list
gamesguru Feb 26, 2024
fd8566c
standardize all to build_subcommand_*
gamesguru Feb 27, 2024
221a0f8
lint suppression
gamesguru Feb 28, 2024
c834646
tidy TODOs, move line of code up
gamesguru Mar 1, 2024
91dda08
add TODO in test_cli to split up/mock out argparse
gamesguru Mar 1, 2024
08a1589
wip refactor sql() to return headers, and more
gamesguru Mar 2, 2024
829f429
finish sql refactor
gamesguru Mar 2, 2024
f9c8d26
fix unused headers var (oh well)
gamesguru Mar 2, 2024
606fa57
fix test
gamesguru Mar 2, 2024
8e25067
bump USDA version to 0.0.10
gamesguru Mar 2, 2024
a979992
formatting, comments
gamesguru Mar 28, 2024
9f767f4
upgrade deps
gamesguru Mar 28, 2024
f0530ed
use makefile syntax, not bash. upgrade deps
gamesguru Apr 12, 2024
32c570e
bugs: mock API call, still need to mock DB call
gamesguru Apr 12, 2024
f2986c6
wip
gamesguru Apr 12, 2024
e6f2c4f
improve mocks
gamesguru Apr 12, 2024
5e18f70
remove unused function
gamesguru Apr 12, 2024
b08bef4
warn to do a 'git add' when make format changes
gamesguru Apr 12, 2024
c74f17b
upgrade black
gamesguru Apr 12, 2024
0f8b8ad
Merge branch 'master' into dev
gamesguru Apr 12, 2024
b865898
uncomment raise for status on api client post?
gamesguru Apr 12, 2024
f2c14ea
remove shabangs
gamesguru Apr 12, 2024
10ccfcb
move todo about ".nutra.test" test home dir
gamesguru Apr 12, 2024
8cd798d
empty-commit test DB failure due to needed upgrade
gamesguru Apr 12, 2024
3e8934d
add TODO in requirements-test.txt
gamesguru Apr 12, 2024
8b0b7be
add test for __init__.py (version check branch)
gamesguru Apr 12, 2024
6cc5239
make testable function: version_check()
gamesguru Apr 12, 2024
efe4dcf
contextual patch()
gamesguru Apr 12, 2024
3b75bcc
update scripts: `nutra` and `scripts/n`
gamesguru Apr 12, 2024
79587ab
fully cover services/__init__.py
gamesguru Apr 12, 2024
bb13ac9
rename test
gamesguru Apr 12, 2024
cf9f320
fully cover: sql/__init__.py
gamesguru Apr 12, 2024
a46d0b9
coverage ignores in ntsqlite submodule
gamesguru Apr 12, 2024
784cb8a
fix tuple(csv_reader), list() first. Add test:
gamesguru Apr 12, 2024
3674b24
re-enable & fix recipe (invalid path) test
gamesguru Apr 12, 2024
cacb3d2
fully cover: services/recipe/utils.py
gamesguru Apr 12, 2024
608c202
add TODOs
gamesguru Apr 12, 2024
6e06d4b
fully cover, add test in recipes, aggregate_rows()
gamesguru Apr 12, 2024
c5a2a43
add TODO
gamesguru Apr 12, 2024
b414773
add todo; use/compare exc string in var
gamesguru Apr 12, 2024
dc58727
make `_aggregate_rows()` method private
gamesguru Apr 18, 2024
7829622
cosmetic
gamesguru Apr 19, 2024
ec3736e
cover bugs and arg parse funcs
gamesguru Apr 19, 2024
eeb1936
cover tree.py
gamesguru Apr 19, 2024
f015ba5
rename recipe.utils to recipe.recipe
gamesguru Apr 19, 2024
cf132e7
try Sequence[dict]
gamesguru Apr 19, 2024
f6ce625
fix api parameter (dict now, not sqlite3.Row)
gamesguru Apr 19, 2024
dec9c95
`: list` can be replaced with `: Sequence[...]`
gamesguru Apr 19, 2024
9434e75
test python-3.4 incompatible type annotation
gamesguru Apr 19, 2024
f69e8d2
build on 3.5 too
gamesguru Apr 19, 2024
0bec4b6
test fix
gamesguru Apr 19, 2024
a7ed90d
fix python 3.5 type annotations
gamesguru Apr 19, 2024
885ad74
fix test?
gamesguru Apr 19, 2024
2765dc0
fix test mock with _list_bugs_unsubmitted
gamesguru Apr 19, 2024
39b511c
no f-string
gamesguru Apr 19, 2024
861ec5c
small fix listing bug values not keys
gamesguru Apr 19, 2024
0d009c1
wip test ApiClient
gamesguru Apr 19, 2024
ef62648
cover api
gamesguru Apr 19, 2024
7b57e98
add TODO
gamesguru Apr 19, 2024
9a8c11f
upgrade deps (lint)
gamesguru Apr 20, 2024
20e8cab
no deprecated nodejs-16 workflow actions
gamesguru Apr 20, 2024
448ca88
update TODOs and helper text (printed off init)
gamesguru Apr 20, 2024
8731251
better check for HOOK in .bashrc, rm prefs.json
gamesguru Apr 23, 2024
98075c0
bump dev version 0.2.8.dev1
gamesguru Apr 23, 2024
ddc2d1f
format readme
gamesguru Apr 24, 2024
248f143
fix null bug_insert if args=None
gamesguru Jul 19, 2024
7799a21
bump version 0.2.8.dev2
gamesguru Jul 19, 2024
5586f45
wip relative food prog bars
gamesguru Jan 28, 2025
2a853b7
update setfup.cfg from a while ago
gamesguru Dec 26, 2025
1cb6c76
wip
gamesguru Jan 11, 2026
f32249f
pre-planning deep action session
gamesguru Jan 11, 2026
26560e1
small additions
gamesguru Jan 11, 2026
cd7b0d2
refactor re-used code into compact method calls
gamesguru Jan 11, 2026
2f880b0
lint/format
gamesguru Jan 11, 2026
7e499ac
wip trim some code
gamesguru Jan 11, 2026
c3c457b
update/format/lint
gamesguru Jan 11, 2026
f6c50cc
Update ntclient/persistence/sql/nt/funcs.py
gamesguru Jan 12, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ indent_size = 2
max_line_length = 79


[{COMMIT_EDITMSG,MERGE_MSG,SQUASH_MSG,git-rebase-todo}]
[{COMMIT_EDITMSG,MERGE_MSG,SQUASH_MSG,TAG_EDITMSG,git-rebase-todo}]
max_line_length = 72
6 changes: 6 additions & 0 deletions .geminiignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.venv
.pytest_cache
__pycache__
*.sql
*.db

12 changes: 6 additions & 6 deletions .github/workflows/install-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ jobs:

strategy:
matrix:
python-version: ["3.10"]
python-version: ["3.11", "3.5"]
Copy link

@cubic-dev-ai cubic-dev-ai bot Jan 12, 2026

Choose a reason for hiding this comment

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

P1: Python 3.5 is incompatible with actions/setup-python@v5 and will cause workflow failures due to SSL certificate verification errors. Python 3.5 reached EOL in 2020. Consider using supported Python versions like 3.8, 3.9, 3.10, 3.11, or 3.12 instead.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At .github/workflows/install-linux.yml, line 18:

<comment>Python 3.5 is incompatible with actions/setup-python@v5 and will cause workflow failures due to SSL certificate verification errors. Python 3.5 reached EOL in 2020. Consider using supported Python versions like 3.8, 3.9, 3.10, 3.11, or 3.12 instead.</comment>

<file context>
@@ -15,16 +15,16 @@ jobs:
     strategy:
       matrix:
-        python-version: ["3.10"]
+        python-version: ["3.11", "3.5"]
 
     steps:
</file context>
Suggested change
python-version: ["3.11", "3.5"]
python-version: ["3.11", "3.10"]
Fix with Cubic


steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
# update-environment: false
Expand All @@ -35,7 +35,7 @@ jobs:

# NOTE: see above NOTE, we are still using deprecated cache restore
- name: Reload Cache / pip
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.cache/pip
# NOTE: only cares about base requirements.txt
Expand All @@ -52,6 +52,6 @@ jobs:

- name: Basic Tests / CLI / Integration
run: |
n -v
nutra -d recipe init -f
n --version
nutra --debug recipe init -f
nutra --no-pager recipe
10 changes: 5 additions & 5 deletions .github/workflows/install-win32.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
Copy link

@cubic-dev-ai cubic-dev-ai bot Jan 12, 2026

Choose a reason for hiding this comment

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

P0: Python 3.4 is not supported by actions/setup-python@v5. Python 3.4 reached EOL in 2019, and setup-python's minimum supported version is Python 3.5+. This workflow will fail when attempting to set up Python 3.4. Consider either keeping actions/setup-python@v4 (though support is not guaranteed) or updating the Python version to 3.5 or later.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At .github/workflows/install-win32.yml, line 25:

<comment>Python 3.4 is not supported by actions/setup-python@v5. Python 3.4 reached EOL in 2019, and setup-python's minimum supported version is Python 3.5+. This workflow will fail when attempting to set up Python 3.4. Consider either keeping actions/setup-python@v4 (though support is not guaranteed) or updating the Python version to 3.5 or later.</comment>

<file context>
@@ -17,18 +17,18 @@ jobs:
 
       - name: Set up Python ${{ matrix.python-version }}
-        uses: actions/setup-python@v4
+        uses: actions/setup-python@v5
         with:
           python-version: ${{ matrix.python-version }}
</file context>
Fix with Cubic

with:
python-version: ${{ matrix.python-version }}
# update-environment: false

- name: Reload Cache / pip
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~\AppData\Local\pip\Cache
# NOTE: only cares about base requirements.txt
Expand All @@ -43,8 +43,8 @@ jobs:

- name: Basic Tests / CLI / Integration
run: |
n -v
nutra -d init -y
n --version
nutra --debug init -y
nutra --no-pager nt
nutra --no-pager sort -c 789
nutra --no-pager search ultraviolet mushrooms
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive

- name: Fetch master (for incremental diff, lint filter mask)
run: git fetch origin master

- name: Reload Cache / pip
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3
cache: "pip" # caching pip dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive

Expand Down
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[MASTER]

fail-under=9.93
fail-under=9.95


[MESSAGES CONTROL]
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ and this project adheres to `Semantic Versioning <https://semver.org/spec/v2.0.0
[0.2.8] - Unreleased
########################################################################

Added
~~~~~

- ``Nutrient`` class, and partially completed ``nnest`` nested list.
- Print statement for average of 1-rep maxes (for 3 different formulas)
- ``print_header()`` function inside of ``services/analyze.py``

Removed
~~~~~~~

- ``-d`` and ``-v`` shortcuts for ``--debug`` and ``--version``



[0.2.7] - 2023-03-27
Expand Down
83 changes: 58 additions & 25 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ SHELL=/bin/bash
.PHONY: _help
_help:
@printf "\nUsage: make <command>, valid commands:\n\n"
@grep "##" $(MAKEFILE_LIST) | grep -v IGNORE_ME | sed -e 's/##//' | column -t -s $$'\t'
@grep "##" $(MAKEFILE_LIST) | grep -v ^# | grep -v IGNORE_ME | sed -e 's/##//' | column -t -s $$'\t'



Expand All @@ -16,11 +16,15 @@ _help:

.PHONY: init
init: ## Set up a Python virtual environment
# Fetch submodule
git submodule update --init
# Re-add virtual environment
rm -rf .venv
${PY_SYS_INTERPRETER} -m venv .venv
# Upgrade dependencies and pip, if NOT running in CI automation
- if [ -z "${CI}" ]; then ${PY_SYS_INTERPRETER} -m venv --upgrade-deps .venv; fi
direnv allow
@echo "INFO: Successfully initialized venv, run 'make deps' now!"

# include .env
SKIP_VENV ?=
Expand All @@ -29,7 +33,8 @@ PWD ?= $(shell pwd)
.PHONY: _venv
_venv:
# Test to enforce venv usage across important make targets
[ "${SKIP_VENV}" ] || [ "${PYTHON}" = "${PWD}/.venv/bin/python" ]
test "${SKIP_VENV}" || test "${PYTHON}" = "${PWD}/.venv/bin/python"
@echo "OK"



Expand All @@ -54,10 +59,12 @@ REQ_LINT := requirements-lint.txt
REQ_TEST := requirements-test.txt
REQ_TEST_OLD := requirements-test-old.txt

# TODO: this is a fragile hack (to get it to work in CI and locally too)
PIP_OPT_ARGS ?= $(shell if [ "$(SKIP_VENV)" ]; then echo "--user"; fi)

.PHONY: deps
deps: _venv ## Install requirements
# Install requirements
${PIP} install wheel
${PIP} install ${PIP_OPT_ARGS} -r requirements.txt
- ${PIP} install ${PIP_OPT_ARGS} -r ${REQ_OPT}
Expand All @@ -69,42 +76,65 @@ deps: _venv ## Install requirements
# Format, lint, test
# ---------------------------------------

.PHONY: format
format: _venv ## Format with isort & black
if [ "${CHANGED_FILES_PY_FLAG}" ]; then isort ${CHANGED_FILES_PY} ; fi
if [ "${CHANGED_FILES_PY_FLAG}" ]; then black ${CHANGED_FILES_PY} ; fi


LINT_LOCS := ntclient/ tests/ setup.py
# LINT_LOCS := ntclient/ tests/ setup.py
CHANGED_FILES_RST ?= $(shell git diff origin/master --name-only --diff-filter=MACRU \*.rst)
CHANGED_FILES_PY ?= $(shell git diff origin/master --name-only --diff-filter=MACRU \*.py)
CHANGED_FILES_PY_FLAG ?= $(shell if [ "$(CHANGED_FILES_PY)" ]; then echo 1; fi)

.PHONY: format
format: _venv ## Format with isort & black
ifneq ($(CHANGED_FILES_PY),)
isort ${CHANGED_FILES_PY}
black ${CHANGED_FILES_PY}
-git --no-pager diff --stat
@echo "OK"
@git diff --quiet || echo "NOTE: You may want to run: git add ."
else
$(info No changed Python files, skipping.)
endif

.PHONY: lint
lint: _venv ## Lint code and documentation
ifneq ($(CHANGED_FILES_RST),)
# lint RST
if [ "${CHANGED_FILES_RST}" ]; then doc8 --quiet ${CHANGED_FILES_RST}; fi
doc8 --quiet ${CHANGED_FILES_RST}
@echo "OK"
else
$(info No changed RST files, skipping.)
endif
ifneq ($(CHANGED_FILES_PY),)
# check formatting: Python
if [ "${CHANGED_FILES_PY_FLAG}" ]; then isort --diff --check ${CHANGED_FILES_PY} ; fi
if [ "${CHANGED_FILES_PY_FLAG}" ]; then black --check ${CHANGED_FILES_PY} ; fi
isort --diff --check ${CHANGED_FILES_PY}
black --check ${CHANGED_FILES_PY}
# lint Python
if [ "${CHANGED_FILES_PY_FLAG}" ]; then pycodestyle --statistics ${CHANGED_FILES_PY}; fi
if [ "${CHANGED_FILES_PY_FLAG}" ]; then bandit -q -c .banditrc -r ${CHANGED_FILES_PY}; fi
if [ "${CHANGED_FILES_PY_FLAG}" ]; then flake8 ${CHANGED_FILES_PY}; fi
if [ "${CHANGED_FILES_PY_FLAG}" ]; then mypy ${CHANGED_FILES_PY}; fi
if [ "${CHANGED_FILES_PY_FLAG}" ]; then pylint ${CHANGED_FILES_PY}; fi
pycodestyle --statistics ${CHANGED_FILES_PY}
bandit -q -c .banditrc -r ${CHANGED_FILES_PY}
flake8 ${CHANGED_FILES_PY}
mypy ${CHANGED_FILES_PY}
pylint ${CHANGED_FILES_PY}
@echo "OK"
else
$(info No changed Python files, skipping.)
endif

.PHONY: pylint
pylint:
if [ "${CHANGED_FILES_PY_FLAG}" ]; then pylint ${CHANGED_FILES_PY}; fi
ifneq ($(CHANGED_FILES_PY),)
pylint ${CHANGED_FILES_PY}
else
$(info No changed Python files, skipping.)
endif

.PHONY: mypy
mypy:
if [ "${CHANGED_FILES_PY_FLAG}" ]; then mypy ${CHANGED_FILES_PY}; fi
ifneq ($(CHANGED_FILES_PY),)
mypy ${CHANGED_FILES_PY}
else
$(info No changed Python files, skipping.)
endif


.PHONY: test
test: _venv ## Run CLI unittests
test: _venv ## Run CLI unit tests
coverage run
coverage report
- grep fail_under setup.cfg
Expand Down Expand Up @@ -144,7 +174,7 @@ install: ## pip install .
${PY_SYS_INTERPRETER} -m pip install . || ${PY_SYS_INTERPRETER} -m pip install --user .
${PY_SYS_INTERPRETER} -m pip show nutra
- ${PY_SYS_INTERPRETER} -c 'import shutil; print(shutil.which("nutra"));'
nutra -v
nutra --version



Expand All @@ -156,16 +186,19 @@ RECURSIVE_CLEAN_LOCS ?= $(shell find ntclient/ tests/ \
-name __pycache__ \
-o -name .coverage \
-o -name .mypy_cache \
-o -name .pytest_cache)
-o -name .pytest_cache \
)

.PHONY: clean
clean: ## Clean up __pycache__ and leftover bits
rm -f .coverage ntclient/ntsqlite/sql/nt.sqlite3
rm -rf build/
rm -rf nutra.egg-info/
rm -rf .pytest_cache/ .mypy_cache/
ifneq ($(RECURSIVE_CLEAN_LOCS),)
# Recursively find & remove
if [ "${RECURSIVE_CLEAN_LOCS}" ]; then rm -rf ${RECURSIVE_CLEAN_LOCS}; fi
rm -rf ${RECURSIVE_CLEAN_LOCS}
endif



Expand All @@ -175,4 +208,4 @@ clean: ## Clean up __pycache__ and leftover bits

.PHONY: extras/cloc
extras/cloc: ## Count lines of source code
- cloc HEAD
- cloc HEAD ntclient/ntsqlite
5 changes: 3 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Install with,
HOOK='eval "$(direnv hook '$DEFAULT_SHELL')"'

# Install the hook, if not already
grep "$HOOK" $SHELL_RC_FILE || echo "$HOOK" >>$SHELL_RC_FILE
grep ^"$HOOK"$ $SHELL_RC_FILE || echo "$HOOK" >>$SHELL_RC_FILE
source $SHELL_RC_FILE

This is what the ``.envrc`` file is for. It automatically activates ``venv``.
Expand Down Expand Up @@ -269,4 +269,5 @@ Usage
Requires internet connection to download initial datasets.
Run ``nutra init`` for this step.

Run ``n`` or ``nutra`` to output usage (``-h`` flag is optional and defaulted).
Run ``n`` or ``nutra`` to output usage (``--help`` flag is optional and
defaulted).
39 changes: 27 additions & 12 deletions ntclient/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,38 +16,53 @@

# Package info
__title__ = "nutra"
__version__ = "0.2.7"
__version__ = "0.2.8.dev2"
__author__ = "Shane Jaroch"
__email__ = "chown_tee@proton.me"
__license__ = "GPL v3"
__copyright__ = "Copyright 2018-2022 Shane Jaroch"
__url__ = "https://github.com/nutratech/cli"

# Sqlite target versions
__db_target_nt__ = "0.0.6"
__db_target_usda__ = "0.0.8"
# TODO: should this be via versions.csv file? Don't update in two places?
__db_target_nt__ = "0.0.7"
__db_target_usda__ = "0.0.10"
USDA_XZ_SHA256 = "25dba8428ced42d646bec704981d3a95dc7943240254e884aad37d59eee9616a"

# Global variables
PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))
NUTRA_HOME = os.getenv("NUTRA_HOME", os.path.join(os.path.expanduser("~"), ".nutra"))
USDA_DB_NAME = "usda.sqlite"
NUTRA_HOME = os.getenv(
"NUTRA_HOME",
os.getenv("NUTRA_DIR", os.path.join(os.path.expanduser("~"), ".nutra")),
)
USDA_DB_NAME = "usda.sqlite3"
# NOTE: NT_DB_NAME = "nt.sqlite3" is defined in ntclient.ntsqlite.sql

NTSQLITE_BUILDPATH = os.path.join(PROJECT_ROOT, "ntsqlite", "sql", NT_DB_NAME)
NTSQLITE_DESTINATION = os.path.join(NUTRA_HOME, NT_DB_NAME)

# Check Python version

def version_check() -> None:
"""Check Python version"""
# pylint: disable=global-statement
global PY_SYS_VER, PY_SYS_STR
PY_SYS_VER = sys.version_info[0:3]
PY_SYS_STR = ".".join(str(x) for x in PY_SYS_VER)

if PY_SYS_VER < PY_MIN_VER:
# TODO: make this testable with: `class CliConfig`?
raise RuntimeError(
"ERROR: %s requires Python %s or later to run" % (__title__, PY_MIN_STR),
"HINT: You're running Python %s" % PY_SYS_STR,
)
Comment on lines +54 to +57
Copy link

@cubic-dev-ai cubic-dev-ai bot Jan 12, 2026

Choose a reason for hiding this comment

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

P1: RuntimeError is raised with two separate arguments, which will be displayed as a tuple instead of properly formatted error messages. Combine them into a single string with a newline separator.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At ntclient/__init__.py, line 54:

<comment>RuntimeError is raised with two separate arguments, which will be displayed as a tuple instead of properly formatted error messages. Combine them into a single string with a newline separator.</comment>

<file context>
@@ -16,38 +16,53 @@
+
+    if PY_SYS_VER < PY_MIN_VER:
+        # TODO: make this testable with: `class CliConfig`?
+        raise RuntimeError(
+            "ERROR: %s requires Python %s or later to run" % (__title__, PY_MIN_STR),
+            "HINT:  You're running Python %s" % PY_SYS_STR,
</file context>
Suggested change
raise RuntimeError(
"ERROR: %s requires Python %s or later to run" % (__title__, PY_MIN_STR),
"HINT: You're running Python %s" % PY_SYS_STR,
)
raise RuntimeError(
"ERROR: %s requires Python %s or later to run\n"
"HINT: You're running Python %s" % (__title__, PY_MIN_STR, PY_SYS_STR)
)
Fix with Cubic



PY_MIN_VER = (3, 4, 3)
PY_SYS_VER = sys.version_info[0:3]
PY_MIN_STR = ".".join(str(x) for x in PY_MIN_VER)
PY_SYS_STR = ".".join(str(x) for x in PY_SYS_VER)
if PY_SYS_VER < PY_MIN_VER:
# TODO: make this testable with: `class CliConfig`?
raise RuntimeError( # pragma: no cover
"ERROR: %s requires Python %s or later to run" % (__title__, PY_MIN_STR),
"HINT: You're running Python %s" % PY_SYS_STR,
)
# Run the check
version_check()

# Console size, don't print more than it
BUFFER_WD = shutil.get_terminal_size()[0]
Expand Down
Loading
Loading