Skip to content

Commit

Permalink
... and away we go
Browse files Browse the repository at this point in the history
  • Loading branch information
jorenham committed Feb 22, 2024
0 parents commit d7c0dfb
Show file tree
Hide file tree
Showing 22 changed files with 1,752 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# https://editorconfig.org/

root = true

[*]
end_of_line = lf
charset = utf-8
indent_style = space
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true
max_line_length = 79

# 2 space indentation
[*.yml]
indent_size = 2
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: monthly
- package-ecosystem: pip
directory: /
schedule:
interval: monthly
insecure-external-code-execution: allow
52 changes: 52 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: CI

on:
push:
branches:
- master
- dev
pull_request:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true

jobs:
ci:
timeout-minutes: 10

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.12']

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4
- name: install poetry
run: pipx install poetry
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: poetry

- name: poetry check
run: poetry check

- name: poetry install
run: poetry install --with github --sync

- name: codespell
run: poetry run codespell .

- name: ruff
run: poetry run ruff check --output-format=github .

- name: pyright
run: poetry run pyright

- name: pytest
run: poetry run py.test
27 changes: 27 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# Distribution / packaging
build/
dist/
site/

# Unit test
.cache
.pyright/
.pytest_cache/
.ruff_cache/

# Environments
.env
.venv/
venv/

# IntelliJ
.idea/
.run

# VSCode settings
.vscode/settings.json
27 changes: 27 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-yaml
- id: check-toml

- repo: https://github.com/python-poetry/poetry
rev: 1.7.1
hooks:
- id: poetry-check

- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
hooks:
- id: codespell

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.2
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]

- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.351
hooks:
- id: pyright
27 changes: 27 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Copyright (c) 2024, Joren Hammudoglu (jorenham).
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[![license](https://img.shields.io/github/license/jorenham/optype?style=flat-square)](https://github.com/jorenham/optype/blob/master/LICENSE?)
[![PyPI](https://img.shields.io/pypi/v/optype?style=flat-square)](https://pypi.org/project/optype/)
[![versions](https://img.shields.io/pypi/pyversions/optype?style=flat-square)](https://github.com/jorenham/optype)
[![Checked with pyright](https://microsoft.github.io/pyright/img/pyright_badge.svg)](https://microsoft.github.io/pyright/)

# optype

Typing Protocols for Precise Type Hints in Python 3.12+.
200 changes: 200 additions & 0 deletions optype/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
__all__ = (
'CanAIter',
'CanANext',
'CanAbs',
'CanAdd',
'CanAnd',
'CanBool',
'CanBytes',
'CanCeil',
'CanComplex',
'CanContains',
'CanDelitem',
'CanDir',
'CanDivmod',
'CanEq',
'CanFloat',
'CanFloor',
'CanFloordiv',
'CanGe',
'CanGetitem',
'CanGt',
'CanHash',
'CanIAdd',
'CanIAnd',
'CanIFloordiv',
'CanILshift',
'CanIMatmul',
'CanIMod',
'CanIMul',
'CanIOr',
'CanIPow',
'CanIRshift',
'CanISub',
'CanITruediv',
'CanIXor',
'CanIndex',
'CanInt',
'CanInvert',
'CanIter',
'CanLe',
'CanLen',
'CanLenHint',
'CanLshift',
'CanLt',
'CanMatmul',
'CanMissing',
'CanMod',
'CanMul',
'CanNe',
'CanNeg',
'CanNext',
'CanOr',
'CanPos',
'CanPow',
'CanPow0',
'CanRAdd',
'CanRAnd',
'CanRDivmod',
'CanRFloordiv',
'CanRLshift',
'CanRMatmul',
'CanRMod',
'CanRMul',
'CanROr',
'CanRPow',
'CanRRshift',
'CanRSub',
'CanRTruediv',
'CanRXor',
'CanRepr',
'CanReversed',
'CanRound',
'CanRound0',
'CanRshift',
'CanSetitem',
'CanStr',
'CanSub',
'CanTruediv',
'CanTrunc',
'CanXor',
'HasAnnotations',
'HasDict',
'HasDoc',
'HasModule',
'HasName',
'HasQualname',
'HasWeakCallableProxy',
'HasWeakProxy',
'HasWeakReference',
'__version__',
)

from importlib import metadata as _metadata

from ._binops import (
CanAdd,
CanAnd,
CanDivmod,
CanFloordiv,
CanLshift,
CanMatmul,
CanMod,
CanMul,
CanOr,
CanPow,
CanPow0,
CanRshift,
CanSub,
CanTruediv,
CanXor,
)
from ._binops_i import (
CanIAdd,
CanIAnd,
CanIFloordiv,
CanILshift,
CanIMatmul,
CanIMod,
CanIMul,
CanIOr,
CanIPow,
CanIRshift,
CanISub,
CanITruediv,
CanIXor,
)
from ._binops_r import (
CanRAdd,
CanRAnd,
CanRDivmod,
CanRFloordiv,
CanRLshift,
CanRMatmul,
CanRMod,
CanRMul,
CanROr,
CanRPow,
CanRRshift,
CanRSub,
CanRTruediv,
CanRXor,
)
from ._cmpops import (
CanEq,
CanGe,
CanGt,
CanLe,
CanLt,
CanNe,
)
from ._containers import (
CanContains,
CanDelitem,
CanGetitem,
CanMissing,
CanSetitem,
)
from ._nullops import (
CanBool,
CanBytes,
CanComplex,
CanFloat,
CanHash,
CanIndex,
CanInt,
CanLen,
CanLenHint,
CanRepr,
CanStr,
)
from ._specialattrs import (
HasAnnotations,
HasDict,
HasDoc,
HasModule,
HasName,
HasQualname,
HasWeakCallableProxy,
HasWeakProxy,
HasWeakReference,
)
from ._unops import (
CanAIter,
CanANext,
CanAbs,
CanCeil,
CanDir,
CanFloor,
CanInvert,
CanIter,
CanNeg,
CanNext,
CanPos,
CanReversed,
CanRound,
CanRound0,
CanTrunc,
)

__version__: str = _metadata.version(__package__ or __file__.split('/')[-1])
Loading

0 comments on commit d7c0dfb

Please sign in to comment.