Skip to content

Commit bc4776e

Browse files
authored
Add: Vale prose linter with basic config - pycon sprint!
Setup Vale (prose linter) with a minimal unobtrusive configuration
2 parents e5d7ff4 + 1076550 commit bc4776e

23 files changed

+1474
-8
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,4 @@ __pycache__
88
*notes-from-review.md
99
*.idea*
1010
# Grammar / syntax checkers
11-
.vale.ini
1211
styles/

.pre-commit-config.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ repos:
3131
- id: codespell
3232
additional_dependencies:
3333
- tomli
34+
exclude: >
35+
(?x)^(
36+
.*vale-styles.*
37+
)$
38+
39+
- repo: https://github.com/errata-ai/vale
40+
rev: v3.4.2
41+
hooks:
42+
- id: vale
3443

3544
ci:
3645
autofix_prs: false

.vale.ini

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Configuration file for using Vale in the python-package-guide repository
2+
#
3+
# To disable checks on parts of a MarkDown or HTML file, delimit the section
4+
# using these HTML comments:
5+
# to disabled Vale checks after this line: <!-- vale off -->
6+
# to enable Vale checks after this line: <!-- vale on -->
7+
#
8+
# To disable checks based on MarkDown scope, see IgnoredScopes.
9+
# To disable checks on certain HTML elements, see IgnoredClasses.
10+
#
11+
# More information about the configuration can be found here:
12+
# https://vale.sh/docs/topics/config
13+
14+
15+
# Path to the styles directory, where style rules are defined
16+
StylesPath = vale-styles
17+
18+
# Path to a dictionary folders inside the StylesPath config subdirectory. This
19+
# folder can contain two files, accept.txt and reject.txt, with one word per
20+
# line. These words will be used to check for spelling mistakes in addition to
21+
# the internal dictionary, if the 'Vale' ruleset is enabled (see below)
22+
# See https://vale.sh/docs/topics/vocab/#folder-structure for more details
23+
Vocab = sample
24+
25+
26+
# Checks are defined in sections by file type, like the one below for
27+
# MarkDown. In each section you can enable groups of style rules, defined in folders
28+
# inside the StylesPath directory.
29+
# Use 'Vale' to enable the internal style rules and checks.
30+
31+
[*.md]
32+
BasedOnStyles = package-guide-test

conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@
135135
"styles/write-good/README.md",
136136
"styles/*",
137137
".pytest_cache/README.md",
138+
"vale-styles/*",
138139
]
139140

140141
# For sitemap generation

index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ The first round of our community-developed, how to create a Python package tutor
7171

7272
* [What is a Python package?](/tutorials/intro)
7373
* [Make your code installable](/tutorials/installable-code)
74-
* [Publish your package to (test) PyPi](/tutorials/publish-pypi)
74+
* [Publish your package to (test) PyPI](/tutorials/publish-pypi)
7575
* [Publish your package to conda-forge](/tutorials/publish-conda-forge)
7676

7777
:::

package-structure-code/publish-python-package-pypi-conda.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ exist in the `defaults` Anaconda channel.
104104

105105
:::{figure-md} pypi-conda-channels
106106

107-
<img src="../images/python-pypi-conda-channels.png" alt="Graphic with the title Python package repositories. Below it says Anything hosted on PyPI can be installed using pip install. Packaging hosted on a conda channel can be installed using conda install. Below that there are two rows. the top row says conda channels. next to it are three boxes one with conda-forge, community maintained; bioconda and then default - managed by the anaconda team. Below that there is a row that says PyPI servers. PyPI - anyone can publish to pypi. and test pypi. a testbed server for you to practice. " width="700px">
107+
<img src="../images/python-pypi-conda-channels.png" alt="Graphic with the title Python package repositories. Below it says Anything hosted on PyPI can be installed using pip install. Packaging hosted on a conda channel can be installed using conda install. Below that there are two rows. the top row says conda channels. next to it are three boxes one with conda-forge, community maintained; bioconda and then default - managed by the anaconda team. Below that there is a row that says PyPI servers. PyPI - anyone can publish to PyPI. and test PyPI. a testbed server for you to practice. " width="700px">
108108

109109
Conda channels represent various repositories that you can install packages from. Because conda-forge is community maintained, anyone can submit a recipe there. PyPI is also a community maintained repository. Anyone can submit a package to PyPI and test PyPI. Unlike conda-forge there are no manual checks of packages submitted to PyPI.
110110
:::

