Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

depending on newer dapla-toolbelt for dependabot #64

Merged
merged 15 commits into from
Apr 3, 2024
Merged
4 changes: 2 additions & 2 deletions .cruft.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"template": "https://github.com/statisticsnorway/ssb-pypitemplate.git",
"commit": "c2aa8500502801d19a2b4213db6f44ebfcc874f1",
"checkout": "2023.11.17",
"commit": "b427b1efa9bec3506a1fef209b456a8523c8e6bd",
"checkout": null,
"context": {
"cookiecutter": {
"project_name": "ssb-klass-python",
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/constraints.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pip==23.3.2
nox==2023.4.22
pip==24.0
nox==2024.3.2
nox-poetry==1.0.3
poetry==1.7.1
virtualenv==20.25.0
poetry==1.8.2
virtualenv==20.25.1
4 changes: 2 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- name: Set up Python
uses: actions/[email protected]
with:
python-version: "3.11"
python-version: "3.10"
cache: "poetry"

- name: Install dependencies
Expand All @@ -45,7 +45,7 @@ jobs:

- name: Build doc with Sphinx
run: |
poetry run sphinx-build -W docs docs/_build
poetry run sphinx-build docs docs/_build

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Set up Python
uses: actions/[email protected]
with:
python-version: "3.10"
python-version: "3.12"

- name: Upgrade pip
run: |
Expand All @@ -48,7 +48,7 @@ jobs:
bash -o pipefail -c "poetry version | cut -f 2 -d' '"

- name: Bump version for developmental release
if: "! steps.check-version.outputs.tag"
if: (!steps.check-version.outputs.tag)
run: |
poetry version patch &&
version=$(poetry version | awk '{ print $2 }') &&
Expand All @@ -60,16 +60,16 @@ jobs:

- name: Publish package on PyPI
if: steps.check-version.outputs.tag
uses: pypa/[email protected].11
uses: pypa/[email protected].14

- name: Publish package on TestPyPI
if: "! steps.check-version.outputs.tag"
uses: pypa/[email protected].11
if: (! steps.check-version.outputs.tag)
uses: pypa/[email protected].14
with:
repository-url: https://test.pypi.org/legacy/

- name: Publish the release notes
uses: release-drafter/release-drafter@v5.25.0
uses: release-drafter/release-drafter@v6.0.0
with:
publish: ${{ steps.check-version.outputs.tag != '' }}
tag: ${{ steps.check-version.outputs.tag }}
Expand Down
23 changes: 14 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@ jobs:
matrix:
include:
- { python: "3.10", os: "ubuntu-latest", session: "pre-commit" }
- { python: "3.11", os: "ubuntu-latest", session: "mypy" }
- { python: "3.10", os: "ubuntu-latest", session: "mypy" }
- { python: "3.11", os: "ubuntu-latest", session: "tests" }
- { python: "3.11", os: "ubuntu-latest", session: "mypy" }
- { python: "3.12", os: "ubuntu-latest", session: "mypy" }
- { python: "3.10", os: "ubuntu-latest", session: "tests" }
- { python: "3.11", os: "windows-latest", session: "tests" }
- { python: "3.11", os: "macos-latest", session: "tests" }
- { python: "3.11", os: "ubuntu-latest", session: "tests" }
- { python: "3.12", os: "ubuntu-latest", session: "tests" }
- { python: "3.12", os: "windows-latest", session: "tests" }
- { python: "3.12", os: "macos-latest", session: "tests" }
- { python: "3.10", os: "ubuntu-latest", session: "typeguard" }
- { python: "3.11", os: "ubuntu-latest", session: "xdoctest" }
- { python: "3.10", os: "ubuntu-latest", session: "xdoctest" }
- { python: "3.10", os: "ubuntu-latest", session: "docs-build" }

env:
Expand Down Expand Up @@ -98,7 +100,7 @@ jobs:
if: always() && matrix.session == 'tests'
uses: "actions/upload-artifact@v4"
with:
name: coverage-data
name: coverage-data-${{ matrix.os }}-${{ matrix.python }}
path: ".coverage.*"

- name: Upload documentation
Expand All @@ -120,7 +122,7 @@ jobs:
- name: Set up Python
uses: actions/[email protected]
with:
python-version: "3.11"
python-version: "3.12"

- name: Upgrade pip
run: |
Expand All @@ -141,7 +143,8 @@ jobs:
- name: Download coverage data
uses: actions/download-artifact@v4
with:
name: coverage-data
pattern: coverage-data-*
merge-multiple: true

- name: Combine coverage data and display human readable report
run: |
Expand All @@ -154,7 +157,9 @@ jobs:
# Need to fix coverage source paths for SonarCloud scanning in GitHub actions.
# Replace root path with /github/workspace (mounted in docker container).
- name: Override coverage source paths for SonarCloud
run: sed -i "s/<source>\/home\/runner\/work\/ssb-klass-python\/ssb-klass-python/<source>\/github\/workspace/g" coverage.xml
run: |
sed -i "s/<source><\/source>/<source>\/github\/workspace<\/source>/g" coverage.xml
sed -i "s/<source>tests/<source>\/github\/workspace\/tests/g" coverage.xml

- name: SonarCloud Scan
env:
Expand Down
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,24 @@ venv.bak/
# Spyder project settings
.spyderproject
.spyproject
/.python-version

/.pytype/
/docs/_build/

# Visual Studio Code
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets
# Local History for Visual Studio Code
.history/
# Built Visual Studio Code Extensions
*.vsix



# Rope project settings
.ropeproject
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ repos:
stages: [manual]
- id: ruff
name: ruff
entry: ruff --fix --exit-non-zero-on-fix
entry: ruff check --fix --exit-non-zero-on-fix
language: system
types_or: [python, jupyter]
require_serial: true
Expand Down
65 changes: 44 additions & 21 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ Here is a list of important resources for contributors:
- [Issue Tracker]
- [Code of Conduct]

[mit license]: https://opensource.org/licenses/MIT
[source code]: https://github.com/statisticsnorway/ssb-klass-python
[documentation]: https://ssb-klass-python.readthedocs.io/
[issue tracker]: https://github.com/statisticsnorway/ssb-klass-python/issues

## How to report a bug

Report bugs on the [Issue Tracker].
Expand All @@ -37,56 +32,75 @@ Request features on the [Issue Tracker].

## How to set up your development environment

You need Python 3.9+ and the following tools:
You need Python 3.10+ and the following tools:

- [Poetry]
- [Nox]
- [nox-poetry]

Install the package with development requirements:
Install [pipx]:

```console
$ poetry install
python -m pip install --user pipx
python -m pipx ensurepath
```

You can now run an interactive Python session,
or the command-line interface:
Install [Poetry]:

```console
$ poetry run python
$ poetry run ssb-klass-python
pipx install poetry
```

[poetry]: https://python-poetry.org/
[nox]: https://nox.thea.codes/
[nox-poetry]: https://nox-poetry.readthedocs.io/
Install [Nox] and [nox-poetry]:

```console
pipx install nox
pipx inject nox nox-poetry
```

Install the pre-commit hooks

```console
nox --session=pre-commit -- install
```

Install the package with development requirements:

```console
poetry install
```

You can now run an interactive Python session, or your app:

```console
poetry run python
poetry run ssb-klass-python
```

## How to test the project

Run the full test suite:

```console
$ nox
nox
```

List the available Nox sessions:

```console
$ nox --list-sessions
nox --list-sessions
```

You can also run a specific Nox session.
For example, invoke the unit test suite like this:

```console
$ nox --session=tests
nox --session=tests
```

Unit tests are located in the _tests_ directory,
and are written using the [pytest] testing framework.

[pytest]: https://pytest.readthedocs.io/

## How to submit changes

Open a [pull request] to submit changes to this project.
Expand All @@ -102,12 +116,21 @@ Feel free to submit early, though—we can always iterate on this.
To run linting and code formatting checks before committing your change, you can install pre-commit as a Git hook by running the following command:

```console
$ nox --session=pre-commit -- install
nox --session=pre-commit -- install
```

It is recommended to open an issue before starting work on anything.
This will allow a chance to talk it over with the owners and validate your approach.

[mit license]: https://opensource.org/licenses/MIT
[source code]: https://github.com/statisticsnorway/ssb-klass-python
[documentation]: https://statisticsnorway.github.io/ssb-klass-python
[issue tracker]: https://github.com/statisticsnorway/ssb-klass-python/issues
[pipx]: https://pipx.pypa.io/
[poetry]: https://python-poetry.org/
[nox]: https://nox.thea.codes/
[nox-poetry]: https://nox-poetry.readthedocs.io/
[pytest]: https://pytest.readthedocs.io/
[pull request]: https://github.com/statisticsnorway/ssb-klass-python/pulls

<!-- github-only -->
Expand Down
1 change: 1 addition & 0 deletions demo/gui_ipywidgets.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"outputs": [],
"source": [
"import klass\n",
"\n",
"klass.search_classification()"
]
},
Expand Down
1 change: 0 additions & 1 deletion demo/quarter_seb.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
},
"outputs": [],
"source": [
"from datetime import datetime\n",
"\n",
"from klass import KlassCorrespondence"
]
Expand Down
1 change: 1 addition & 0 deletions demo/version.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
"outputs": [],
"source": [
"import pandas as pd\n",
"\n",
"df = pd.DataFrame({\"nus2000\": [\"099999\", \"899903\"]})\n",
"df[\"isced_label\"] = df[\"nus2000\"].map(nus_isced_map)\n",
"df"
Expand Down
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Sphinx configuration."""

# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
Expand Down
3 changes: 2 additions & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Nox sessions."""

import os
import shlex
import shutil
Expand All @@ -22,7 +23,7 @@
raise SystemExit(dedent(message)) from None

package = "klass"
python_versions = ["3.10", "3.11"]
python_versions = ["3.10", "3.11", "3.12"]
nox.needs_version = ">= 2021.6.6"
nox.options.sessions = (
"pre-commit",
Expand Down
Loading