Skip to content

Commit

Permalink
Merge pull request #7 from ninoseki/drop-python37
Browse files Browse the repository at this point in the history
refactor: drop Python 3.7 support & update deps
  • Loading branch information
ninoseki committed Jul 22, 2023
2 parents 3493bd6 + 4bdeb2d commit 58df044
Show file tree
Hide file tree
Showing 7 changed files with 814 additions and 892 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/test.yml
Expand Up @@ -8,23 +8,23 @@ jobs:

strategy:
matrix:
python-version: [3.7, 3.8, 3.9]
poetry-version: [1.1.6]
python-version: [3.8, 3.9, "3.10", 3.11]
poetry-version: [1.5.1]

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Run image
uses: abatilo/actions-poetry@v2.0.0
- name: Setup Poetry
uses: abatilo/actions-poetry@v2
with:
poetry-version: ${{ matrix.poetry-version }}

- name: Install
run: |
poetry install
run: poetry install

- name: Run tests
run: poetry run pytest -v --cov=aiodnsbl --cov-report=term-missing
Expand Down
52 changes: 32 additions & 20 deletions .pre-commit-config.yaml
@@ -1,36 +1,48 @@
repos:
- repo: https://github.com/humitos/mirrors-autoflake
rev: v1.3
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: autoflake
- id: check-added-large-files
- id: check-toml
- id: check-yaml
args:
[
"--in-place",
"--remove-all-unused-imports",
"--remove-unused-variable",
]
- --unsafe
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/asottile/pyupgrade
rev: v2.29.0
rev: v3.9.0
hooks:
- id: pyupgrade
args: [--py37-plus]
args:
- --py38-plus

- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.2
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.280
hooks:
- id: flake8
additional_dependencies: [flake8-print]
args: ["--ignore=E501,W503,E203"]
- id: ruff
args:
- --fix

- repo: https://github.com/timothycrosley/isort
rev: 5.9.2
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
additional_dependencies: [toml]
exclude: ^.*/?setup\.py$
args: ["--profile", "black", "--filter-files"]

- repo: https://github.com/psf/black
rev: 21.9b0
rev: 23.7.0
hooks:
- id: black

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.4.1
hooks:
- id: mypy
additional_dependencies:
- types-all

- repo: https://github.com/andrei-shabanski/poetry-plugin-sort
rev: v0.2.0
hooks:
- id: poetry-sort
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -72,4 +72,4 @@ async def main():

loop = asyncio.get_event_loop()
loop.run_until_complete(main())
```
```
9 changes: 2 additions & 7 deletions aiodnsbl/__init__.py
@@ -1,10 +1,5 @@
from .checker import DNSBLChecker
import importlib.metadata as importlib_metadata

try:
import importlib.metadata as importlib_metadata
except ModuleNotFoundError:
import importlib_metadata
from .checker import DNSBLChecker # noqa: F401

__version__ = importlib_metadata.version(__name__)

__all__ = ["DNSBLChecker"]
6 changes: 4 additions & 2 deletions aiodnsbl/checker.py
Expand Up @@ -30,7 +30,9 @@ def normalize_domain(value: str) -> str:


# https://regex101.com/r/vdrgm7/1
DOMAIN_REGEX = re.compile(r"^(((?!-))(xn--|_{1,1})?[a-z0-9-]{0,61}[a-z0-9]{1,1}\.)*(xn--[a-z0-9][a-z0-9\-]{0,60}|[a-z0-9-]{1,30}\.[a-z]{2,})$")
DOMAIN_REGEX = re.compile(
r"^(((?!-))(xn--|_{1,1})?[a-z0-9-]{0,61}[a-z0-9]{1,1}\.)*(xn--[a-z0-9][a-z0-9\-]{0,60}|[a-z0-9-]{1,30}\.[a-z]{2,})$"
)


@functools.lru_cache(maxsize=256)
Expand Down Expand Up @@ -161,7 +163,7 @@ def prepare_query(self, request: str) -> str:
if address.version == 6:
# according to RFC: https://tools.ietf.org/html/rfc5782#section-2.4
request_stripped = request.replace(":", "")
return ".".join(reversed([x for x in request_stripped]))
return ".".join(reversed(list(request_stripped)))

raise ValueError("Unknown ip version")

Expand Down

0 comments on commit 58df044

Please sign in to comment.