python-code-quality

Demo code for the "Code Quality in Python" Talk

https://github.com/claasrostock/python-code-quality

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (15.5%) to scientific vocabulary
Last synced: 10 months ago · JSON representation ·

Repository

Demo code for the "Code Quality in Python" Talk

Basic Info
  • Host: GitHub
  • Owner: ClaasRostock
  • License: mit
  • Language: Python
  • Default Branch: main
  • Size: 335 KB
Statistics
  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • Open Issues: 0
  • Releases: 1
Created over 3 years ago · Last pushed 10 months ago
Metadata Files
Readme Changelog License Citation

README.md

pypi versions license ci docs

python-code-quality

python-code-quality is an example package containing demo code for the Python Code Quality talk.

Installation

sh pip install python-code-quality

Usage Example

API:

py from python_code_quality import ...

CLI:

sh python-code-quality ...

For more examples and usage, please refer to python-code-quality's documentation.

Development Setup

1. Install uv

This project uses uv as package manager. If you haven't already, install uv, preferably using it's "Standalone installer" method:
..on Windows: sh powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex" ..on MacOS and Linux: sh curl -LsSf https://astral.sh/uv/install.sh | sh (see docs.astral.sh/uv for all / alternative installation methods.)

Once installed, you can update uv to its latest version, anytime, by running: sh uv self update

2. Install Python

This project requires Python 3.10 or later.
If you don't already have a compatible version installed on your machine, the probably most comfortable way to install Python is through uv: sh uv python install This will install the latest stable version of Python into the uv Python directory, i.e. as a uv-managed version of Python.

Alternatively, and if you want a standalone version of Python on your machine, you can install Python either via winget: sh winget install --id Python.Python or you can download and install Python from the python.org website.

3. Clone the repository

Clone the python-code-quality repository into your local development directory: sh git clone https://github.com/ClaasRostock/python-code-quality path/to/your/dev/python-code-quality Change into the project directory after cloning: sh cd python-code-quality

4. Install dependencies

Run uv sync to create a virtual environment and install all project dependencies into it: sh uv sync

Note: Using --no-dev will omit installing development dependencies.

Note: uv will create a new virtual environment called .venv in the project root directory when running uv sync the first time. Optionally, you can create your own virtual environment using e.g. uv venv, before running uv sync.

5. (Optional) Install CUDA support

Run uv sync with option --extra cuda to in addition install torch with CUDA support: sh uv sync --extra cuda

Alternatively, you can manually install torch with CUDA support. Note 1: Do this preferably after running uv sync. That way you ensure a virtual environment exists, which is a prerequisite before you install torch with CUDA support using below uv pip install command.

To manually install torch with CUDA support, generate a uv pip install command matching your local machine's operating system using the wizard on the official PyTorch website. Note: As we use uv as package manager, remember to replace pip in the command generated by the wizard with uv pip.

If you are on Windows, the resulting uv pip install command will most likely look something like this: sh uv pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124

Hint: If you are unsure which cuda version to indicate in above uv pip install .. /cuXXX command, you can use the shell command nvidia-smi on your local system to find out the cuda version supported by the current graphics driver installed on your system. When then generating the uv pip install command with the wizard from the PyTorch website, select the cuda version that matches the major version of what your graphics driver supports (major version must match, minor version may deviate).

6. (Optional) Activate the virtual environment

When using uv, there is in almost all cases no longer a need to manually activate the virtual environment.
uv will find the .venv virtual environment in the working directory or any parent directory, and activate it on the fly whenever you run a command via uv inside your project folder structure: sh uv run <command>

However, you still can manually activate the virtual environment if needed. When developing in an IDE, for instance, this can in some cases be necessary depending on your IDE settings. To manually activate the virtual environment, run one of the "known" legacy commands:
..on Windows: sh .venv\Scripts\activate.bat ..on Linux: sh source .venv/bin/activate

7. Install pre-commit hooks

The .pre-commit-config.yaml file in the project root directory contains a configuration for pre-commit hooks. To install the pre-commit hooks defined therein in your local git repository, run: sh uv run pre-commit install

All pre-commit hooks configured in .pre-commit-config.yaml will now run each time you commit changes.

pre-commit can also manually be invoked, at anytime, using: sh uv run pre-commit run --all-files

To skip the pre-commit validation on commits (e.g. when intentionally committing broken code), run: sh uv run git commit -m <MSG> --no-verify

To update the hooks configured in .pre-commit-config.yaml to their newest versions, run: sh uv run pre-commit autoupdate

8. Test that the installation works

To test that the installation works, run pytest in the project root folder: sh uv run pytest

Meta

Copyright (c) 2025 Claas Rostock

Claas Rostock - @LinkedIn - claas.rostock@dnv.com

Distributed under the MIT license. See LICENSE for more information.

