Skip to content

Commit 7c144ad

Browse files
committed
Switch to Ruff for linting, add MyPy type checking, update GitHub Actions workflow, and refine configuration files.
1 parent 8b8b1bf commit 7c144ad

4 files changed

Lines changed: 48 additions & 20 deletions

File tree

.github/workflows/tests-and-linting.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,17 @@ permissions:
1111

1212
jobs:
1313
build:
14-
1514
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
python-version: ["3.10", "3.11", "3.12"]
1618

1719
steps:
18-
- uses: actions/checkout@v3
19-
- name: Set up Python 3.11
20-
uses: actions/setup-python@v3
20+
- uses: actions/checkout@v4
21+
- name: Set up Python ${{ matrix.python-version }}
22+
uses: actions/setup-python@v5
2123
with:
22-
python-version: "3.11"
24+
python-version: ${{ matrix.python-version }}
2325
- name: Install dependencies
2426
run: |
2527
python -m pip install --upgrade pip
@@ -32,7 +34,7 @@ jobs:
3234
run: |
3335
poetry run pytest --cov=flare_explorer --cov-report xml:coverage.xml
3436
- name: Coverage
35-
uses: codecov/codecov-action@v2.1.0
37+
uses: codecov/codecov-action@v5
3638
with:
3739
token: ${{ secrets.CODECOV_TOKEN }}
3840
file: ./coverage.xml

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<a href="https://pypi.org/project/flare-explorer-python" target="_blank">
66
<img src="https://img.shields.io/pypi/pyversions/flare-explorer-python.svg?color=%2334D058" alt="Supported Python versions">
77
</a>
8-
[![Code Style](https://img.shields.io/badge/code_style-black-black)](https://black.readthedocs.io/en/stable/)
8+
[![Code Style](https://img.shields.io/badge/code_style-ruff-orange)](https://docs.astral.sh/ruff/)
99
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
1010

1111
A lightweight library that works as a connector to the [Flare explorer api](https://flare-explorer.flare.network/graphiql)

flare_explorer/address.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
from __future__ import annotations
2+
13
from decimal import Decimal
4+
from typing import List
25

36
from pydantic import BaseModel
47

@@ -52,7 +55,7 @@ def get_address(address_hash: str) -> Address:
5255
return Address(**response["address"])
5356

5457

55-
def get_addresses(address_hashes: [str]) -> [Address]:
58+
def get_addresses(address_hashes: List[str]) -> List[Address]:
5659
"""
5760
Get multiple addresses in one call.
5861
API complexity limit is 15 addresses at once

pyproject.toml

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,46 @@ pytest = "^8.4.0"
3333
requests-mock = "^1.12.0"
3434
pytest-cov = "^6.2.0"
3535
ruff = "^0.12.0"
36+
mypy = "^1.13.0"
37+
types-requests = "^2.32.0"
3638

3739
[build-system]
3840
requires = ["poetry-core"]
3941
build-backend = "poetry.core.masonry.api"
4042

4143
[tool.ruff]
42-
select = ["E", "F"]
43-
ignore = ["E501"]
44-
fixable = []
45-
unfixable = ["B"]
46-
exclude = [
47-
".git",
48-
"__pypackages__",
49-
"_build",
50-
"build",
51-
"dist",
52-
]
53-
per-file-ignores = {}
5444
line-length = 88
5545
target-version = "py310"
46+
47+
[tool.ruff.lint]
48+
select = [
49+
"E", # pycodestyle errors
50+
"W", # pycodestyle warnings
51+
"F", # Pyflakes
52+
"I", # isort
53+
"B", # flake8-bugbear
54+
"C4", # flake8-comprehensions
55+
"UP", # pyupgrade
56+
"SIM", # flake8-simplify
57+
]
58+
ignore = ["E501"] # line too long
59+
fixable = ["ALL"]
60+
unfixable = []
61+
62+
[tool.ruff.format]
63+
quote-style = "double"
64+
indent-style = "space"
65+
skip-magic-trailing-comma = false
66+
line-ending = "auto"
67+
68+
[tool.mypy]
69+
python_version = "3.10"
70+
check_untyped_defs = true
71+
disallow_any_generics = true
72+
disallow_incomplete_defs = true
73+
disallow_untyped_defs = true
74+
no_implicit_optional = true
75+
warn_redundant_casts = true
76+
warn_unused_ignores = true
77+
warn_return_any = true
78+
strict_equality = true

0 commit comments

Comments
 (0)