Skip to content

Commit 596c3d0

Browse files
committed
Fix: general cleanup of syntax, sphinx warnings
1 parent ce38ab7 commit 596c3d0

9 files changed

+33
-50
lines changed

package-structure-code/code-style-linting-format.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# Python Package Code Style, Format and Linters
22

3-
```{important}
4-
5-
## Take Aways
3+
```{admonition} Take Aways
64
75
* pyOpenSci requires authors to follow PEP 8 code format guidelines
86
* Setting up a code formatters like Black and isort will help you enforce PEP 8 style guidelines and also consistent, readable code format
@@ -96,7 +94,6 @@ some exceptions. A few examples of those exceptions are below:
9694
- Black will not adjust line length in your comments or docstrings.
9795
- This tool will not review and fix import order (you need _isort_ or _Ruff_ to do that - see below).
9896

99-
10097
```{tip}
10198
If you are interested in seeing how Black will format your code, you can
10299
use the [Black playground](https://black.vercel.app/)
@@ -205,6 +202,7 @@ gaining some traction since its release.
205202
As such, `ruff` can be used instead of `flake8` and `isort`.
206203

207204
`ruff` has some interesting features that distinguish it from other linters:
205+
208206
- Linter configuration in `pyproject.toml`
209207
- Several hundred rules included, many of which are automatically fixable
210208
- Rules explanation, see [F403](https://beta.ruff.rs/docs/rules/undefined-local-with-import-star/) for an example
@@ -236,7 +234,6 @@ Depending on your project, you might want to add the following to sort imports c
236234
known-first-party = ["<package_folder>"]
237235
```
238236

239-
240237
## How to use code formatter in your local workflow
241238

242239
### Linters, code formatters and your favorite coding tools
@@ -277,7 +274,7 @@ You type and run:
277274
- Once all of the fixes are applied you can re-add (stage) the files to be
278275
commit. And re-run your commit.
279276

280-
:::{figure-md} fig-target
277+
:::{figure-md} precommit-hook
281278
<img src="../images/precommit-hook-python-code.png" alt="Diagram showing the steps of a pre-commit workflow from left to right." width="700px">
282279

283280
The pre-commit workflow begins with you adding files that have changes to be

package-structure-code/intro.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ package follows best practices for code format? Learn more about the options and
5555
:::
5656
::::
5757

58-
:::{figure-md} fig-target
58+
:::{figure-md} packaging-tools-decision-tree
5959

6060
<img src="../images/python-package-tools-decision-tree.png" alt="Figure showing a decision tree with the various packaging tool front-end and back-end options." width="700px">
6161

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
<!--todo: add as resource https://docs.conda.io/projects/conda/en/latest/glossary.html -->
44

5-
pyOpenSci requires that your package has an distribution that can be installed from a public community repository such as PyPI or a conda channel such as `bioconda` or `conda-forge` in the Anaconda cloud.
5+
pyOpenSci requires that your package has an distribution that can be installed
6+
from a public community repository such as PyPI or a conda channel such as
7+
`bioconda` or `conda-forge` in the Anaconda cloud.
68

79
Below you will learn more about the various publishing options for your Python
810
package.
911

10-
```{important}
11-
## Take Aways
12+
```{admonition} Take Aways
1213
1314
* Installing packages in the same environment using both pip and conda can
1415
lead to package conflicts.
@@ -17,7 +18,7 @@ lead to package conflicts.
1718
Below you will learn more specifics about the differences between PyPI and conda publishing of your Python package.
1819
```
1920

20-
### What is PyPI
21+
## What is PyPI
2122

2223
[PyPI](https://pypi.org/) is an online Python package repository that
2324
you can use to both find and install and publish your Python package. There is
@@ -31,17 +32,15 @@ a package is that conda can install any package regardless
3132
of the language(s) that it is written in. Whereas `pip` can
3233
only install Python packages.
3334

34-
<!-- TODO add link to build page below when this page is published -->
35-
3635
```{tip}
3736
On the package build page, we discussed the [two package distribution
38-
types that you will create when making a Python package](link-to-page-on-sdist): SDist (packaged as a .tar.gz or .zip) and
37+
types that you will create when making a Python package](python-package-distribution-files-sdist-wheel): SDist (packaged as a .tar.gz or .zip) and
3938
Wheel (.whl) which is really a zip file. Both of those file "bundles" will
40-
be published on PyPI when you use [a standard build tool](link-to-build-page) to build
39+
be published on PyPI when you use [a standard build tool](python-package-build-tools) to build
4140
your package.
4241
```
4342

44-
### What is Anaconda Cloud and conda?
43+
## What is Anaconda Cloud and conda?
4544

4645
conda is an open source package and environment management tool.
4746
conda can be used to install tools from the [Anaconda Cloud
@@ -61,7 +60,8 @@ While conda was originally created to support Python packages, it
6160
is now used across all languages. This cross-language support
6261
makes it easier for some packages to include and have access to
6362
tools written in other languages such as c/c++ (gdal), Julia, or R.
64-
Creating environment that mixes all those packages are usually easier and more consistent with full fledged package managers like conda.
63+
Creating environment that mixes all those packages are usually easier and more
64+
consistent with full fledged package managers like conda.
6565
```
6666

