Skip to content
This repository was archived by the owner on Feb 27, 2023. It is now read-only.
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
84 changes: 42 additions & 42 deletions .github/workflows/on-push-to-main.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
#name: Release Main
#
#on:
# push:
# branches:
# - main
#
#jobs:
# release:
# name: Release main
# runs-on: ubuntu-latest
#
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# with:
# fetch-depth: 0
# ref: main
#
# - name: Setup Node.js
# uses: actions/setup-node@v3
# with:
# node-version: 'lts/*'
#
# - name: Set up Python 3.9
# uses: actions/setup-python@v3
# with:
# python-version: 3.9
#
# - name: Install python dependencies
# run: |
# python -m pip install --upgrade wheel setuptools pipenv-setup twine
#
# - name: Install semantic release dependencies
# run: npm i semantic-release-slack-bot semantic-release-pypi
#
# - name: Release
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_NT_SEMANTIC_RELEASE_PROD }}
# PYPI_TOKEN: ${{ secrets.GH_PYPI_TOKEN }}
# run: npx semantic-release
name: Release Main

on:
push:
branches:
- main

jobs:
release:
name: Release main
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: main

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 'lts/*'

- name: Set up Python 3.9
uses: actions/setup-python@v3
with:
python-version: 3.9

- name: Install python dependencies
run: |
python -m pip install --upgrade wheel setuptools pipenv-setup twine

- name: Install semantic release dependencies
run: npm i semantic-release-slack-bot semantic-release-pypi

- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_NT_SEMANTIC_RELEASE_PROD }}
PYPI_TOKEN: ${{ secrets.GH_PYPI_TOKEN }}
run: npx semantic-release
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ repos:
pass_filenames: false
require_serial: true
args: [
"changeme-package-name-stubs",
"jose-stubs",
"--show-error-codes",
"--namespace-packages",
"--show-traceback",
Expand All @@ -30,7 +30,7 @@ repos:
hooks:
- id: reorder-python-imports
args: [
"--application-directories=changeme-package-name-stubs"
"--application-directories=jose-stubs"
]
- repo: https://gitlab.com/pycqa/flake8
rev: 4.0.1
Expand Down
2 changes: 1 addition & 1 deletion .releaserc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{
"notifyOnSuccess": false,
"notifyOnFail": false,
"packageName": "changeme-types-package-name",
"packageName": "types-python-jose",
"branchesConfig": [
{
"pattern": "main",
Expand Down
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ name = "pypi"
# If you edit this file, run `pipenv-setup sync --pipfile --dev` afterwards

[dev-packages]
python-jose = "==3.3.0"

mypy = "==0.942"
pipenv-setup = "==3.2.0"
Expand Down
74 changes: 58 additions & 16 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 6 additions & 53 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,70 +1,23 @@
# template-python-types

###(For the instructions below, the original packagename will be assumed to be `foo-bar`. Adapt this to your use case)

Step-by-step instructions on using this template:

- Create a new repository using this template. Name it `types-foo-bar`.
- Set up anything that may not carry over from the template (branch permissions, enabling the renovate bot, etc)
- You can use [this](https://app.gitbook.com/o/kE0i1aiE1u2yiaP5k3xM/s/B8iaOECpmPzLCKc8nF0p/development/github-repository-init-checklist) for a full list (although some steps do not apply, like the `next` branch or the `unit-tests` action)
- Set the repository to `public` access. Take a second to think through the implications of this. Extra care will be needed to avoid leaking any information
- Replace all instances of `changeme` strings as follows:
- Replace these:
- `changeme-package-name` => `foo-bar` (name of the original package)
- `changeme-types-package-name` => `types-foo-bar` (name of your stubs package; **must** start with `types-`)
- `changeme-package-name-stubs` => `foo-bar-stubs` (name of the stubs root folder; **must** end with `-stubs`)
- In the following files:
- `README.md`
- `.releaserc`
- `.pre-commit-config.yaml`
- `setup.py`
- Rename the folder `changeme-package-name-stubs` to `foo-bar-stubs`. This will be the root folder for all the stub files
- In `foo-bar-stubs/METADATA.toml`, change the version from `"X.Y.*"` to the version of the original package for which your stubs are meant for (usually the latest one)
- Update the package's information in `setup.py`
- Add/Update the [classifiers](https://pypi.org/classifiers/) to help people find the package
- Add some keywords (like the original package name, related frameworks, etc) to help people find the package
- Change the versions in `python_requires` if necessary. Make sure it matches the versions listed in the classifiers
- Add the dependencies:
- Add your dependencies to the `Pipfile` with an exact version
- Run `$ pipenv install -d` to update the `Pipfile.lock`
- Run `$ pipenv shell` to switch to a shell within the virtual environment
- Run `$ pipenv-setup sync --pipfile --dev` to sync the dependencies to the `setup.py`
- Install the pre-commit hook (see below, in the `Developing` section)
- Add your stubs
- [Optional] Mark the `foo-bar-stubs` directory as `Sources Root` and the `.mypy_cache` directory as `Excluded`
- The stubs can be generated with [stubgen](https://mypy.readthedocs.io/en/stable/stubgen.html#stubgen) with the command `$ stubgen -p foo-bar`, and will only need to be filled in
- The files need to use the root of the `foo-bar-stubs` as their root, and only have sub-folders as necessary to match the structure of the original package
- Test your stubs
- If you add the stubs root directory (`foo-bar-stubs`) to `mypy`'s path, it should pick up and use your stubs automatically. You can tell this is the case when it gives off a warning about the `type: ignore[import]` comment for that specific package being unused (doesn't complain about the package not having stubs available)
- Uncomment the action in `.github/workflows/on-push-to-main.yml` to allow the package to be released
- Remove these instructions from `README.md` (they will still be available in the template repo for the next steps)
- A search through the whole project (CTRL + Shift + F in PyCharm) should find no results for `changeme`
- Release the package
- Merge your changes into the `main` branch (preferably via PR)
- Wait for the GH Action to run, and the package to be released
- The package should be available at https://pypi.org/project/types-foo-bar/
- Download your package and test it again as a final check

# changeme-types-package-name
# types-python-jose

This is a package containing type annotations
for [changeme-package-name](https://pypi.org/project/changeme-package-name/).
for [python-jose](https://pypi.org/project/python-jose/).

### Installing:

Simply run the following in the environment in which you want to install this package:

```shell
# install changeme-types-package-name
$ python -m pip install changeme-types-package-name
# install types-python-jose
$ python -m pip install types-python-jose
```

or add it to your requirements file.

### Developing

This is a partial stub package, only covering a part of the functions and objects available in `changeme-package-name`.
Contributions (both in adding stubs for more functions, or keeping up to date with `changeme-package-name` itself) are
This is a partial stub package, only covering a part of the functions and objects available in `python-jose`.
Contributions (both in adding stubs for more functions, or keeping up to date with `python-jose` itself) are
welcome.

All the formatting is done using [pre-commit](https://pre-commit.com/). To use this, run the following:
Expand Down
1 change: 0 additions & 1 deletion changeme-package-name-stubs/METADATA.toml

This file was deleted.

1 change: 1 addition & 0 deletions jose-stubs/METADATA.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version = "3.3.*"
6 changes: 6 additions & 0 deletions jose-stubs/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from .exceptions import (
ExpiredSignatureError as ExpiredSignatureError,
JOSEError as JOSEError,
JWSError as JWSError,
JWTError as JWTError,
)
3 changes: 3 additions & 0 deletions jose-stubs/backends/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .base import DIRKey as DIRKey
from jose.backends.native import HMACKey as HMACKey, get_random_bytes as get_random_bytes
from jose.backends.rsa_backend import RSAKey as RSAKey
3 changes: 3 additions & 0 deletions jose-stubs/backends/_asn1.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from typing import Any

def __getattr__(name: str) -> Any: ... # incomplete
4 changes: 4 additions & 0 deletions jose-stubs/backends/base.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from ..utils import base64url_encode as base64url_encode, ensure_binary as ensure_binary
from typing import Any

def __getattr__(name: str) -> Any: ... # incomplete
13 changes: 13 additions & 0 deletions jose-stubs/backends/cryptography_backend.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from ..constants import ALGORITHMS as ALGORITHMS
from ..exceptions import JWEError as JWEError, JWKError as JWKError
from ..utils import (
base64_to_long as base64_to_long,
base64url_decode as base64url_decode,
base64url_encode as base64url_encode,
ensure_binary as ensure_binary,
long_to_base64 as long_to_base64,
)
from .base import Key as Key
from typing import Any

def __getattr__(name: str) -> Any: ... # incomplete
7 changes: 7 additions & 0 deletions jose-stubs/backends/ecdsa_backend.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from ..backends.base import Key as Key
from ..constants import ALGORITHMS as ALGORITHMS
from ..exceptions import JWKError as JWKError
from ..utils import base64_to_long as base64_to_long, long_to_base64 as long_to_base64
from typing import Any

def __getattr__(name: str) -> Any: ... # incomplete
7 changes: 7 additions & 0 deletions jose-stubs/backends/native.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from ..backends.base import Key as Key
from ..constants import ALGORITHMS as ALGORITHMS
from ..exceptions import JWKError as JWKError
from ..utils import base64url_decode as base64url_decode, base64url_encode as base64url_encode
from typing import Any

def __getattr__(name: str) -> Any: ... # incomplete
Loading