Skip to content

Commit

Permalink
Drop Python 3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
hynek committed Aug 24, 2022
1 parent 85c4874 commit 9b8708f
Show file tree
Hide file tree
Showing 15 changed files with 38 additions and 26 deletions.
1 change: 0 additions & 1 deletion .github/workflows/main.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ jobs:
strategy:
matrix:
python-version:
- "3.6"
- "3.7"
- "3.8"
- "3.9"
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ repos:
rev: v2.37.3
hooks:
- id: pyupgrade
args: [--py36-plus]
args: [--py37-plus]

- repo: https://github.com/asottile/yesqa
rev: v1.4.0
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ What explicitly *may* change over time are the default hashing parameters and th

## [Unreleased](https://github.com/hynek/argon2-cffi/compare/21.3.0...HEAD)

### Removed

- Python 3.6 is not supported anymore.


### Added

- Official support for Python 3.11.
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Project Information
- **Source Code**: https://github.com/hynek/argon2-cffi
- **Documentation**: https://argon2-cffi.readthedocs.io/
- **Changelog**: https://github.com/hynek/argon2-cffi/blob/main/CHANGELOG.md
- **Supported Python Versions**: 3.6 and later
- **Supported Python Versions**: 3.7 and later

The low-level Argon2 CFFI bindings are maintained in the separate project `argon2-cffi-bindings <https://github.com/hynek/argon2-cffi-bindings>`_.

Expand Down
7 changes: 3 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ build-backend = "flit_core.buildapi"

