Learning pieces
Github secrets
- To call a workflow from another, one needs to mark the callee workflow as reusable with
workflow_call. However, the variable${{secrets}}is not automatically available to the callee workflow. We need to explicitly give the instructions, in the caller workflow, that secrets will be passed along. To do that, usesecrets: inherit.
Dependencies in pyproject.toml
The PEP 508 defines the dependency specification for python packages. This specification
is used, for example, in pip install. But not only, it is also how dependencies should be specified
in pyproject.toml.
In the context of this project, I was using packages in my local machines, so I needed to use the
file:// protocol.
We could do the same for a git branch:
"word-def-plugin-core @ git+https://github.com/danoan/word-def-plugin-core.git@dmartins/v0.1.0"
Problems with pip cache
During development it could be the case that the pip cache gets messed up. That will result in weird behaviours
such as some changes not being reflected in the installed package. It is worthy to clean the pip cache
located at ~/.cache/pip.
My issue in particular was that the package was being installed with a different name than the one it has and that was leading to import errors. The issue was that pip was using a previous name (I changed the package name).
Testing exceptions in pytest
Learn that pytest.raises returns a type pytest.ExceptionInfo. To access the exception instance I need to type
e.value.
SimpleNamespace
Creates objects from dictionaries. Dictionary keys become the object attributes.
from types import SimpleNamespace
d = {"name":"paolo", "age": 27}
o = SimpleNamespace(d)
print(o.name)
precommit: pretty-format-json
Update the pretty-format-json hook to autocorrect itself.
sphinx: --implicit-namespaces
We need to indicate the flag --implicit-namespaces to sphinx-apidoc if we have implicit namespaces in our package.
Otherwise modules are not linked correctly.
Link rendering with MyST parser
The MyST parser extension for sphinx allows us to proper render documentation links by simply following a convention defined by the MyST parser plugin. That way, links are rendered correctly during the documentation build.
More information in the documentation.
OIDC (OpenId Connect)
In order to enable OIDC in a publish package action on github, we need to give write permissions to token
Mermaid diagrams
Add mermaid diagrams in the documentation: sphinxcontrib-mermaid.Need to list in the extensions list of conf.py besides listing it as a dependency in the documentation tox environment.
Default environments to load in tox
How to make tox command run all the test environments? I mean, pytest, format, typecheck...
LSP Servers in nvim
The LSP servers in LazyVim are managed by Mason. If we go to ~/.local/share/nvim we can find the mason folder and also the lsp servers. For example, I need that to install the python-lsp-black plugin in the pylsp venv (this is located in the mason file hierarchy) in order to pylsp make use o black instead of autopep8. The goal is to align the formatting of pylsp with pre-commit.