Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jonghwanhyeon committed Jul 31, 2024
0 parents commit 2756bce
Show file tree
Hide file tree
Showing 26 changed files with 1,078 additions and 0 deletions.
132 changes: 132 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
name: Publish 📡 Python 🐍 distributions 📦

on:
push:
tags:
- v*

jobs:
lint:
name: Lint 🧹 and Check 🧐 Python 🐍 package 🗂️
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Setup 🛠️ Python 🐍
uses: actions/setup-python@v5
with:
python-version: "3.x"

- name: Install 🛠️ dependencies 📚
run: |
pip install --upgrade pip
pip install --requirement=requirements-dev.txt
- name: Lint 🧹 with Ruff ⚡️
run: ruff check --output-format=github .

- name: Check 🧐 with mypy 👐🐍
run: mypy --package="griffe_generics"

test:
name: Test 🔍 package 🗂️
needs: [lint]
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4

- name: Setup 🛠️ Python 🐍
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install 🛠️ dependencies 📚
run: |
pip install --upgrade pip
pip install --requirement=requirements.txt --requirement=tests/requirements.txt
- name: Run ⏱️ tests 📊
run: pytest

build:
name: Build 🏗️ distributions 📦
needs: [test]
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Setup 🛠️ Python 🐍
uses: actions/setup-python@v5
with:
python-version: "3.x"

- name: Build 🏗️ a source distribution 🗃️ and a binary wheel 🛞
run: pipx run build --outdir=distributions

- name: Upload 📤 the built distributions 📦
uses: actions/upload-artifact@v4
with:
name: distributions
path: distributions/

publish-to-pypi:
name: Publish 📡 Python 🐍 distributions 📦 to PyPI 🌐
needs: [build]
runs-on: ubuntu-latest
environment:
name: release
url: https://pypi.org/p/griffe-generics
permissions:
id-token: write

steps:
- name: Download 📥 all the distributions 📦
uses: actions/download-artifact@v4
with:
pattern: distributions
path: distributions/
merge-multiple: true

- name: Publish 📡 distributions 📦 to PyPI 🌐
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: distributions/

upload-to-github-release:
name: Upload 📤 Python 🐍 distributions 📦 to GitHub Release 🚀
needs: [publish-to-pypi]
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write

steps:
- name: Download 📥 all the distributions 📦
uses: actions/download-artifact@v4
with:
pattern: distributions
path: distributions/
merge-multiple: true

- name: Sign 🔑 the distributions 📦 with Sigstore
uses: sigstore/gh-action-sigstore-python@v3.0.0
with:
inputs: |
distributions/*.tar.gz
distributions/*.whl
- name: Create 📂 GitHub Release 🚀
env:
GITHUB_TOKEN: ${{ github.token }}
run: gh release --repo="${{ github.repository }}" create "${{ github.ref_name }}"

- name: Upload 📤 distributions 📦 and signatures 🔏 to GitHub Release 🚀
env:
GITHUB_TOKEN: ${{ github.token }}
run: gh release --repo="${{ github.repository }}" upload "${{ github.ref_name }}" distributions/**
209 changes: 209 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
# Created by https://www.toptal.com/developers/gitignore/api/python,macos
# Edit at https://www.toptal.com/developers/gitignore?templates=python,macos

### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### macOS Patch ###
# iCloud generated files
*.icloud

### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

### Python Patch ###
# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
poetry.toml

# ruff
.ruff_cache/

# LSP config files
pyrightconfig.json

# End of https://www.toptal.com/developers/gitignore/api/python,macos
7 changes: 7 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2024 Jonghwan Hyeon

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# griffe-generics
![Build status](https://github.com/jonghwanhyeon/griffe-generics/actions/workflows/publish.yml/badge.svg)

A Griffe extension that resolves generic type parameters as bound types in subclasses

## Example
Without extension:
![Without Extension](https://github.com/jonghwanhyeon/griffe-generics/raw/main/assets/without-extension.png)

With extension:
![With Extension](https://github.com/jonghwanhyeon/griffe-generics/raw/main/assets/without-extension.png)

## Install
To install **griffe-generics**, simply use pip:

```console
$ pip install griffe-generics
```

## Usage
```yaml
plugins:
- mkdocstrings:
handlers:
python:
options:
extensions:
- griffe_generics
```
Binary file added assets/with-extension.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/without-extension.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions griffe_generics/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from griffe_generics.extension import GenericsExtension

__version__ = "1.0.12"

__all__ = ["GenericsExtension"]
Loading

0 comments on commit 2756bce

Please sign in to comment.