Drop six dependency (#225)

* Drop six dependency

* Resolve formatting error
This commit is contained in:
Eugene 2020-08-17 14:44:23 +03:00 committed by GitHub
parent a571ad475d
commit 0b88cb2273
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 30 deletions

View File

@ -8,7 +8,6 @@ from setuptools.command.test import test
CFFI_DEPENDENCY = "cffi>=1.1"
SIX_DEPENDENCY = "six>=1.4.1"
CFFI_MODULES = [
@ -54,7 +53,7 @@ setup(
author_email=__about__["__email__"],
python_requires=">=3.6",
setup_requires=[CFFI_DEPENDENCY],
install_requires=[CFFI_DEPENDENCY, SIX_DEPENDENCY],
install_requires=[CFFI_DEPENDENCY],
extras_require={"tests": ["pytest>=3.2.1,!=3.3.0"], "typecheck": ["mypy"]},
tests_require=["pytest>=3.2.1,!=3.3.0"],
package_dir={"": "src"},

View File

@ -20,8 +20,6 @@ import os
import re
import warnings
import six
from . import _bcrypt # type: ignore
from .__about__ import (
__author__,
@ -76,8 +74,8 @@ def gensalt(rounds: int = 12, prefix: bytes = b"2b") -> bytes:
def hashpw(password: bytes, salt: bytes) -> bytes:
if isinstance(password, six.text_type) or isinstance(salt, six.text_type):
raise TypeError("Unicode-objects must be encoded before hashing")
if isinstance(password, str) or isinstance(salt, str):
raise TypeError("Strings must be encoded before hashing")
if b"\x00" in password:
raise ValueError("password may not contain NUL bytes")
@ -114,10 +112,8 @@ def hashpw(password: bytes, salt: bytes) -> bytes:
def checkpw(password: bytes, hashed_password: bytes) -> bool:
if isinstance(password, six.text_type) or isinstance(
hashed_password, six.text_type
):
raise TypeError("Unicode-objects must be encoded before checking")
if isinstance(password, str) or isinstance(hashed_password, str):
raise TypeError("Strings must be encoded before checking")
if b"\x00" in password or b"\x00" in hashed_password:
raise ValueError(
@ -139,8 +135,8 @@ def kdf(
rounds: int,
ignore_few_rounds: bool = False,
) -> bytes:
if isinstance(password, six.text_type) or isinstance(salt, six.text_type):
raise TypeError("Unicode-objects must be encoded before hashing")
if isinstance(password, str) or isinstance(salt, str):
raise TypeError("Strings must be encoded before hashing")
if len(password) == 0 or len(salt) == 0:
raise ValueError("password and salt must not be empty")

View File

@ -2,8 +2,6 @@ import os
import pytest
import six
import bcrypt
@ -264,30 +262,22 @@ def test_checkpw_bad_salt():
def test_checkpw_str_password():
with pytest.raises(TypeError):
bcrypt.checkpw(
six.text_type("password"), b"$2b$04$cVWp4XaNU8a4v1uMRum2SO",
)
bcrypt.checkpw("password", b"$2b$04$cVWp4XaNU8a4v1uMRum2SO")
def test_checkpw_str_salt():
with pytest.raises(TypeError):
bcrypt.checkpw(
b"password", six.text_type("$2b$04$cVWp4XaNU8a4v1uMRum2SO"),
)
bcrypt.checkpw(b"password", "$2b$04$cVWp4XaNU8a4v1uMRum2SO")
def test_hashpw_str_password():
with pytest.raises(TypeError):
bcrypt.hashpw(
six.text_type("password"), b"$2b$04$cVWp4XaNU8a4v1uMRum2SO",
)
bcrypt.hashpw("password", b"$2b$04$cVWp4XaNU8a4v1uMRum2SO")
def test_hashpw_str_salt():
with pytest.raises(TypeError):
bcrypt.hashpw(
b"password", six.text_type("$2b$04$cVWp4XaNU8a4v1uMRum2SO"),
)
bcrypt.hashpw(b"password", "$2b$04$cVWp4XaNU8a4v1uMRum2SO")
def test_checkpw_nul_byte():
@ -440,14 +430,12 @@ def test_kdf(rounds, password, salt, expected):
def test_kdf_str_password():
with pytest.raises(TypeError):
bcrypt.kdf(
six.text_type("password"), b"$2b$04$cVWp4XaNU8a4v1uMRum2SO", 10, 10
)
bcrypt.kdf("password", b"$2b$04$cVWp4XaNU8a4v1uMRum2SO", 10, 10)
def test_kdf_str_salt():
with pytest.raises(TypeError):
bcrypt.kdf(b"password", six.text_type("salt"), 10, 10)
bcrypt.kdf(b"password", "salt", 10, 10)
def test_kdf_no_warn_rounds():