Skip to content

Commit

Permalink
Misc. tweaks (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
gecrooks authored Feb 3, 2021
1 parent 2575bc2 commit 55c258f
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-12s\033[0m %s\n", $$1, $$2}'


test:
test: ## Build example cookicutter project and test
rm -rf example_python_project/.git # Remove old git test repo if previously initilized
cookiecutter --no-input --overwrite-if-exists .
cd example_python_project; make all
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -349,11 +349,12 @@ exclude_lines =
except ImportError
assert False
raise NotImplementedError()
pass
```

We have to explicitly omit the unit tests since we have placed the test files in the same directories as the code to test.

The [pragma](https://en.wikipedia.org/wiki/Directive_(programming)) `pragma: no cover` is used to mark untestable lines. This often happens with conditional imports used for backwards compatibility between python versions. The other excluded lines are common patterns of code that doesn't need test coverage.
The [pragma](https://en.wikipedia.org/wiki/Directive_(programming)) `pragma: no cover` is used to mark untestable lines. This often happens with conditional imports used for backwards compatibility between python versions. The other excluded lines are common patterns of code that don't need test coverage.


## Linting
Expand All @@ -377,7 +378,7 @@ The configuration also lives in `setup.cfg`.
max-line-length = 88
ignore = E203, W503
```
We need to override the linter on occasion. We add pragma such as `# noqa: F401` to assert that no, really, in this case we do know what we're doing.
We need to override the linter on occasion. We add pragmas such as `# noqa: F401` to assert that no, really, in this case we do know what we're doing.


Two other python code format tools to consider using are [isort](https://pypi.org/project/isort/) and [black, The uncompromising code formatter](https://black.readthedocs.io/en/stable/). Isort sorts your import statements into a canonical order. And Black is the Model-T Ford of code formatting -- any format you want, so long as it's Black. I could quibble about some of Black's code style, but in the end it's just easier to blacken your code and accept black's choices, and thereby gain a consistent coding style across developers.
Expand Down Expand Up @@ -698,7 +699,7 @@ The basic idea is to replace customizable text with template strings, e.g. `{{c
Defaults for these templates are stored in `cookiecutter.json`. In particular example_python_package is moved to a directory called
`{{cookiecutter.module_name}}`, and the module code is moved to
`{{cookiecutter.module_name}}/{{cookiecutter.module_name}}`.
I'm more or less following [cookiecutter-pypackage])https://github.com/audreyfeldroy/cookiecutter-pypackage)
I'm more or less following [cookiecutter-pypackage](https://github.com/audreyfeldroy/cookiecutter-pypackage)

One tricky bit is that some of the github configuration files already contain similar template strings. So we have to
wrap those strings in special raw tags.
Expand Down
4 changes: 3 additions & 1 deletion example_python_project/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,12 @@ build: ## Setuptools build
./setup.py clean --all
./setup.py sdist bdist_wheel


clean: ## Clean up after setuptools
./setup.py clean --all

requirements: ## Make requirements.txt
pip freeze > requirements.txt


.PHONY: help
.PHONY: docs
Expand Down
3 changes: 2 additions & 1 deletion example_python_project/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ python_requires = >= 3.8
packages = find:

install_requires =
numpy # example
numpy >= 1.20 # v1.20 introduces typechecking for numpy

setup_requires =
setuptools_scm
Expand Down Expand Up @@ -94,6 +94,7 @@ exclude_lines =
except ImportError
assert False
raise NotImplementedError()
pass



Expand Down
4 changes: 3 additions & 1 deletion {{cookiecutter.module_name}}/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,12 @@ build: ## Setuptools build
./setup.py clean --all
./setup.py sdist bdist_wheel


clean: ## Clean up after setuptools
./setup.py clean --all

requirements: ## Make requirements.txt
pip freeze > requirements.txt


.PHONY: help
.PHONY: docs
Expand Down
5 changes: 3 additions & 2 deletions {{cookiecutter.module_name}}/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Keywords = python
Home-page = https://github.com/{{cookiecutter.github_username}}/{{cookiecutter.module_name}}/
Author = {{cookiecutter.author_name}}
Author-email = {{cookiecutter.author_email}}
License = Apache-2.0
License = {{cookiecutter.license}}
License-File = LICENSE

# https://pypi.org/classifiers/
Expand Down Expand Up @@ -46,7 +46,7 @@ python_requires = >= 3.8
packages = find:

install_requires =
numpy # example
numpy >= 1.20 # v1.20 introduces typechecking for numpy

setup_requires =
setuptools_scm
Expand Down Expand Up @@ -94,6 +94,7 @@ exclude_lines =
except ImportError
assert False
raise NotImplementedError()
pass



Expand Down

0 comments on commit 55c258f

Please sign in to comment.