Skip to content

Commit

Permalink
Use pyproject.toml and ruff (#248)
Browse files Browse the repository at this point in the history
* move to ruff and pyproject

* flit

* per file ignores

* changelog

* update test
  • Loading branch information
mscroggs authored Nov 24, 2023
1 parent 1e1be12 commit f26f36a
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 76 deletions.
12 changes: 5 additions & 7 deletions ++version.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,15 @@
with open("codemeta.json", "w") as f:
json.dump(data, f)

# setup.py
# pyproject.toml
new_setup = ""
with open("setup.py") as f:
with open("pyproject.toml") as f:
for line in f:
if 'version="' in line:
a, b = line.split('version="')
b = b.split('"', 1)[1]
new_setup += f'{a}version="{new_version_str}"{b}'
if 'version ="' in line:
new_setup += f'version = "{new_version_str}"\n'
else:
new_setup += line
with open("setup.py", "w") as f:
with open("pyproject.toml", "w") as f:
f.write(new_setup)

# symfem/version.py
Expand Down
4 changes: 4 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
max-line-length = 100
per-file-ignores =
*/__init__.py: F401
4 changes: 2 additions & 2 deletions .github/workflows/style-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
- uses: actions/checkout@v3
- run: sudo apt-get install -y python3-setuptools
- run: pip3 install -e .[style,docs]
- run: python3 -m ruff check .
name: Run ruff checks
- run: python3 -m flake8 .
name: Run flake8 checks
- run: python3 -m pydocstyle .
name: Run pydocstyle checks
- run: python3 -m mypy .
name: Run mypy checks
- run: python3 -m isort --check .
Expand Down
42 changes: 42 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[build-system]
build-backend = "flit_core.buildapi"
requires = ["flit_core >=3.8.0,<4"]

[project]
name = "symfem"
version = "2023.8.2"
description = "a symbolic finite element definition library"
readme = "README.md"
requires-python = ">=3.8.0"
license = { file = "LICENSE" }
authors = [
{ name = "Matthew Scroggs", email = "symfem@mscroggs.co.uk" }
]
packages = ["symfem", "symfem.elements", "symfem.polynomials"]
dependencies = ["sympy>=1.10", "appdirs"]

[project.urls]
homepage = "https://github.com/mscroggs/symfem"
repository = "https://github.com/mscroggs/symfem"
documentation = "https://symfem.readthedocs.io/en/latest/"

[project.optional-dependencies]
style = ["ruff", "flake8", "mypy", "isort"]
docs = ["sphinx", "sphinx-autoapi"]
optional = ["CairoSVG>=2.6.0"]
test = ["pytest", "symfem[optional]", "numpy"]

[tool.ruff]
line-length = 100

[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401"]

[tool.ruff.lint.pydocstyle]
convention = "google"

[tool.mypy]
ignore_missing_imports = true

[tool.isort]
line_length = 100
15 changes: 0 additions & 15 deletions setup.cfg

This file was deleted.

48 changes: 0 additions & 48 deletions setup.py

This file was deleted.

8 changes: 4 additions & 4 deletions test/test_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,11 @@ def test_version_numbers():
assert data["version"] == version
date = data["dateModified"]

# setup.py
with open(os.path.join(root, "setup.py")) as f:
# pyproject.toml
with open(os.path.join(root, "pyproject.toml")) as f:
for line in f:
if 'version="' in line:
assert line.split('version="')[1].split('"')[0] == version
if 'version = "' in line:
assert line.split('version = "')[1].split('"')[0] == version

# symfem/version.py
with open(os.path.join(root, "symfem/version.py")) as f:
Expand Down

0 comments on commit f26f36a

Please sign in to comment.