Skip to content

Commit

Permalink
Use ruff linter
Browse files Browse the repository at this point in the history
  • Loading branch information
liZe committed Jul 12, 2024
1 parent a4e228f commit 05a312d
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ jobs:
run: python -m pip install .[test]
- name: Launch tests
run: python -m pytest
- name: Check coding style
run: python -m ruff check
3 changes: 2 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys, os, re
import os
import re

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
Expand Down
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ Changelog = 'https://github.com/gsnedders/python-webencodings/releases'

[project.optional-dependencies]
doc = ['sphinx']
test = ['pytest']
test = ['pytest', 'ruff']

[tool.flit.sdist]
exclude = ['.*']

[tool.ruff.lint]
select = ['E', 'W', 'F', 'I', 'N', 'RUF']
ignore = ['RUF001', 'RUF002', 'RUF003']
21 changes: 16 additions & 5 deletions tests/test_webencodings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,16 @@
"""

from webencodings import (
lookup, LABELS, decode, encode, iter_decode, iter_encode, IncrementalDecoder,
IncrementalEncoder, UTF8)
LABELS,
UTF8,
IncrementalDecoder,
IncrementalEncoder,
decode,
encode,
iter_decode,
iter_encode,
lookup,
)


def assert_raises(exception, function, *args, **kwargs):
Expand Down Expand Up @@ -77,10 +85,13 @@ def test_decode():
assert decode(b'\xc3\xa9', 'utf8') == ('é', lookup('utf8'))
assert decode(b'\xc3\xa9', UTF8) == ('é', lookup('utf8'))
assert decode(b'\xc3\xa9', 'ascii') == ('é', lookup('ascii'))
assert decode(b'\xEF\xBB\xBF\xc3\xa9', 'ascii') == ('é', lookup('utf8')) # UTF-8 with BOM
# UTF-8 with BOM
assert decode(b'\xEF\xBB\xBF\xc3\xa9', 'ascii') == ('é', lookup('utf8'))

assert decode(b'\xFE\xFF\x00\xe9', 'ascii') == ('é', lookup('utf-16be')) # UTF-16-BE with BOM
assert decode(b'\xFF\xFE\xe9\x00', 'ascii') == ('é', lookup('utf-16le')) # UTF-16-LE with BOM
# UTF-16-BE with BOM
assert decode(b'\xFE\xFF\x00\xe9', 'ascii') == ('é', lookup('utf-16be'))
# UTF-16-LE with BOM
assert decode(b'\xFF\xFE\xe9\x00', 'ascii') == ('é', lookup('utf-16le'))
assert decode(b'\xFE\xFF\xe9\x00', 'ascii') == ('\ue900', lookup('utf-16be'))
assert decode(b'\xFF\xFE\x00\xe9', 'ascii') == ('\ue900', lookup('utf-16le'))

Expand Down
1 change: 0 additions & 1 deletion webencodings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

from .labels import LABELS


VERSION = __version__ = '0.6-dev'


Expand Down
1 change: 0 additions & 1 deletion webencodings/x_user_defined.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import codecs


### Codec APIs

class Codec(codecs.Codec):
Expand Down

0 comments on commit 05a312d

Please sign in to comment.