package-structure-code/python-package-distribution-files-sdist-wheel.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,14 @@ represent on your PyPI landing page. These classifiers also allow users to sort
9191
```
9292

9393
:::{figure-md} build-workflow
94-
<img src="../images/python-package-development-process.png" alt="Graphic showing the high level packaging workflow. On the left you see a graphic with code, metadata and tests in it. those items all go into your package. Documentation and data are below that box because they aren't normally published in your packaging wheel distribution. an arrow to the right takes you to a build distribution files box. that box leads you to either publishing to testpypi or the real pypi. from pypi you can then connect to conda-forge for an automated build that sends distributions from pypi to conda-forge. " width="700px">
94+
<img src="../images/python-package-development-process.png" alt="Graphic showing the high level packaging workflow. On the left you see a graphic with code, metadata and tests in it. those items all go into your package. Documentation and data are below that box because they aren't normally published in your packaging wheel distribution. an arrow to the right takes you to a build distribution files box. that box leads you to either publishing to TestPyPI or the real PyPI. from PyPI you can then connect to conda-forge for an automated build that sends distributions from PyPI to conda-forge. " width="700px">
9595

9696
You need to build your Python package in order to publish it to PyPI (or Conda). The build process organizes your code and metadata into a distribution format that can be uploaded to PyPI and subsequently downloaded and installed by users. NOTE: you need to publish a sdist to PyPI in order for conda-forge to properly build your package automatically.
9797
:::
9898

9999
:::{figure-md}
100100

101-
<img src="../images/python-build-package/pypi-metadata-keywords-license.png" alt="This screenshot shows the metadata on pypi for the xclim package. on it you can see the name of the license, the author and maintainer names keywords associated with the package and the base python version it requires which is 3.8." width="400px">
101+
<img src="../images/python-build-package/pypi-metadata-keywords-license.png" alt="This screenshot shows the metadata on PyPI for the xclim package. on it you can see the name of the license, the author and maintainer names keywords associated with the package and the base python version it requires which is 3.8." width="400px">
102102

103103
PyPI screenshot showing metadata for the xclim package.
104104
:::

pyproject.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@ dependencies = [
2121
"sphinxext-opengraph",
2222
"sphinx-inline-tabs",
2323
# for project cards
24-
"matplotlib"
24+
"matplotlib",
25+
]
26+
27+
[project.optional-dependencies]
28+
dev = [
29+
# for checking style rules
30+
"vale"
2531
]
2632

2733
[tool.hatch.build.targets.wheel]

tutorials/intro.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ Then you can create a conda-forge recipe using the [Grayskull](https://github.co
321321
[You will learn more about the conda-forge publication process here.](publish-conda-forge.md)
322322

323323
:::{figure-md} publish-package-pypi-conda-overview
324-
<img src="../images/tutorials/publish-package-pypi-conda.png" alt="Graphic showing the high level packaging workflow. On the left you see a graphic with code, metadata and tests in it. Those items all go into your package. Documentation and data are below that box because they aren't normally published in your packaging wheel distribution. an arrow to the right takes you to a build distribution files box. that box leads you to either publishing to testPyPI or the real PyPI. From PyPI you can then connect to conda-forge for an automated build that sends distributions from PyPI to conda-forge." width="700px">
324+
<img src="../images/tutorials/publish-package-pypi-conda.png" alt="Graphic showing the high level packaging workflow. On the left you see a graphic with code, metadata and tests in it. Those items all go into your package. Documentation and data are below that box because they aren't normally published in your packaging wheel distribution. an arrow to the right takes you to a build distribution files box. that box leads you to either publishing to TestPyPI or the real PyPI. From PyPI you can then connect to conda-forge for an automated build that sends distributions from PyPI to conda-forge." width="700px">
325325

326326
In the image above, you can see the steps associated with publishing
327327
your package on PyPI and conda-forge. Note that the distribution files that PyPI requires are the [sdist](#python-source-distribution) and [wheel](#python-wheel) files. Once you are ready to make your code publicly installable, you can publish it on PyPI. Once your code is on PyPI it is straight forward to then publish to conda-forge. You create a recipe using the Grayskull package and then you open a pr in the conda-forge recipe repository. You will learn more about this process in the [conda-forge lesson](/tutorials/publish-conda-forge).

tutorials/publish-pypi.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ will remember them.
295295
## Install your package from TestPyPI
296296

297297
Once your package upload is complete, you can install it from
298-
TestPYPI. You can find the installation instructions on the TestPyPI
298+
TestPyPI. You can find the installation instructions on the TestPyPI
299299
landing page for your newly uploaded package.
300300

301301
:::{figure-md} testpypi-landing-page

0 commit comments

Comments
 (0)