[project]
name = "argon2-cffi"
description = "Argon2 for Python"
authors = [{ name = "Hynek Schlawack", email = "hs@ox.cx" }]
dynamic = ["version", "description"]
requires-python = ">=3.6"
dynamic = ["version"]
requires-python = ">=3.7"
license = { file = "LICENSE" }
readme = "README.rst"
keywords = ["password", "hash", "hashing", "security"]
Expand All @@ -23,7 +24,6 @@ classifiers = [
"Operating System :: POSIX",
"Operating System :: Unix",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
Expand All @@ -38,7 +38,6 @@ classifiers = [
]
dependencies = [
"argon2-cffi-bindings",
"dataclasses; python_version < '3.7'",
"typing-extensions; python_version < '3.8'", # c.f. _typing.py module
]

Expand Down
2 changes: 1 addition & 1 deletion src/argon2/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: MIT

"""
The secure Argon2 password hashing algorithm.
Argon2 for Python
"""

from . import exceptions, low_level, profiles
Expand Down
6 changes: 3 additions & 3 deletions src/argon2/__main__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# SPDX-License-Identifier: MIT

from __future__ import annotations

import argparse
import sys
import timeit

from typing import List

from . import (
DEFAULT_HASH_LENGTH,
DEFAULT_MEMORY_COST,
Expand All @@ -16,7 +16,7 @@
)


def main(argv: List[str]) -> None:
def main(argv: list[str]) -> None:
parser = argparse.ArgumentParser(description="Benchmark Argon2.")
parser.add_argument(
"-n", type=int, default=100, help="Number of iterations to measure."
Expand Down
8 changes: 4 additions & 4 deletions src/argon2/_legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
Legacy mid-level functions.
"""

import os
from __future__ import annotations

from typing import Optional
import os

from ._password_hasher import (
DEFAULT_HASH_LENGTH,
Expand All @@ -21,7 +21,7 @@

def hash_password(
password: bytes,
salt: Optional[bytes] = None,
salt: bytes | None = None,
time_cost: int = DEFAULT_TIME_COST,
memory_cost: int = DEFAULT_MEMORY_COST,
parallelism: int = DEFAULT_PARALLELISM,
Expand All @@ -43,7 +43,7 @@ def hash_password(

def hash_password_raw(
password: bytes,
salt: Optional[bytes] = None,
salt: bytes | None = None,
time_cost: int = DEFAULT_TIME_COST,
memory_cost: int = DEFAULT_MEMORY_COST,
parallelism: int = DEFAULT_PARALLELISM,
Expand Down
12 changes: 6 additions & 6 deletions src/argon2/_password_hasher.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# SPDX-License-Identifier: MIT

import os
from __future__ import annotations

from typing import Union
import os

from ._typing import Literal
from ._utils import Parameters, _check_types, extract_parameters
Expand All @@ -18,7 +18,7 @@
DEFAULT_PARALLELISM = RFC_9106_LOW_MEMORY.parallelism


def _ensure_bytes(s: Union[bytes, str], encoding: str) -> bytes:
def _ensure_bytes(s: bytes | str, encoding: str) -> bytes:
"""
Ensure *s* is a bytes string. Encode using *encoding* if it isn't.
"""
Expand Down Expand Up @@ -108,7 +108,7 @@ def __init__(
self.encoding = encoding

@classmethod
def from_parameters(cls, params: Parameters) -> "PasswordHasher":
def from_parameters(cls, params: Parameters) -> PasswordHasher:
"""
Construct a `PasswordHasher` from *params*.
Expand Down Expand Up @@ -143,7 +143,7 @@ def salt_len(self) -> int:
def type(self) -> Type:
return self._parameters.type

def hash(self, password: Union[str, bytes]) -> str:
def hash(self, password: str | bytes) -> str:
"""
Hash *password* and return an encoded hash.
Expand Down Expand Up @@ -171,7 +171,7 @@ def hash(self, password: Union[str, bytes]) -> str:
}

def verify(
self, hash: Union[str, bytes], password: Union[str, bytes]
self, hash: str | bytes, password: str | bytes
) -> Literal[True]:
"""
Verify that *password* matches *hash*.
Expand Down
2 changes: 2 additions & 0 deletions src/argon2/_typing.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# SPDX-License-Identifier: MIT

from __future__ import annotations

import sys


Expand Down
6 changes: 4 additions & 2 deletions src/argon2/_utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# SPDX-License-Identifier: MIT

from __future__ import annotations

from dataclasses import dataclass
from typing import Any, Optional
from typing import Any

from .exceptions import InvalidHash
from .low_level import Type
Expand All @@ -10,7 +12,7 @@
NoneType = type(None)


def _check_types(**kw: Any) -> Optional[str]:
def _check_types(**kw: Any) -> str | None:
"""
Check each ``name: (value, types)`` in *kw*.
Expand Down
2 changes: 2 additions & 0 deletions src/argon2/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# SPDX-License-Identifier: MIT

from __future__ import annotations


class Argon2Error(Exception):
"""
Expand Down
4 changes: 3 additions & 1 deletion src/argon2/low_level.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
.. warning::
This is a "Hazardous Materials" module. You should **ONLY** use it if
you're 100% absolutely sure that you know what youre doing because this
you're 100% absolutely sure that you know what you're doing because this
module is full of land mines, dragons, and dinosaurs with laser guns.
"""

from __future__ import annotations

from enum import Enum
from typing import Any

Expand Down
2 changes: 2 additions & 0 deletions src/argon2/profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
.. versionadded:: 21.2.0
"""

from __future__ import annotations

from ._utils import Parameters
from .low_level import Type

Expand Down
3 changes: 1 addition & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ ignore =
# We don't run pre-commit in CI, because we use pre-commit.ci.
[gh-actions]
python =
3.6: py36
3.7: py37
3.8: py38, docs
3.9: py39, mypy
Expand All @@ -24,7 +23,7 @@ python =


[tox]
envlist = pre-commit,mypy,py36,py37,py38,py39,py310,py311,pypy3,system-argon2,bindings-main,docs,pypi-description,coverage-report
envlist = pre-commit,mypy,py37,py38,py39,py310,py311,pypy3,system-argon2,bindings-main,docs,pypi-description,coverage-report
isolated_build = true


Expand Down

0 comments on commit 9b8708f

Please sign in to comment.