Skip to content

Commit

Permalink
merge template updates, drop py37, add pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
pacrob committed Nov 3, 2023
2 parents dce3dcf + 885bef7 commit 4e69b83
Show file tree
Hide file tree
Showing 14 changed files with 101 additions and 112 deletions.
15 changes: 0 additions & 15 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ common: &common
- .tox
- ~/.cache/pip
- ~/.local
- ./eggs
key: cache-v1-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }}

orbs:
Expand Down Expand Up @@ -74,12 +73,6 @@ jobs:
environment:
TOXENV: docs

py37-core:
<<: *common
docker:
- image: cimg/python:3.7
environment:
TOXENV: py37-core
py38-core:
<<: *common
docker:
Expand Down Expand Up @@ -130,12 +123,6 @@ jobs:
environment:
TOXENV: py311-lint

py37-wheel:
<<: *common
docker:
- image: cimg/python:3.7
environment:
TOXENV: py37-wheel
py38-wheel:
<<: *common
docker:
Expand Down Expand Up @@ -171,7 +158,6 @@ workflows:
test:
jobs:
- docs
- py37-core
- py38-core
- py39-core
- py310-core
Expand All @@ -180,7 +166,6 @@ workflows:
- py39-lint
- py310-lint
- py311-lint
- py37-wheel
- py38-wheel
- py39-wheel
- py310-wheel
Expand Down
6 changes: 3 additions & 3 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ Closes #

### Todo:

- \[ \] Clean up commit history
- [ ] Clean up commit history

- \[ \] Add or update documentation related to these changes
- [ ] Add or update documentation related to these changes

