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

Introduce ruff code checker and formatter #7

Merged
merged 2 commits into from
Nov 29, 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
27 changes: 27 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: pre-commit check

on:
push:
pull_request:

permissions:
contents: read

jobs:
pre-commit:
runs-on: ubuntu-24.04

steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
- uses: astral-sh/setup-uv@v4
- name: pre-commit
run: uvx pre-commit run --all
env:
RUFF_OUTPUT_FORMAT: github
- name: show diff
run: git diff
if: always()
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.0
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format
22 changes: 11 additions & 11 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
from setuptools import setup, find_packages

setup(
name='altcha',
version='0.1.5',
description='A library for creating and verifying challenges for ALTCHA.',
long_description=open('README.md').read(),
long_description_content_type='text/markdown',
author='Daniel Regeci',
author_email='[email protected]',
url='https://github.com/altcha-org/altcha-lib-py',
name="altcha",
version="0.1.5",
description="A library for creating and verifying challenges for ALTCHA.",
long_description=open("README.md").read(),
long_description_content_type="text/markdown",
author="Daniel Regeci",
author_email="[email protected]",
url="https://github.com/altcha-org/altcha-lib-py",
packages=find_packages(),
classifiers=[
'Programming Language :: Python :: 3',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
python_requires='>=3.9',
install_requires=[
Expand Down
12 changes: 7 additions & 5 deletions tests/test_altcha.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@


class TestALTCHA(unittest.TestCase):

def setUp(self):
self.hmac_key = "test-key"

Expand Down Expand Up @@ -90,7 +89,8 @@ def test_verify_solution_not_expired(self):
hmac_key=self.hmac_key,
salt="somesalt",
number=123,
expires=datetime.datetime.now().astimezone() + datetime.timedelta(minutes=1)
expires=datetime.datetime.now().astimezone()
+ datetime.timedelta(minutes=1),
)
challenge = create_challenge(options)
payload = Payload(
Expand All @@ -114,7 +114,8 @@ def test_verify_solution_expired(self):
hmac_key=self.hmac_key,
salt="somesalt",
number=123,
expires=datetime.datetime.now().astimezone() - datetime.timedelta(minutes=1)
expires=datetime.datetime.now().astimezone()
- datetime.timedelta(minutes=1),
)
challenge = create_challenge(options)
payload = Payload(
Expand All @@ -138,14 +139,15 @@ def test_verify_solution_malformed_expiry(self):
hmac_key=self.hmac_key,
salt="somesalt",
number=123,
expires=datetime.datetime.now().astimezone() + datetime.timedelta(minutes=1)
expires=datetime.datetime.now().astimezone()
+ datetime.timedelta(minutes=1),
)
challenge = create_challenge(options)
payload = Payload(
algorithm="SHA-256",
challenge=challenge.challenge,
number=123,
salt='somesalt?expires=foobar',
salt="somesalt?expires=foobar",
signature=challenge.signature,
)
payload_encoded = base64.b64encode(
Expand Down
Loading