Skip to content

Commit

Permalink
remove Python 3.7 support
Browse files Browse the repository at this point in the history
* drop support for Python 3.7, update deps, remove python<4 blocker, bump version
  • Loading branch information
guillp authored Jul 21, 2023
1 parent 569a37d commit 6983e38
Show file tree
Hide file tree
Showing 11 changed files with 288 additions and 400 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
# The type of runner that the job will run on
strategy:
matrix:
python-versions: [3.7, 3.8, 3.9, '3.10', '3.11']
python-versions: [3.8, 3.9, '3.10', '3.11']
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}

Expand Down
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ repos:
additional_dependencies:
- mdformat-black
- repo: https://github.com/myint/docformatter
rev: v1.7.2
rev: v1.7.5
hooks:
- id: docformatter
args:
Expand All @@ -57,7 +57,7 @@ repos:
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 23.3.0
rev: 23.7.0
hooks:
- id: black
- repo: https://github.com/pycqa/flake8
Expand All @@ -67,7 +67,7 @@ repos:
additional_dependencies:
- flake8-typing-imports==1.14.0
- repo: https://github.com/asottile/blacken-docs
rev: 1.14.0
rev: 1.15.0
hooks:
- id: blacken-docs
- repo: https://github.com/pycqa/pydocstyle
Expand All @@ -80,7 +80,7 @@ repos:
- toml
exclude: 'tests/'
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.4.0
rev: v1.4.1
hooks:
- id: mypy
args:
Expand Down
27 changes: 8 additions & 19 deletions binapy/binapy.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
List,
Optional,
SupportsBytes,
SupportsIndex,
TypeVar,
Union,
cast,
overload,
)

from typing_extensions import Literal, SupportsIndex
from typing_extensions import Literal


class BinaPy(bytes):
Expand Down Expand Up @@ -128,9 +129,7 @@ def text(self, encoding: str = "ascii") -> str:
Returns:
the decoded text
"""
return self.re_match(
r'^[a-zA-Z0-9!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ ]*$', encoding
)
return self.re_match(r'^[a-zA-Z0-9!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ ]*$', encoding)

def urlsafe(self) -> str:
r"""Convert this BinaPy to a str, and check that it contains only url-safe characters.
Expand All @@ -150,9 +149,7 @@ def alphanumeric(self) -> str:
"""
return self.re_match(r"^[a-zA-Z]$")

def to_int(
self, byteorder: Literal["little", "big"] = "big", signed: bool = False
) -> int:
def to_int(self, byteorder: Literal["little", "big"] = "big", signed: bool = False) -> int:
"""Convert this BinaPy to an `int`.
This is a wrapper around
Expand Down Expand Up @@ -185,9 +182,7 @@ def from_binary_string(
a BinaPy
"""
s = s.replace(" ", "").replace("\t", "")
return cls(
int(s, 2).to_bytes((len(s) + 7) // 8, byteorder=byteorder, signed=signed)
)
return cls(int(s, 2).to_bytes((len(s) + 7) // 8, byteorder=byteorder, signed=signed))

def to_binary_string(
self,
Expand Down Expand Up @@ -368,9 +363,7 @@ def _get_parser(cls, extension_name: str) -> Callable[..., Any]:
extension_methods = cls._get_extension_methods(extension_name)
method = extension_methods.get("parse")
if method is None:
raise NotImplementedError(
f"Extension {extension_name} doesn't have a parse method"
)
raise NotImplementedError(f"Extension {extension_name} doesn't have a parse method")
return method

@classmethod
Expand Down Expand Up @@ -426,9 +419,7 @@ def decode_from(self, name: str, *args: Any, **kwargs: Any) -> "BinaPy":

return decoder(self, *args, **kwargs)

def check(
self, name: str, decode: bool = False, raise_on_error: bool = False
) -> bool:
def check(self, name: str, decode: bool = False, raise_on_error: bool = False) -> bool:
"""Check that this BinaPy conforms to a given format extension.
Args:
Expand Down Expand Up @@ -519,9 +510,7 @@ def serialize_to(cls, name: str, *args: Any, **kwargs: Any) -> "BinaPy":
return serializer(*args, **kwargs)

@classmethod
def register_extension(
cls, name: str, feature: str, func: Callable[..., Any]
) -> None:
def register_extension(cls, name: str, feature: str, func: Callable[..., Any]) -> None:
"""Register a new feature for the given extension name.
Args:
Expand Down
6 changes: 1 addition & 5 deletions binapy/encoding/hex.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,4 @@ def is_hex(bp: bytes) -> bool:
Returns:
`True` if `bp` is a valid hexadecimal string
"""
return (
len(bp) % 2 == 0
and bp.isalnum()
and set(bp.lower()).issubset(b"abcdef0123456789")
)
return len(bp) % 2 == 0 and bp.isalnum() and set(bp.lower()).issubset(b"abcdef0123456789")
1 change: 0 additions & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ markdown_extensions:
slugify: !!python/name:pymdownx.slugs.uslugify
- meta
plugins:
- include-markdown
- search:
lang: en
- mkdocstrings:
Expand Down
Loading

0 comments on commit 6983e38

Please sign in to comment.