- \[ \] Add entry to the [release notes](https://github.com/ethereum/hexbytes/blob/master/newsfragments/README.md)
- [ ] Add entry to the [release notes](https://github.com/ethereum/hexbytes/blob/master/newsfragments/README.md)

#### Cute Animal Picture

Expand Down
10 changes: 9 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
exclude: '.project-template|docs/conf.py'
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
rev: v4.5.0
hooks:
- id: check-yaml
- id: check-toml
Expand All @@ -18,6 +18,10 @@ repos:
additional_dependencies:
- flake8-bugbear==23.9.16
exclude: setup.py
- repo: https://github.com/PyCQA/autoflake
rev: v2.2.1
hooks:
- id: autoflake
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
Expand All @@ -26,10 +30,14 @@ repos:
rev: 6.3.0
hooks:
- id: pydocstyle
additional_dependencies:
- tomli # required until >= python311
- repo: https://github.com/executablebooks/mdformat
rev: 0.7.17
hooks:
- id: mdformat
additional_dependencies:
- mdformat-gfm
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.5.1
hooks:
Expand Down
30 changes: 0 additions & 30 deletions .pydocstyle.ini

This file was deleted.

6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ clean: clean-build clean-pyc
clean-build:
rm -fr build/
rm -fr dist/
rm -fr *.egg-info

clean-pyc:
find . -name '*.pyc' -exec rm -f {} +
Expand All @@ -26,7 +25,10 @@ clean-pyc:
find . -name '__pycache__' -exec rm -rf {} +

lint:
pre-commit run --all-files --show-diff-on-failure
@pre-commit run --all-files --show-diff-on-failure || ( \
echo "\n\n\n * pre-commit should have fixed the errors above. Running again to make sure everything is good..." \
&& pre-commit run --all-files --show-diff-on-failure \
)

test:
pytest tests
Expand Down
6 changes: 6 additions & 0 deletions hexbytes/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
from importlib.metadata import (
version as __version,
)

from .main import (
HexBytes,
)

__all__ = ["HexBytes"]

__version__ = __version("hexbytes")
15 changes: 3 additions & 12 deletions hexbytes/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import sys
from typing import (
TYPE_CHECKING,
Type,
Expand All @@ -12,17 +11,9 @@
)

if TYPE_CHECKING:
# remove once hexbytes supports python>=3.8
# Types was added to typing in 3.8
if sys.version_info >= (3, 8):
from typing import (
SupportsIndex,
)
else:
from typing_extensions import ( # noqa: F401
SupportsIndex,
)

from typing import (
SupportsIndex,
)

BytesLike = Union[bool, bytearray, bytes, int, str, memoryview]

Expand Down
16 changes: 0 additions & 16 deletions mypy.ini

This file was deleted.

1 change: 1 addition & 0 deletions newsfragments/39.breaking.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Drop python 3.7 support
1 change: 1 addition & 0 deletions newsfragments/39.internal.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Merge template updates, including additional linting, move most lint config to pyproject.toml
69 changes: 69 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,72 @@
[tool.autoflake]
remove_all_unused_imports = "True"
exclude = "__init__.py"

[tool.isort]
combine_as_imports = "True"
extra_standard_library = "pytest"
force_grid_wrap = 1
force_sort_within_sections = "True"
known_third_party = "hypothesis,pytest"
known_first_party = "hexbytes"
multi_line_output = 3
profile = "black"

[tool.mypy]
check_untyped_defs = "True"
disallow_incomplete_defs = "True"
disallow_untyped_defs = "True"
disallow_any_generics = "True"
disallow_untyped_calls = "True"
disallow_untyped_decorators = "True"
disallow_subclassing_any = "True"
ignore_missing_imports = "True"
strict_optional = "True"
strict_equality = "True"
warn_redundant_casts = "True"
warn_return_any = "True"
warn_unused_configs = "True"
warn_unused_ignores = "True"


[tool.pydocstyle]
# All error codes found here:
# http://www.pydocstyle.org/en/3.0.0/error_codes.html
#
# Ignored:
# D1 - Missing docstring error codes
#
# Selected:
# D2 - Whitespace error codes
# D3 - Quote error codes
# D4 - Content related error codes
select = "D2,D3,D4"

# Extra ignores:
# D200 - One-line docstring should fit on one line with quotes
# D203 - 1 blank line required before class docstring
# D204 - 1 blank line required after class docstring
# D205 - 1 blank line required between summary line and description
# D212 - Multi-line docstring summary should start at the first line
# D302 - Use u""" for Unicode docstrings
# D400 - First line should end with a period
# D401 - First line should be in imperative mood
# D412 - No blank lines allowed between a section header and its content
# D415 - First line should end with a period, question mark, or exclamation point
add-ignore = "D200,D203,D204,D205,D212,D302,D400,D401,D412,D415"

# Explanation:
# D400 - Enabling this error code seems to make it a requirement that the first
# sentence in a docstring is not split across two lines. It also makes it a
# requirement that no docstring can have a multi-sentence description without a
# summary line. Neither one of those requirements seem appropriate.

[tool.pytest.ini_options]
addopts = "-v --showlocals --durations 10"
xfail_strict = "True"
log_format = "%(levelname)8s %(asctime)s %(filename)20s %(message)s"
log_date_format = "%m-%d %H:%M:%S"

[tool.towncrier]
# Read https://github.com/ethereum/hexbytes/blob/master/newsfragments/README.md for instructions
package = "hexbytes"
Expand Down
8 changes: 0 additions & 8 deletions pytest.ini

This file was deleted.

4 changes: 1 addition & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"bumpversion>=0.5.3",
"ipython",
"pre-commit>=3.4.0",
"pytest-watch>=4.1.0",
"tox>=4.0.0",
"twine",
"wheel",
Expand Down Expand Up @@ -50,7 +49,7 @@
url="https://github.com/ethereum/hexbytes",
include_package_data=True,
install_requires=[],
python_requires=">=3.7, <4",
python_requires=">=3.8, <4",
extras_require=extras_require,
py_modules=["hexbytes"],
license="MIT",
Expand All @@ -64,7 +63,6 @@
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
Expand Down
26 changes: 4 additions & 22 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
[tox]
envlist=
py{37,38,39,310,311}-core
py{38,39,310,311}-core
py{38,39,310,311}-lint
py{37,38,39,310,311}-wheel
py{38,39,310,311}-wheel
py311-wheel-windows
docs

[isort]
combine_as_imports=True
force_grid_wrap=1
force_sort_within_sections=True
known_third_party=hypothesis,pytest,eth_utils
known_first_party=hexbytes
multi_line_output=3
profile=black

[flake8]
exclude=venv*,.tox,docs,build
extend-ignore=E203
Expand All @@ -28,7 +19,6 @@ commands=
docs: make check-docs
basepython=
docs: python
py37: python3.7
py38: python3.8
py39: python3.9
py310: python3.10
Expand All @@ -38,20 +28,12 @@ extras=
docs
allowlist_externals=make,pre-commit

[common-lint]
basepython=python
[testenv:py{38,39,310,311}-lint]
deps=pre-commit
commands=
pre-commit run --all-files --show-diff-on-failure

[testenv:lint]
basepython: python
commands: {[common-lint]commands}

[testenv:py{38,39,310,311}-lint]
commands: {[common-lint]commands}

[testenv:py{37,38,39,310,311}-wheel]
[testenv:py{38,39,310,311}-wheel]
deps=
wheel
build[virtualenv]
Expand Down

0 comments on commit 4e69b83

Please sign in to comment.