Skip to content

Commit 5088ea4

Browse files
committed
Update project files
1 parent 0caee64 commit 5088ea4

19 files changed

Lines changed: 250 additions & 141 deletions

.flake8

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,27 @@
33
# max-complexity = 10
44
doctests = true
55
# https://github.com/psf/black/blob/main/docs/guides/using_black_with_other_tools.md
6+
# - E203: whitespace before ‘,’, ‘;’, or ‘:’
7+
# - E701: multiple statements on one line (colon)
8+
# - E704: multiple statements on one line (def)
9+
# + W504: line break after binary operator
10+
# https://www.pydocstyle.org/en/stable/error_codes.html
11+
# - D105: undocumented-magic-method
12+
# - D107: undocumented-public-init
13+
# https://github.com/gforcada/flake8-builtins?tab=readme-ov-file#rules
14+
# - A003: A class attribute is shadowing a Python builtin.
15+
# - A005: A module is shadowing a Python builtin module (e.g: logging or socket)
16+
# https://github.com/PyCQA/flake8-bugbear?tab=readme-ov-file#list-of-warnings
17+
# + B950: (smart) Line too long
18+
# https://github.com/orsinium-labs/flake8-todos
19+
# - T003: add link on issue into TODO.
20+
# https://github.com/plinss/flake8-noqa?tab=readme-ov-file#error-codes
21+
# NQA102: "# noqa: X000" has no matching violations
22+
# misc
23+
# - I # flake8-import-order: not compatible with isort
24+
# - SC # flake8-spellcheck: too aggressive
25+
# - CNL # flake8-class-newline: incompatible with black
626
extend-ignore = E203,E501,E701,W503,SC,CNL
7-
# extend-ignore = I # flake8-import-order: not compatible with isort
8-
# extend-ignore = SC # flake8-spellcheck: too aggressive
9-
# extend-ignore = CNL # flake8-class-newline: incompatible with black
10-
# extend-ignore = A003,A005 # Python builtin is shadowed by class attribute / module
11-
# https://docs.astral.sh/ruff/rules/#pydocstyle-d
12-
# extend-ignore = D105 # undocumented-magic-method
13-
# extend-ignore = D107 # undocumented-public-init
1427
extend-select = W504,B950
1528
per-file-ignores =
1629
*/tests/test_*.py: D,T003
@@ -19,6 +32,7 @@ per-file-ignores =
1932
bpack/codecs.py: A005
2033
bpack/typing.py: A005
2134
bpack/tests/test_future_annotations.py: D,T003,NQA102
35+
bpack/tests/test_backends_codec.py: D,T003, BLK100
2236
statistics = True
2337
count = True
2438
extend-exclude = examples/*

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
steps:
2222
- uses: actions/checkout@v4
2323
with:
24+
fetch-depth: 0
2425
submodules: 'true'
2526

2627
- name: Set up Python

.github/workflows/lint.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,31 @@ jobs:
3535
3636
- name: Lint (flake8)
3737
run: |
38+
python -m flake8 --version
3839
python -m flake8 --count --show-source --statistics ${PACKAGE}
3940
4041
- name: Lint (pydocstyle)
4142
run: |
43+
python -m pydocstyle --version
4244
python -m pydocstyle --count ${PACKAGE}
4345
4446
- name: Lint (isort)
4547
run: |
48+
python -m isort --version
4649
python -m isort --check ${PACKAGE}
4750
4851
- name: Lint (black)
4952
run: |
53+
python -m black --version
5054
python -m black --check ${PACKAGE}
55+
# python -m black --diff ${PACKAGE}
56+
57+
# - name: Lint (mypy)
58+
# run: |
59+
# python -m mypy --version
60+
# python -m mypy ${PACKAGE}
61+
62+
# - name: Lint (ruff)
63+
# run: |
64+
# ruff --version
65+
# ruff check ${PACKAGE}

.gitignore

Lines changed: 52 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Byte-compiled / optimized / DLL files
22
__pycache__/
3-
*.py[cod]
3+
*.py[codz]
44
*$py.class
55

66
# C extensions
@@ -46,7 +46,7 @@ htmlcov/
4646
nosetests.xml
4747
coverage.xml
4848
*.cover
49-
*.py,cover
49+
*.py.cover
5050
.hypothesis/
5151
.pytest_cache/
5252
cover/
@@ -94,23 +94,36 @@ ipython_config.py
9494
# install all needed dependencies.
9595
#Pipfile.lock
9696

97+
# UV
98+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99+
# This is especially recommended for binary packages to ensure reproducibility, and is more
100+
# commonly ignored for libraries.
101+
#uv.lock
102+
97103
# poetry
98104
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99105
# This is especially recommended for binary packages to ensure reproducibility, and is more
100106
# commonly ignored for libraries.
101107
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102108
#poetry.lock
109+
#poetry.toml
103110

104111
# pdm
105112
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
106115
#pdm.lock
107-
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108-
# in version control.
109-
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
110-
.pdm.toml
116+
#pdm.toml
111117
.pdm-python
112118
.pdm-build/
113119

120+
# pixi
121+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122+
#pixi.lock
123+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124+
# in the .venv directory. It is recommended not to include this directory in version control.
125+
.pixi
126+
114127
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
115128
__pypackages__/
116129

@@ -123,6 +136,7 @@ celerybeat.pid
123136

124137
# Environments
125138
.env
139+
.envrc
126140
.venv
127141
env/
128142
venv/
@@ -159,7 +173,35 @@ cython_debug/
159173
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
160174
# and can be added to the global gitignore or merged into this file. For a more nuclear
161175
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
162-
/.idea/
163-
164-
# VSCode
165-
/.vscode
176+
#.idea/
177+
178+
# Abstra
179+
# Abstra is an AI-powered process automation framework.
180+
# Ignore directories containing user credentials, local state, and settings.
181+
# Learn more at https://abstra.io/docs
182+
.abstra/
183+
184+
# Visual Studio Code
185+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
186+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
187+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
188+
# you could uncomment the following to ignore the entire vscode folder
189+
.vscode/
190+
191+
# Ruff stuff:
192+
.ruff_cache/
193+
194+
# PyPI configuration file
195+
.pypirc
196+
197+
# Cursor
198+
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
199+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
200+
# refer to https://docs.cursor.com/context/ignore-files
201+
.cursorignore
202+
.cursorindexingignore
203+
204+
# Marimo
205+
marimo/_static/
206+
marimo/_lsp/
207+
__marimo__/

.pre-commit-config.yaml

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# See https://pre-commit.com/hooks.html for more hooks
33
repos:
44
- repo: https://github.com/pre-commit/pre-commit-hooks
5-
rev: v5.0.0
5+
rev: v6.0.0
66
hooks:
77
- id: trailing-whitespace
88
- id: end-of-file-fixer
@@ -15,14 +15,14 @@ repos:
1515
- id: detect-private-key
1616

1717
# - repo: https://github.com/astral-sh/ruff-pre-commit
18-
# rev: v0.7.0
18+
# rev: v0.12.5
1919
# hooks:
2020
# - id: ruff
21-
# args: [ --fix ]
21+
# args: [--fix]
2222
# - id: ruff-format
2323

2424
- repo: https://github.com/asottile/pyupgrade
25-
rev: v3.19.1
25+
rev: v3.20.0
2626
hooks:
2727
- id: pyupgrade
2828
args: [--py39-plus]
@@ -35,7 +35,7 @@ repos:
3535
)
3636
3737
- repo: https://github.com/pycqa/flake8
38-
rev: 7.1.1
38+
rev: 7.3.0
3939
hooks:
4040
- id: flake8
4141

@@ -46,24 +46,33 @@ repos:
4646
exclude: tests|examples|data|docs
4747

4848
- repo: https://github.com/pycqa/isort
49-
rev: 5.13.2
49+
rev: 6.0.1
5050
hooks:
5151
- id: isort
5252
name: isort (python)
5353

5454
- repo: https://github.com/psf/black-pre-commit-mirror
55-
rev: 24.10.0
55+
rev: 25.1.0
5656
hooks:
5757
- id: black
5858
language_version: python3.10
59+
- id: black-jupyter
60+
language_version: python3.10
5961

6062
# - repo: https://github.com/pre-commit/mirrors-mypy
61-
# rev: v1.12.0
63+
# rev: v1.17.0
6264
# hooks:
6365
# - id: mypy
66+
# additional_dependencies:
67+
# - tokenize-rt==3.2.0
68+
# - numpy>=1.21
6469

65-
# - repo: https://github.com/codespell-project/codespell
66-
# rev: v2.2.4
67-
# hooks:
68-
# - id: codespell
69-
# additional_dependencies: [tomli]
70+
- repo: https://github.com/codespell-project/codespell
71+
rev: v2.4.1
72+
hooks:
73+
- id: codespell
74+
additional_dependencies: [tomli]
75+
exclude: |
76+
(?x)^(
77+
docs/spelling_wordlist.txt
78+
)

.readthedocs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ version: 2
88
build:
99
os: ubuntu-22.04
1010
tools:
11-
python: "3.11"
11+
python: "3"
1212

1313
# Build documentation in the "docs/" directory with Sphinx
1414
sphinx:
@@ -24,6 +24,6 @@ formats:
2424

2525
python:
2626
install:
27+
- requirements: docs/requirements-docs.txt
2728
- method: pip
2829
path: .
29-
- requirements: docs/requirements-docs.txt

Makefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@ clean:
4747

4848
cleaner: clean
4949
$(RM) -r .coverage htmlcov
50-
$(RM) -r .pytest_cache .tox
51-
$(RM) -r .mypy_cache .ruff_cache
50+
$(RM) -r .pytest_cache
51+
$(RM) -r .tox
52+
$(RM) -r .mypy_cache
53+
$(RM) -r .ruff_cache
5254
$(RM) -r .ipynb_checkpoints
5355

5456
distclean: cleaner
@@ -59,12 +61,16 @@ lint:
5961
$(PYTHON) -m pydocstyle --count $(TARGET)
6062
$(PYTHON) -m isort --check $(TARGET)
6163
$(PYTHON) -m black --check $(TARGET)
64+
# $(PYTHON) -m fawltydeps
6265
# $(PYTHON) -m mypy --check-untyped-defs --ignore-missing-imports $(TARGET)
6366
# ruff check $(TARGET)
67+
codespell
6468

6569
docs:
6670
mkdir -p docs/_static
6771
$(MAKE) -C docs html
72+
$(MAKE) -C docs linkcheck
73+
$(MAKE) -C docs spelling
6874

6975
api:
7076
$(RM) -r docs/api

bpack/bs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ def packbits(
234234
Please note that no check that the input values actually fits in the
235235
specified number of bits is performed is performed.
236236
237-
The function return a sting of bytes including same number of samples
237+
The function return a string of bytes including same number of samples
238238
of the input plus possibly some padding bit (at the end) to fill an
239239
integer number of bytes.
240240
@@ -244,7 +244,7 @@ def packbits(
244244
if (nsamples * bits_per_sample) % 8:
245245
warnings.warn(
246246
f"packing {nsamples} with {bits_per_sample} bits per "
247-
f"sample requires padding"
247+
"sample requires padding"
248248
)
249249
encoder_ = _get_sequence_codec(
250250
nsamples, bits_per_sample, signed=signed, byteorder=byteorder

bpack/codecs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def _check_descriptor(cls, descriptor):
3131
if bpack.baseunits(descriptor) is not cls.baseunits:
3232
raise ValueError(
3333
f"{cls.__module__}.{cls.__name__} "
34-
f"only accepts descriptors with base units "
34+
"only accepts descriptors with base units "
3535
f"'{cls.baseunits.value}'"
3636
)
3737

bpack/descriptors.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def _validate_signed(self):
125125
if not isinstance(self.signed, bool):
126126
raise TypeError(
127127
f"invalid 'signed' parameter: {self.signed!r} "
128-
f"(must be a bool or None)"
128+
"(must be a bool or None)"
129129
)
130130

131131
def _validate_repeat(self):
@@ -144,7 +144,7 @@ def __post_init__(self):
144144
"""Finalize BinFieldDescriptor instance initialization."""
145145
if isinstance(self.type, str):
146146
raise TypeError(
147-
f"the 'type' parameter cannot be a string "
147+
"the 'type' parameter cannot be a string "
148148
f"(type_: {self.type!r})"
149149
)
150150

@@ -170,21 +170,21 @@ def validate(self):
170170
self._validate_signed()
171171
if not self.is_int_type():
172172
warnings.warn(
173-
f"the 'signed' parameter will be ignored for non-integer "
173+
"the 'signed' parameter will be ignored for non-integer "
174174
f"type: '{self.type!r}'"
175175
)
176176
if self.repeat is not None:
177177
self._validate_repeat()
178178
if not self.is_sequence_type() and self.repeat is not None:
179179
raise TypeError(
180-
f"repeat parameter specified for non-sequence type: "
180+
"repeat parameter specified for non-sequence type: "
181181
f"{self.type!r}"
182182
)
183183
if bpack.utils.is_enum_type(self.type):
184184
self._validate_enum_type()
185185
elif self.is_sequence_type() and self.repeat is None:
186186
raise TypeError(
187-
f"no 'repeat' parameter specified for sequence type "
187+
"no 'repeat' parameter specified for sequence type "
188188
f"{self.type!r}"
189189
)
190190

0 commit comments

Comments
 (0)