Skip to content

Commit 6f52287

Browse files
authored
Update question terminology, make validation text more concise (#189)
* Changing question term `module` into `package`. * Trying to create a multiline validation error. * Trying a different line break. * Gave up, used ChatGPT to help shorten the validator message. * Updated docs to include formatting requirements. * Update jinja template directory name. * Update the tests jinja template directory name too. * Addressing PR comments.
1 parent 04578c4 commit 6f52287

File tree

12 files changed

+25
-25
lines changed

12 files changed

+25
-25
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ jobs:
1616
python-version: ['3.8', '3.9', '3.10']
1717
copier_config:
1818
- name: Base example
19-
module_name: example_project # The default module_name
19+
package_name: example_project # The default package_name
2020
extra_flags: ''
2121
foldername: base_example
2222
- name: Black w/o example module
23-
module_name: 'drewtonian' # Same module name provided in `extra_flags` on the next line.
23+
package_name: 'drewtonian' # Same module name provided in `extra_flags` on the next line.
2424
extra_flags: >-
2525
--data project_name=new_science
26-
--data module_name=drewtonian
26+
--data package_name=drewtonian
2727
--data author_name=Drew
2828
2929
--data project_license=BSD
@@ -35,10 +35,10 @@ jobs:
3535
--data use_gitlfs=disabled
3636
foldername: 'black_w_o_example_module'
3737
- name: Black w/ example
38-
module_name: 'drewtonian' # Same module name provided in `extra_flags` on the next line.
38+
package_name: 'drewtonian' # Same module name provided in `extra_flags` on the next line.
3939
extra_flags: >-
4040
--data project_name=new_science
41-
--data module_name=drewtonian
41+
--data package_name=drewtonian
4242
--data author_name=Drew
4343
4444
--data project_license=BSD
@@ -50,10 +50,10 @@ jobs:
5050
--data use_gitlfs=disabled
5151
foldername: 'black_w_example_module'
5252
- name: Pylint w/o example
53-
module_name: 'drewtonian' # Same module name provided in `extra_flags` on the next line.
53+
package_name: 'drewtonian' # Same module name provided in `extra_flags` on the next line.
5454
extra_flags: >-
5555
--data project_name=new_science
56-
--data module_name=drewtonian
56+
--data package_name=drewtonian
5757
--data author_name=Drew
5858
5959
--data project_license=BSD
@@ -132,4 +132,4 @@ jobs:
132132
if: ${{ !contains(matrix.copier_config.extra_flags, 'create_example_module=no') }}
133133
run: |
134134
cd ../test/${{ matrix.copier_config.foldername }}
135-
python -m pytest tests --cov=${{ matrix.copier_config.module_name }} --cov-report=xml
135+
python -m pytest tests --cov=${{ matrix.copier_config.package_name }} --cov-report=xml

copier.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ project_name:
1212
default: example_project
1313
validator: >-
1414
{% if not (project_name | regex_search('^[a-z][a-z0-9\_\-]+$')) %}
15-
project_name must start with a letter, followed by one or more letters, digits, hyphens, or underscores (all letters lowercase).
15+
Must use a lowercase letter followed by one or more of (a-z, 0-9, _, -).
1616
{% endif %}
1717
18-
module_name:
18+
package_name:
1919
type: str
20-
help: What is your python module name?
21-
default: example_module
20+
help: What is your python package name?
21+
default: example_package
2222
validator: >-
23-
{% if not (module_name | regex_search('^[a-z][a-z0-9\_]+$')) %}
24-
module_name must start with a letter, followed by one or more letters, digits, or underscores (all letters lowercase).
23+
{% if not (package_name | regex_search('^[a-z][a-z0-9\_]+$')) %}
24+
Must use a lowercase letter followed by one or more of (a-z, 0-9, _).
2525
{% endif %}
2626
2727
author_name:

docs/source/new_project.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ questions:
2525
* - *Would you like to use simple (default tooling) or customized installation?*
2626
- If a simple install is used, the template automatically selects the recommended tooling options (linter, isort, and create example module).
2727
* - *What is the name of your project?*
28-
- The name of your project.
29-
* - *What is your python module name?*
30-
- The name of your (first) module. This controls where your source code will live (``src/{{module_name}}``).
28+
- The name of your project. If you distribute your code via PyPI, this is the name that will be used. This will allow users to pip install like so: ``pip install <project_name>``. The project name must start with a lowercase letter, followed by one or more of the following (a-z, 0-9, _, -).
29+
* - *What is your python package name?*
30+
- The name of your top level package. Specifies the location of the source code (``src/{{package_name}}``). The package name must start with a lowercase letter, followed by one or more of the following (a-z, 0-9, _).
3131
* - *Your first and last name?*
3232
- The name of code's author. This will be used in the project and documentation metadata. This name will also be included as part of the copyright license.
3333
* - *Your preferred email address?*
@@ -41,7 +41,7 @@ questions:
4141
* - *Would you like to include mypy to perform static type checking for type hints?*
4242
- `mypy <https://www.mypy-lang.org>`_ performs static type checking on python code that uses `type hints <https://docs.python.org/3/library/typing.html>`_. This type checking makes sure that the correct data types are being used where type hints are defined. If basic or strict type checking is selected, a pre-commit hook and GitHub actions workflow that perform the type checking are added. Basic type checking performs type checks but ignores code or imports for which type hints are not written. Strict type checking enforces type hints are used by giving errors where no type hints are found.
4343
* - *Do you want to create some example module code?*
44-
- If this option is selected the template will create a model in ``src/{{module_name}}`` and create a corresponding example test file. Defaults to ``True`` during simple installation.
44+
- If this option is selected the template will create an example module ``src/{{package_name}}/example_module.py`` and test file ``tests/{{package_name}}/test_example_module.py``. Defaults to ``True`` during simple installation.
4545
* - *Do you want to include rendered notebooks in your documentation?*
4646
- The requirements to host rendered notebooks on your Read the Docs (or just build them locally) will be included in your project. A sample notebook will be generated and added to your docs as an example.
4747
* - *Do you want to add a .gitattributes with entries for git-lfs?*

docs/source/update_project.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ If you change any of the initial responses during the update you should
6060
take some time to review your project for any files or directories that are no
6161
longer needed.
6262

63-
For instance, if you change the ``module_name`` response from "new_project" to
63+
For instance, if you change the ``package_name`` response from "new_project" to
6464
"great_project", it is unlikely that Copier will be able to create a new
6565
directory structure, move and rename your existing files, *and* remove the old
6666
directory structure.

python-project-template/.github/workflows/testing-and-coverage.yml.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ jobs:
3232
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
3333
- name: Run unit tests with pytest
3434
run: |
35-
python -m pytest tests --cov={{module_name}} --cov-report=xml
35+
python -m pytest tests --cov={{package_name}} --cov-report=xml
3636
- name: Upload coverage report to codecov
3737
uses: codecov/codecov-action@v3

python-project-template/docs/index.rst.jinja

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
.. {{module_name}} documentation main file.
1+
.. {{package_name}} documentation main file.
22
You can adapt this file completely to your liking, but it should at least
33
contain the root `toctree` directive.
44

5-
Welcome to {{module_name}}'s documentation!
5+
Welcome to {{package_name}}'s documentation!
66
========================================================================================
77

88
.. toctree::

python-project-template/pyproject.toml.jinja

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ requires = [
6060
build-backend = "setuptools.build_meta"
6161

6262
[tool.setuptools_scm]
63-
write_to = "src/{{module_name}}/_version.py"
63+
write_to = "src/{{package_name}}/_version.py"
6464
{%- if preferred_linter == 'black' %}
6565

6666
[tool.black]
@@ -69,5 +69,5 @@ line-length = 110
6969
{%- if mypy_type_checking != 'none' %}
7070

7171
[tool.setuptools.package-data]
72-
{{module_name}} = ["py.typed"]
72+
{{package_name}} = ["py.typed"]
7373
{%- endif %}

0 commit comments

Comments
 (0)