Skip to content

Commit 9caafb0

Browse files
authored
Merge pull request #233 from kjd/cleanups
Cleanups
2 parents fefc994 + 5ce96ab commit 9caafb0

7 files changed

Lines changed: 88 additions & 117 deletions

File tree

.github/workflows/python-package.yml

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,13 @@ permissions:
1212

1313
jobs:
1414
lint:
15-
strategy:
16-
fail-fast: false
17-
matrix:
18-
python-version:
19-
- '3.8'
20-
- '3.9'
21-
- '3.10'
22-
- '3.11'
23-
- '3.12'
24-
- '3.13'
25-
- '3.14'
26-
runs-on: ${{ matrix.os || 'ubuntu-latest' }}
15+
runs-on: ubuntu-latest
2716
steps:
2817
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
29-
- name: Set up Python ${{ matrix.python-version }}
18+
- name: Set up Python
3019
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
3120
with:
32-
python-version: ${{ matrix.python-version }}
33-
allow-prereleases: true
21+
python-version: '3.14'
3422
- name: Install dependencies
3523
run: python -m pip install ruff mypy ty
3624
- name: Check code style with ruff

idna/codec.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import codecs
2-
import re
32
from typing import Any, Optional, Tuple
43

5-
from .core import IDNAError, alabel, decode, encode, ulabel
6-
7-
_unicode_dots_re = re.compile("[\u002e\u3002\uff0e\uff61]")
4+
from .core import IDNAError, _unicode_dots_re, alabel, decode, encode, ulabel
85

96

107
class Codec(codecs.Codec):
@@ -20,7 +17,7 @@ class Codec(codecs.Codec):
2017

2118
def encode(self, data: str, errors: str = "strict") -> Tuple[bytes, int]: # ty: ignore[invalid-method-override]
2219
if errors != "strict":
23-
raise IDNAError('Unsupported error handling "{}"'.format(errors))
20+
raise IDNAError(f'Unsupported error handling "{errors}"')
2421

2522
if not data:
2623
return b"", 0
@@ -29,7 +26,7 @@ def encode(self, data: str, errors: str = "strict") -> Tuple[bytes, int]: # ty:
2926

3027
def decode(self, data: bytes, errors: str = "strict") -> Tuple[str, int]: # ty: ignore[invalid-method-override]
3128
if errors != "strict":
32-
raise IDNAError('Unsupported error handling "{}"'.format(errors))
29+
raise IDNAError(f'Unsupported error handling "{errors}"')
3330

3431
if not data:
3532
return "", 0
@@ -51,7 +48,7 @@ class IncrementalEncoder(codecs.BufferedIncrementalEncoder):
5148

5249
def _buffer_encode(self, data: str, errors: str, final: bool) -> Tuple[bytes, int]: # ty: ignore[invalid-method-override]
5350
if errors != "strict":
54-
raise IDNAError('Unsupported error handling "{}"'.format(errors))
51+
raise IDNAError(f'Unsupported error handling "{errors}"')
5552

5653
if not data:
5754
return b"", 0
@@ -94,7 +91,7 @@ class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
9491

9592
def _buffer_decode(self, data: Any, errors: str, final: bool) -> Tuple[str, int]: # ty: ignore[invalid-method-override]
9693
if errors != "strict":
97-
raise IDNAError('Unsupported error handling "{}"'.format(errors))
94+
raise IDNAError(f'Unsupported error handling "{errors}"')
9895

9996
if not data:
10097
return ("", 0)

0 commit comments

Comments
 (0)