johnthagen / python-blueprint Goto Github PK
View Code? Open in Web Editor NEWπ Example Python project using best practices π₯
Home Page: https://johnthagen.github.io/python-blueprint/
License: MIT License
π Example Python project using best practices π₯
Home Page: https://johnthagen.github.io/python-blueprint/
License: MIT License
On Windows, the licenses
session does not work:
[Errno 13] Permission denied: 'C:\\Users\\User\\AppData\\Local\\Temp\\tmppridh_h4'
This is because of NamedTemporaryFile
issues on Windows: https://stackoverflow.com/a/23212515
The default Python 3.8 on Ubuntu leaks into the environment, so an unqualified nox -s test
will run 3.8 in addition to 3.9/10.
Possible fix:
Will need to add a minimum pip
version that supports this feature. I think it's version 10.
It was recently decided that dependencies would be described in pyproject.toml
.
When pip
, pip-tools
, tox,
etc. add support for this, should move away from requirements.txt
/dev-requirements.txt
.
Relates to #16
Once this is merged/released upstream, remove lxml
pinned dependency:
Add Dockerfile
with best practices for Python Docker images.
$ tox -r -e docs
docs recreate: python-blueprint\.tox\docs
docs installdeps: -rpython-blueprint/requirements.txt, -rpython-blueprint/dev-requirements.txt
docs installed: atomicwrites==1.4.0,attrs==21.4.0,beautifulsoup4==4.10.0,black==22.1.0,certifi==2021.10.8,charset-norm
alizer==2.0.12,click==8.0.4,colorama==0.4.4,coverage==6.3.2,distlib==0.3.4,fact==1.0.0,filelock==3.6.0,flake8==4.0.1,f
lake8-broken-line==0.4.0,flake8-bugbear==22.1.11,flake8-comprehensions==3.8.0,flake8-polyfill==1.0.2,ghp-import==2.0.2
,griffe==0.12.6,idna==3.3,importlib-metadata==4.11.1,iniconfig==1.1.1,isort==5.10.1,Jinja2==3.0.3,lxml==4.8.0,Markdown
==3.3.6,MarkupSafe==2.1.0,mccabe==0.6.1,mergedeep==1.3.4,mkdocs==1.2.3,mkdocs-autorefs==0.3.1,mkdocs-gen-files==0.3.4,
mkdocs-htmlproofer-plugin==0.8.0,mkdocs-literate-nav==0.4.1,mkdocs-material==8.2.1,mkdocs-material-extensions==1.0.3,m
kdocstrings==0.18.0,mkdocstrings-python==0.6.3,mkdocstrings-python-legacy==0.2.2,mypy==0.931,mypy-extensions==0.4.3,pa
ckaging==21.3,pathspec==0.9.0,pep8-naming==0.12.1,platformdirs==2.5.1,pluggy==1.0.0,py==1.11.0,pycodestyle==2.8.0,pyfl
akes==2.4.0,Pygments==2.11.2,pymdown-extensions==9.2,pyparsing==3.0.7,pytest==7.0.1,pytest-cov==3.0.0,python-dateutil=
=2.8.2,pytkdocs==0.16.0,PyYAML==6.0,pyyaml_env_tag==0.1,requests==2.27.1,six==1.16.0,soupsieve==2.3.1,toml==0.10.2,tom
li==2.0.1,tox==3.24.5,typer==0.4.0,typing_extensions==4.1.1,urllib3==1.26.8,virtualenv==20.13.1,watchdog==2.1.6,zipp==
3.7.0
docs run-test-pre: PYTHONHASHSEED='300'
docs run-test: commands[0] | mkdocs build
INFO - Cleaning site directory
INFO - Building documentation to directory: python-blueprint\site
INFO - The following pages exist in the docs directory, but are not included in the "nav" configuration:
- reference\fact\__init__.md
WARNING - A relative path to 'reference/factβ»95β₯_init__.md' is included in the 'nav' configuration, which is not
found in the documentation files
WARNING - Documentation file 'reference\SUMMARY.md' contains a link to 'reference\factβ»95β₯_init__.md' which is not
found in the documentation files.
Aborted with 2 warnings in strict mode!
Once Python 3.9 is released, upgrade venv
creation docs to specify the new --upgrade-deps
option
There's no license associated with this project. How are we legally allowed to use it?
setup.py
mentions MIT style.
https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html
Related to #16
Add a build
tox
env and depend on the build
package.
This greatly simplifies usage with pip-sync
at the small expense that tox
is itself installed within tox
's virtual environments.
This issue tracks upstream issues that could in some way improve the experience of python-blueprint
.
nox-poetry
https://github.com/dmerejkowsky/tbump seems superior to the bumpversion
bump2?version
pyproject.toml
Consider evaluating from this list:
See also:
If/when the flake8
developers decide to support pyproject.toml
, should move flake8
configuration to that to consolidate configurations.
This comment lists blockers the Flake8 developers have listed:
"pip to change its behaviour so mere presence of the file does not change functionality"
"neither toml nor the python implementations are even 1.0"
"python to consider adding a standard library toml implementation"
This comment lists a non-technical reason a Flake8 developer has against TOML (against the creator of TOML himself):
Recent tweets:
There are some additional mypy
checks that could be enabled: https://mypy.readthedocs.io/en/stable/command_line.html#miscellaneous-strictness-flags
Tracking: raimon49/pip-licenses#77
MkDocs and specifically Material for MkDocs offers a very nice alternative to Sphinx to consider.
For opensource project, you could add a minimal .github
folder for issues and PRs .
.github/
βββ ISSUE_TEMPLATE.md
βββ PULL_REQUEST_TEMPLATE.md
Anyway, your python-blueprint
is awesome. Good job ! ;)
From pytest --help
:
pytest-warnings:
-W PYTHONWARNINGS, --pythonwarnings=PYTHONWARNINGS
set which warnings to report, see -W option of python itself.
Passing -Werror
to pytest
directly is recommended from the help
, and works better for pytest-xdist
.
isort is an application to sort imports. This could replace flake8-import-order
and PyCharm's "Optimize Imports" feature with something that could be run from tox
.
If black
is also used, would need to ensure they work together nicely.
Upstream tracking issues
Hi!
This is a great project idea!
I noticed that you didn't include a py.typed in your project. It's very useful as it tells that your project is typed
More information here:
The only reservation is that it prescribes " "
rather than ' '
string quotes.
darglint can lint Google Style docstrings and could be a useful addition.
One concern is the maintainer is no longer using Python: https://github.com/terrencepreilly/darglint#project-status
Finally, ideally the configuration would be in pyproject.toml
but this isn't supported yet:
Poetry recently went 1.0, and looks pretty good. It's inspired by really solid package managers like Cargo.
There are some tox
related issues that looked a bit concerning.
Should continue to monitor it, and if it continues to gain market share and maturity, consider switching from recommending pip-tools
to poetry
.
Related to #7
Consider including https://github.com/asottile/pyupgrade as a way to lint against old code forms.
Poetry 1.2 has been released:
New features of particular significance
--sync
--with
/ --only
Related:
As of Nov 2, 2020 Travis CI will no longer be free for FOSS projects.
Will need to migrate to GitHub Actions or Circle CI.
Should also be able to replace direct usage of colorama
for Rich instead.
The idea would be to show how to share the version between the packaging system (setuptools, Sphinx project, etc) and the actual application.
The blueprint uses pytest with a tests
folder that is a true Python package (it contains a __init__.py
file). This is known to interact badly with having packages defined at the top levelβin this case, fact
. This is especially problematic when using tox, which the blueprint also uses. tox installs the distribution in a virtual environment so that the distribution itself can be tested. However, pytest adds to sys.path
all directories containing test packages. Because tests
is a package, the project root is added to sys.path
and the fact
package in the project root shadows the fact
package installed in the tox environment. Then that means that the fact
package being tested is actually the source package and not the fact
package installed. pytest and tox may report a success even if there are problems with the packaging of the distribution.
There are a few possible solutions to ensuring that the project root does not end up included in sys.path
:
__init__.py
file from tests
, which prevents pytest
from adding the project root to sys.path
and run pytest
directly as a tox command, not via python -m pytest
to prevent python
from adding the project root to sys.path
.__init__.py
file from tests
and change the working directory of the test command to tests
.src
folder. This is the recommended solution by pytest
when using tox.A possible replacement for tox
is nox
: https://nox.thea.codes/en/stable/
Related to #16, consider nox-poetry
: https://github.com/cjolowicz/nox-poetry
As small side effect of this is that flake8
configuration would need to move back into flake8.ini
or setup.cfg
until #29 is complete.
This line in the testenv might do the trick:
{envpython} -c "import shutil; shutil.rmtree('_build', ignore_errors=True)"
Could replace Sphinx API doc usages with https://github.com/mkdocstrings/mkdocstrings
Evaluate https://editorconfig.org/
This would be a safer default (also the same as that used by Tox):
furo
is a clean, elegant dark theme for Sphinx worth showing in the blueprint.
This allows us to avoid excluding .nox
Blocked by:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.