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

Deprecated Plugin #1

Merged
merged 22 commits into from
Mar 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ max_line_length = 88
[*.md]
indent_style = space
indent_size = 2

[*.ini]
indent_style = space
indent_size = 4
26 changes: 26 additions & 0 deletions .github/actions/setup-env/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: "Setup the whole env"
description: "Setup the env with packages"
branding:
icon: box
color: gray-dark
inputs:
python-version:
description: "Version of Python to install"
required: true
poetry-version:
description: "Version of Poetry to install"
required: false
default: "1.8.2"
runs:
using: composite
steps:
- run: pipx install poetry==${{ inputs.poetry-version }}
shell: bash
- run: poetry lock
shell: bash
- uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
cache: poetry
- run: poetry install --with dev --no-interaction --no-ansi
shell: bash
32 changes: 32 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Build
on:
workflow_call:
inputs:
os:
required: true
type: string
python-version:
required: true
type: string
poetry-version:
required: true
type: string
jobs:
quality:
runs-on: ${{ inputs.os }}
name: Build (${{ inputs.os }}, python${{ inputs.python-version }})
steps:
- name: Synchronize repository
uses: actions/checkout@v4
- name: Setup Python ${{ inputs.python-version }} with Poetry ${{ inputs.poetry-version }}
uses: ./.github/actions/setup-env
with:
python-version: ${{ inputs.python-version }}
poetry-version: ${{ inputs.poetry-version }}
- name: Build
run: poetry build -f wheel
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: release-dists
path: dist/
62 changes: 62 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: CI/CD
on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+"
pull_request: {}
jobs:
quality:
name: Quality (python${{ matrix.python-version }})
uses: ./.github/workflows/quality.yaml
if: github.event_name == 'pull_request'
strategy:
fail-fast: false
matrix:
python-version: ["3.8"]
with:
os: "ubuntu-latest"
python-version: ${{ matrix.python-version }}
poetry-version: "1.8.2"
test:
name: Test (python${{ matrix.python-version }})
uses: ./.github/workflows/test.yaml
if: github.event_name == 'pull_request'
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
with:
os: "ubuntu-latest"
python-version: ${{ matrix.python-version }}
poetry-version: "1.8.2"
build:
name: Build (python${{ matrix.python-version }})
uses: ./.github/workflows/build.yaml
if: github.event_name != 'pull_request' && !(failure() || cancelled())
needs:
- quality
- test
strategy:
fail-fast: false
matrix:
python-version: ["3.8"]
with:
os: "ubuntu-latest"
python-version: ${{ matrix.python-version }}
poetry-version: "1.8.2"
publish:
name: Publish (python${{ matrix.python-version }})
uses: ./.github/workflows/publish.yaml
if: github.event_name != 'pull_request' && !(failure() || cancelled())
needs:
- build
permissions:
id-token: write
strategy:
fail-fast: false
matrix:
python-version: ["3.8"]
with:
os: "ubuntu-latest"
python-version: ${{ matrix.python-version }}
poetry-version: "1.8.2"
34 changes: 34 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Publish
on:
workflow_call:
inputs:
os:
required: true
type: string
python-version:
required: true
type: string
poetry-version:
required: true
type: string
jobs:
quality:
runs-on: ${{ inputs.os }}
name: Publish (${{ inputs.os }}, python${{ inputs.python-version }})
environment:
name: release
steps:
- name: Synchronize repository
uses: actions/checkout@v4
- name: Setup Python ${{ inputs.python-version }} with Poetry ${{ inputs.poetry-version }}
uses: ./.github/actions/setup-env
with:
python-version: ${{ inputs.python-version }}
poetry-version: ${{ inputs.poetry-version }}
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: release-dists
path: dist/
- name: Publish library
uses: pypa/gh-action-pypi-publish@release/v1
31 changes: 31 additions & 0 deletions .github/workflows/quality.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Quality
on:
workflow_call:
inputs:
os:
required: true
type: string
python-version:
required: true
type: string
poetry-version:
required: true
type: string
jobs:
quality:
runs-on: ${{ inputs.os }}
name: Quality (${{ inputs.os }}, python${{ inputs.python-version }})
steps:
- name: Synchronize repository
uses: actions/checkout@v4
- name: Setup Python ${{ inputs.python-version }} with Poetry ${{ inputs.poetry-version }}
uses: ./.github/actions/setup-env
with:
python-version: ${{ inputs.python-version }}
poetry-version: ${{ inputs.poetry-version }}
- name: Check Python formatting
run: poetry run black .
- name: Check Python code
run: poetry run ruff check --force-exclude .
- name: Check Python typing
run: poetry run mypy --ignore-missing-imports --scripts-are-modules .
27 changes: 27 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Test
on:
workflow_call:
inputs:
os:
required: true
type: string
python-version:
required: true
type: string
poetry-version:
required: true
type: string
jobs:
quality:
runs-on: ${{ inputs.os }}
name: Test (${{ inputs.os }}, python${{ inputs.python-version }})
steps:
- name: Synchronize repository
uses: actions/checkout@v4
- name: Setup Python ${{ inputs.python-version }} with Poetry ${{ inputs.poetry-version }}
uses: ./.github/actions/setup-env
with:
python-version: ${{ inputs.python-version }}
poetry-version: ${{ inputs.poetry-version }}
- name: Run tests
run: poetry run python -m pytest --cov=src/mypypp tests
94 changes: 94 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
minimum_pre_commit_version: 3.3.2
fail_fast: true
default_language_version:
python: python3.8
default_stages:
- manual
- pre-commit
- pre-push
- post-merge
default_install_hook_types:
- pre-commit
- post-checkout
- post-merge

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-added-large-files
- id: check-toml
- id: check-yaml
args:
- --allow-multiple-documents
- id: check-merge-conflict
- id: check-symlinks
- id: destroyed-symlinks
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable
- id: detect-private-key
- id: end-of-file-fixer
- id: trailing-whitespace
- id: fix-encoding-pragma
args:
- --remove
- id: name-tests-test
- id: no-commit-to-branch
args:
- --branch=main
- repo: https://gitlab.com/bmares/check-json5
rev: v1.0.0
hooks:
- id: check-json5
- repo: local
hooks:
- id: black
name: black
entry: poetry run black
args: ["--check"]
language: python
types_or: [python, pyi]
require_serial: true
- id: ruff
name: ruff
entry: poetry run ruff check
args: ["--force-exclude"]
language: python
types_or: [python, pyi]
require_serial: true
- id: mypy
name: mypy
entry: poetry run mypy
args: ["--ignore-missing-imports", "--scripts-are-modules"]
language: python
types_or: [python, pyi]
require_serial: true
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.1.0
hooks:
- id: prettier
alias: prettier-check
name: prettier (json, markdown & yaml)
entry: prettier --check --ignore-unknown
files: "\\.(json|md|yaml|yml)$"
- repo: https://github.com/python-poetry/poetry
rev: 1.8.2
hooks:
- id: poetry-check
name: poetry check
args:
- --lock
- id: poetry-install
name: poetry install
args:
- --with
- dev
- repo: local
hooks:
- id: forbid-yml-file
name: no .yml extension
entry: Yaml file must have the .yaml extension
language: fail
files: ".*\\.yml"
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

- Mypy plugin to check for `warnings.deprecated` (or `typing_extensions.deprecated`) decorator on functions, methods and classes. Add `"mypypp.deprecated"` to `plugins` MyPy configuration to use it.

[Unreleased]: https://github.com/bendabir/mypypp/compare/0.1.0...main
[0.1.0]: https://github.com/bendabir/mypypp/tree/0.1.0
Loading