Skip to content

Commit

Permalink
Add poe completions to zsh
Browse files Browse the repository at this point in the history
- poe task updates
  • Loading branch information
whabanks committed Apr 19, 2024
1 parent ec8a6b6 commit a18ae33
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 16 deletions.
5 changes: 5 additions & 0 deletions .devcontainer/scripts/notify-dev-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ echo -e "alias k-staging='aws eks --region ca-central-1 update-kubeconfig --name
echo -e "alias k-prod='aws eks --region ca-central-1 update-kubeconfig --name notification-canada-ca-production-eks-cluster'" >> ~/.zshrc
echo -e "source <(kubectl completion zsh)" >> ~/.zshrc
echo -e "complete -F __start_kubectl k" >> ~/.zshrc
echo -e "alias poe='poetry run poe'" >> ~/.zshrc

# Smoke test
# requires adding files .env_staging and .env_prod to the root of the project
Expand Down Expand Up @@ -49,6 +50,10 @@ make generate-version-file
# Install dependencies
poetry install

# Poe the Poet plugin tab completions
touch ~/.zfunc/_poe
poetry run poe _zsh_completion > ~/.zfunc/_poe

# Upgrade schema of the notification_api database.
poetry run flask db upgrade

Expand Down
56 changes: 41 additions & 15 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 48 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,52 @@ types-python-dateutil = "2.8.19.20240106"
types-pytz = "2022.7.1.2"
types-requests = "2.31.0.20240106"
types-redis = "4.6.0.20240106"

monkeytype = "^23.3.0"
poethepoet = "^0.24.4"

# Poe the Poet tasks
[tool.poe.tasks.trace-app]
help = "Runs the app with monkeytype type collection enabled."
shell = """
monkeytype run -m flask run -p 6012 --host=0.0.0.0
"""

[tool.poe.tasks.trace-tests]
help = "Runs a test suite or single test through MonkeyType, generating a record of type annotation traces monkeytype.sqlite3"
shell = """
if [ -z "${method}" ]; then
monkeytype run -m pytest '/tests/app/${test-path}::${method}'
else
monkeytype run -m pytest '/tests/app/${test-path}'
fi
"""
# Define arguments for trace-tests
[tool.poe.tasks.trace-tests.args.test-path]
help = "Path to the test file to run. /tests/app/ can be omitted. e.g. poe trace-tests -p main/test_contact.py"
options = ["-p", "--path"]
type = "string"
required = true

[tool.poe.tasks.trace-tests.args.method]
help = "Name of the test method to execute and trace"
options = ["-m", "--method"]
type = "string"
default = ""
required = false

[tool.poe.tasks.list-modules]
help = "Lists all files and modules that have trace data associated with them in monkeytype.sqlite3"
cmd = "monkeytype list-modules"

# Composite task that uses list-modules to obtain a list of files and modules
[tool.poe.tasks.apply-annotations]
help = "Applies ALL known type annotations stored in monkeytype.sqlite3"
shell = """
for trace in ${TRACES}
do
monkeytype apply $trace
done
"""
deps = ["list-modules"]
uses = { TRACES = "list-modules"}

0 comments on commit a18ae33

Please sign in to comment.