6767
### conda channels
@@ -79,7 +79,7 @@ packages using conda including.
7979
**conda-forge** emerged as many of the scientific packages did not
8080
exist in the default Anaconda cloud channel.
8181

82-
:::{figure-md} fig-target
82+
:::{figure-md} conda-channels
8383

8484
<img src="../images/conda-channels-geohackweek.jpeg" alt="ADD." width="700px">
8585

@@ -96,7 +96,7 @@ repository to publish your Python package.
9696

9797
The answer to both questions relates dependency conflicts.
9898

99-
:::{figure-md} fig-target
99+
:::{figure-md} xkcd-dep-conflict
100100

101101
<img src="../images/python-dependency-conflicts-xkcd.png" alt="Image showing an XKCD comic that shows a web of Python environments and tools and installations. At the bottom is says - My python environment has become so degraded that my laptop has been declared a superfund site." width="700px">
102102

@@ -130,7 +130,7 @@ to use conda to manage their local environments (which many do), you should
130130
consider publishing to both PyPI and the conda-forge channel (_more
131131
on that below_).
132132

133-
```{tip}
133+
```{admonition} Additional resources
134134
* [learn more about why conda-forge was created, here](https://conda-forge.org/docs/user/introduction.html#why-conda-forge)
135135
136136
* [To learn more about conda terminology, check out their glossary.](https://docs.conda.io/projects/conda/en/latest/glossary.html )

package-structure-code/pyproject-toml-python-package-metadata.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ The **pyproject.toml** file is written in [TOML (Tom's Obvious, Minimal Language
99
Below that table identifier are key/value pairs that
1010
support configuration for that particular table.
1111

12-
### Benefits of using a pyproject.toml file
12+
## Benefits of using a pyproject.toml file
1313

1414
Including your package's metadata in a separate human-readable **pyproject.toml**
1515
format also allows someone to view the project's metadata in a GitHub repository.
@@ -29,7 +29,7 @@ resources working with complex builds in the future.
2929

3030
```
3131

32-
### Example pyproject.toml for building using PDM
32+
## Example pyproject.toml for building using PDM
3333

3434
Below is an example build configuration for a Python project. This example
3535
package setup uses:
@@ -65,7 +65,7 @@ dependencies = [
6565

6666
Notice that dependencies are specified in this file.
6767

68-
### Example pyproject.toml for building using setuptools
68+
## Example pyproject.toml for building using setuptools
6969

7070
The package metadata including authors, keywords, etc is also easy to read.
7171
Below you can see the same TOML file that uses a different build system (setuptools).

package-structure-code/python-package-build-tools.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ We focus on pure-python packages in this guide. However, we also
88
highlight tools that currently support packages with C/C++ and other language
99
extensions.
1010

11-
:::{figure-md} fig-target
11+
:::{figure-md} package-decision-tree
1212

1313
<img src="../images/python-package-tools-decision-tree.png" alt="Decision tree diagram showing the various front and back end packaging tools. You can decide what packaging tool to use by thinking about what features you need. PDM is currently the most flexible tool that also supports both non pure Python projects and also using different build back-ends. As such currently PDM is the tool we think beginners might appreciate most with Poetry being a close second. Poetry is ideal for pure python projects." width="700px">
1414

@@ -19,7 +19,7 @@ NOTE: this is still a DRAFT so i'm not going to spend time truly cleaning it up
1919
If you want to know more about Python packages that have extensions written in
2020
other languages, [check out the page on complex package builds.](complex-python-package-builds)
2121

22-
### Tools that we review here
22+
## Tools that we review here
2323

2424
In this section we have selected tools that were returned
2525
as the most popular packaging tools in the PyPA survey.
@@ -31,7 +31,7 @@ You will learn more about the following tools on this page:
3131
- [PDM](https://pdm.fming.dev/latest/)
3232
- [Poetry](https://python-poetry.org/docs/)
3333

34-
### Summary of tools Hatch vs. PDM vs. Poetry (and setuptools)
34+
## Summary of tools Hatch vs. PDM vs. Poetry (and setuptools)
3535

3636
If you are looking for a quick summary, read below.
3737

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Also note that we are not discussing conda build workflows in this section.
1818
[You can learn more about conda builds here.](https://conda.io/projects/conda-build/en/latest/user-guide/tutorials/index.html)
1919
```
2020

21-
### Source Distribution (sdist)
21+
## Source Distribution (sdist)
2222

2323
**Source files** are the unbuilt files needed to build your
2424
package. These are the "raw / as-is" files that you store on GitHub or whatever
@@ -91,7 +91,7 @@ items including a metadata directory and if you use `setuptools_scm` or `hatch_v
9191
the SDist may also contain a file that stores the version.
9292
```
9393

94-
### Wheel (.whl files):
94+
## Wheel (.whl files):
9595

9696
A wheel file is a ZIP-format archive whose filename follows a specific format
9797
(below) and has the extension `.whl`. The `.whl` archive contains a specific

package-structure-code/python-package-structure.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ While we recommend the **src/** layout we also review the **flat** layout here.
7979
8080
```
8181

82-
### The src/ layout and testing
82+
## The src/ layout and testing
8383

8484
The benefit of using the **src/package** layout, particularly if you
8585
are creating a new package, is that it ensures tests are run against the
@@ -103,7 +103,7 @@ However, if your package lives in a src/ directory structure **src/package** the
103103
Note: Python versions 3.11 and above have a path setting that can be adjusted to ensure the priority is to use installed packages first (e.g. `PYTHONSAFEPATH`).
104104
```
105105

106-
#### Sometimes tests are needed in a distribution
106+
### Sometimes tests are needed in a distribution
107107

108108
We do not recommend including tests as part of your package wheel by default. However, not including tests in your package distribution will make it harder for people other than yourself to test whether your package is functioning correctly on their system. If you have a small test suite (Python files + data), and think your users may want to run tests locally on their systems, you can include tests by moving the `tests/` directory into the **src/package** directory (see example below).
109109

package-structure-code/python-package-versions.md

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
<!-- * mention release should be incremental
44
* rep changes in the code that are either patches, minor fixes, major updates -->
55

6-
```{important}
7-
## Key Takeways
6+
```{admonition} Key Takeways
87
98
* Follow [semantic versioning guidelines (SemVer) rules](https://semver.org/) when bumping (increasing) your Python's package version; for example a major version bump (version 1.0 --> 2.0) equates to breaking changes in your package's code for a user.
109
* You may want to consider using a plugin like hatch_vsc for managing versions of your package - if you want to have a GitHub only release workflow.
@@ -26,9 +25,7 @@ with how and when you update your package versions is important as:
2625
bump a package version based on standard rules.
2726
3. Consistent version increases following semver rules mean that values of your package version explain the extent of the changes made in the code base from version to version. thus your package version numbers become "expressive" in the same way that naming code variables well can [make code expressive](https://medium.com/@daniel.oliver.king/writing-expressive-code-b69ef7a5a2fa).
2827

29-
```{note}
30-
A note about versioning
31-
28+
```{admonition} A note about versioning
3229
In some cases even small version changes can turn a package update
3330
into a breaking change for some users. What is also important is that
3431
you document how you version your code and if you can, also
@@ -37,7 +34,7 @@ document your deprecation policy for code.
3734

3835
<!-- TODO: Better link to what expressive code is?-->
3936

40-
### SemVer rules
37+
## SemVer rules
4138

4239
Following SemVer, your bump your package version to a:
4340

@@ -63,7 +60,7 @@ pyOpenSci will never require semver in a peer review as long as a
6360
package has a reasonable approach to versioning!
6461
```
6562

66-
### Avoid manually updating Python package version numbers if you can
63+
## Avoid manually updating Python package version numbers if you can
6764

6865
Often times you may want to have your package version value in
6966
multiple locations. One example of this is that it might be both
@@ -86,8 +83,8 @@ Python package versions.
8683
## Tools to manage versions for your Python package
8784

8885
There are a handful of tools that are widely used in the scientific ecosystem that you can use to manage your package
89-
versions. Some of these tools are built into or work with your
90-
[packaging build tools that we discuss]()
86+
versions. Some of these tools are built into or work with your chosen
87+
[packaging build tools that discussed in this chapter.](python-package-build-tools)
9188

9289
<!-- TODO: ADD LINK when other pr merged -->
9390

python-packaging/intro.md

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)