Skip to content
This repository was archived by the owner on Feb 27, 2023. It is now read-only.

Commit 96dcb29

Browse files
authored
feat: Set up template, add stubs (#1)
1 parent 8bfb6c6 commit 96dcb29

24 files changed

+316
-126
lines changed
Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
1-
#name: Release Main
2-
#
3-
#on:
4-
# push:
5-
# branches:
6-
# - main
7-
#
8-
#jobs:
9-
# release:
10-
# name: Release main
11-
# runs-on: ubuntu-latest
12-
#
13-
# steps:
14-
# - name: Checkout
15-
# uses: actions/checkout@v3
16-
# with:
17-
# fetch-depth: 0
18-
# ref: main
19-
#
20-
# - name: Setup Node.js
21-
# uses: actions/setup-node@v3
22-
# with:
23-
# node-version: 'lts/*'
24-
#
25-
# - name: Set up Python 3.9
26-
# uses: actions/setup-python@v3
27-
# with:
28-
# python-version: 3.9
29-
#
30-
# - name: Install python dependencies
31-
# run: |
32-
# python -m pip install --upgrade wheel setuptools pipenv-setup twine
33-
#
34-
# - name: Install semantic release dependencies
35-
# run: npm i semantic-release-slack-bot semantic-release-pypi
36-
#
37-
# - name: Release
38-
# env:
39-
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40-
# SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_NT_SEMANTIC_RELEASE_PROD }}
41-
# PYPI_TOKEN: ${{ secrets.GH_PYPI_TOKEN }}
42-
# run: npx semantic-release
1+
name: Release Main
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
release:
10+
name: Release main
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v3
16+
with:
17+
fetch-depth: 0
18+
ref: main
19+
20+
- name: Setup Node.js
21+
uses: actions/setup-node@v3
22+
with:
23+
node-version: 'lts/*'
24+
25+
- name: Set up Python 3.9
26+
uses: actions/setup-python@v3
27+
with:
28+
python-version: 3.9
29+
30+
- name: Install python dependencies
31+
run: |
32+
python -m pip install --upgrade wheel setuptools pipenv-setup twine
33+
34+
- name: Install semantic release dependencies
35+
run: npm i semantic-release-slack-bot semantic-release-pypi
36+
37+
- name: Release
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_NT_SEMANTIC_RELEASE_PROD }}
41+
PYPI_TOKEN: ${{ secrets.GH_PYPI_TOKEN }}
42+
run: npx semantic-release

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ repos:
99
pass_filenames: false
1010
require_serial: true
1111
args: [
12-
"changeme-package-name-stubs",
12+
"jose-stubs",
1313
"--show-error-codes",
1414
"--namespace-packages",
1515
"--show-traceback",
@@ -30,7 +30,7 @@ repos:
3030
hooks:
3131
- id: reorder-python-imports
3232
args: [
33-
"--application-directories=changeme-package-name-stubs"
33+
"--application-directories=jose-stubs"
3434
]
3535
- repo: https://gitlab.com/pycqa/flake8
3636
rev: 4.0.1

.releaserc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
{
1313
"notifyOnSuccess": false,
1414
"notifyOnFail": false,
15-
"packageName": "changeme-types-package-name",
15+
"packageName": "types-python-jose",
1616
"branchesConfig": [
1717
{
1818
"pattern": "main",

Pipfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ name = "pypi"
55
# If you edit this file, run `pipenv-setup sync --pipfile --dev` afterwards
66

77
[dev-packages]
8+
python-jose = "==3.3.0"
89

910
mypy = "==0.942"
1011
pipenv-setup = "==3.2.0"

Pipfile.lock

Lines changed: 58 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 6 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,23 @@
1-
# template-python-types
2-
3-
###(For the instructions below, the original packagename will be assumed to be `foo-bar`. Adapt this to your use case)
4-
5-
Step-by-step instructions on using this template:
6-
7-
- Create a new repository using this template. Name it `types-foo-bar`.
8-
- Set up anything that may not carry over from the template (branch permissions, enabling the renovate bot, etc)
9-
- 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)
10-
- 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
11-
- Replace all instances of `changeme` strings as follows:
12-
- Replace these:
13-
- `changeme-package-name` => `foo-bar` (name of the original package)
14-
- `changeme-types-package-name` => `types-foo-bar` (name of your stubs package; **must** start with `types-`)
15-
- `changeme-package-name-stubs` => `foo-bar-stubs` (name of the stubs root folder; **must** end with `-stubs`)
16-
- In the following files:
17-
- `README.md`
18-
- `.releaserc`
19-
- `.pre-commit-config.yaml`
20-
- `setup.py`
21-
- Rename the folder `changeme-package-name-stubs` to `foo-bar-stubs`. This will be the root folder for all the stub files
22-
- 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)
23-
- Update the package's information in `setup.py`
24-
- Add/Update the [classifiers](https://pypi.org/classifiers/) to help people find the package
25-
- Add some keywords (like the original package name, related frameworks, etc) to help people find the package
26-
- Change the versions in `python_requires` if necessary. Make sure it matches the versions listed in the classifiers
27-
- Add the dependencies:
28-
- Add your dependencies to the `Pipfile` with an exact version
29-
- Run `$ pipenv install -d` to update the `Pipfile.lock`
30-
- Run `$ pipenv shell` to switch to a shell within the virtual environment
31-
- Run `$ pipenv-setup sync --pipfile --dev` to sync the dependencies to the `setup.py`
32-
- Install the pre-commit hook (see below, in the `Developing` section)
33-
- Add your stubs
34-
- [Optional] Mark the `foo-bar-stubs` directory as `Sources Root` and the `.mypy_cache` directory as `Excluded`
35-
- 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
36-
- 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
37-
- Test your stubs
38-
- 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)
39-
- Uncomment the action in `.github/workflows/on-push-to-main.yml` to allow the package to be released
40-
- Remove these instructions from `README.md` (they will still be available in the template repo for the next steps)
41-
- A search through the whole project (CTRL + Shift + F in PyCharm) should find no results for `changeme`
42-
- Release the package
43-
- Merge your changes into the `main` branch (preferably via PR)
44-
- Wait for the GH Action to run, and the package to be released
45-
- The package should be available at https://pypi.org/project/types-foo-bar/
46-
- Download your package and test it again as a final check
47-
48-
# changeme-types-package-name
1+
# types-python-jose
492

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

536
### Installing:
547

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

5710
```shell
58-
# install changeme-types-package-name
59-
$ python -m pip install changeme-types-package-name
11+
# install types-python-jose
12+
$ python -m pip install types-python-jose
6013
```
6114

6215
or add it to your requirements file.
6316

6417
### Developing
6518

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

7023
All the formatting is done using [pre-commit](https://pre-commit.com/). To use this, run the following:

changeme-package-name-stubs/METADATA.toml

Lines changed: 0 additions & 1 deletion
This file was deleted.

jose-stubs/METADATA.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
version = "3.3.*"

jose-stubs/__init__.pyi

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from .exceptions import (
2+
ExpiredSignatureError as ExpiredSignatureError,
3+
JOSEError as JOSEError,
4+
JWSError as JWSError,
5+
JWTError as JWTError,
6+
)

jose-stubs/backends/__init__.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from .base import DIRKey as DIRKey
2+
from jose.backends.native import HMACKey as HMACKey, get_random_bytes as get_random_bytes
3+
from jose.backends.rsa_backend import RSAKey as RSAKey

0 commit comments

Comments
 (0)