https://github.com/ClaasRostock/

Contributing

  1. Fork it (https://github.com/ClaasRostock/python-code-quality/fork)
  2. Create an issue in your GitHub repo
  3. Create your branch based on the issue number and type (git checkout -b issue-name)
  4. Evaluate and stage the changes you want to commit (git add -i)
  5. Commit your changes (git commit -am 'place a descriptive commit message here')
  6. Push to the branch (git push origin issue-name)
  7. Create a new Pull Request in GitHub

For your contribution, please make sure you follow the STYLEGUIDE before creating the Pull Request.

Owner

  • Name: Claas Rostock
  • Login: ClaasRostock
  • Kind: user

Citation (CITATION.cff)

title: python-code-quality
version: 0.2.0
abstract: >-
    demo code for the Code Quality in Python talk.
type: software
authors:
    - name: DNV AS
      address: 'Veritasveien 1'
      post-code: '1363'
      city: Høvik
      country: NO
      website: 'https://www.dnv.com/'
    - given-names: Author
      family-names: One
      affiliation: DNV
      email: claas.rostock@dnv.com
      website: 'https://www.linkedin.com/in/claasrostock/?locale=en_US'
    - given-names: Author
      family-names: Two
      affiliation: DNV
      email:
      website: ''
    - given-names: Author
      family-names: Three
      affiliation: DNV
      email:
      website: ''
keywords:
    - Python
    - Code
    - Quality
license: MIT
license-url: 'https://ClaasRostock.github.io/python-code-quality/LICENSE.html'
url: 'https://ClaasRostock.github.io/python-code-quality/README.html'
repository-code: 'https://github.com/ClaasRostock/python-code-quality'
message: 'Please cite this software using these metadata.'
cff-version: 1.2.0

GitHub Events

Total
  • Delete event: 2
  • Issue comment event: 2
  • Push event: 137
  • Pull request review event: 2
  • Pull request review comment event: 7
  • Pull request event: 2
  • Create event: 1
Last Year
  • Delete event: 2
  • Issue comment event: 2
  • Push event: 137
  • Pull request review event: 2
  • Pull request review comment event: 7
  • Pull request event: 2
  • Create event: 1

Committers

Last synced: 11 months ago

All Time
  • Total Commits: 56
  • Total Committers: 2
  • Avg Commits per committer: 28.0
  • Development Distribution Score (DDS): 0.179
Past Year
  • Commits: 44
  • Committers: 1
  • Avg Commits per committer: 44.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Claas c****k@d****m 46
Claas c****k@d****m 10
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 11 months ago

All Time
  • Total issues: 0
  • Total pull requests: 3
  • Average time to close issues: N/A
  • Average time to close pull requests: 19 minutes
  • Total issue authors: 0
  • Total pull request authors: 1
  • Average comments per issue: 0
  • Average comments per pull request: 1.0
  • Merged pull requests: 3
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 3
  • Average time to close issues: N/A
  • Average time to close pull requests: 19 minutes
  • Issue authors: 0
  • Pull request authors: 1
  • Average comments per issue: 0
  • Average comments per pull request: 1.0
  • Merged pull requests: 3
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
  • ClaasRostock (5)
Top Labels
Issue Labels
Pull Request Labels

Dependencies

pyproject.toml pypi
.github/workflows/_build_and_publish_documentation.yml actions
  • actions/checkout v4 composite
  • actions/setup-python v5 composite
  • astral-sh/setup-uv v5 composite
  • peaceiris/actions-gh-pages v4 composite
  • sphinx-doc/github-problem-matcher master composite
.github/workflows/_build_package.yml actions
  • actions/checkout v4 composite
  • actions/setup-python v5 composite
  • actions/upload-artifact v4 composite
  • astral-sh/setup-uv v5 composite
.github/workflows/_code_quality.yml actions
  • actions/checkout v4 composite
  • actions/setup-python v5 composite
  • astral-sh/setup-uv v5 composite
.github/workflows/_merge_into_release.yml actions
  • actions/checkout v4 composite
  • devmasx/merge-branch v1.4.0 composite
.github/workflows/_test.yml actions
  • actions/checkout v4 composite
  • actions/setup-python v5 composite
  • astral-sh/setup-uv v5 composite
.github/workflows/_test_future.yml actions
  • actions/checkout v4 composite
  • actions/setup-python v5 composite
  • astral-sh/setup-uv v5 composite
.github/workflows/nightly_build.yml actions
.github/workflows/publish_release.yml actions
  • actions/download-artifact v4 composite
  • pypa/gh-action-pypi-publish release/v1 composite
.github/workflows/pull_request_to_main.yml actions
.github/workflows/push.yml actions
.github/workflows/push_to_main.yml actions
.github/workflows/push_to_release.yml actions