Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modernize pre-commits and pyproject #220

Merged
merged 4 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions .bumpversion.cfg

This file was deleted.

36 changes: 6 additions & 30 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
repos:
# Syntax validation and some basic sanity checks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
Expand All @@ -9,33 +8,10 @@ repos:
- id: check-json
- id: check-yaml

# Automatically sort imports
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.2
hooks:
- id: isort
args: [
# '-a', 'from __future__ import annotations', # 3.7-3.11
'--rm', 'from __future__ import absolute_import', # -3.0
'--rm', 'from __future__ import division', # -3.0
# '--rm', 'from __future__ import generator_stop', # -3.7
'--rm', 'from __future__ import generators', # -2.3
'--rm', 'from __future__ import nested_scopes', # -2.2
'--rm', 'from __future__ import print_function', # -3.0
'--rm', 'from __future__ import unicode_literals', # -3.0
'--rm', 'from __future__ import with_statement', # -2.6
]

# Automatic source code formatting
- repo: https://github.com/psf/black
rev: 24.8.0
hooks:
- id: black
args: [--safe, --quiet]

# Linting
- repo: https://github.com/PyCQA/flake8
rev: 7.1.1
hooks:
- id: flake8
additional_dependencies: ['flake8-comprehensions==3.8.0']
- id: ruff
args: [--fix, --exit-non-zero-on-fix, --show-fixes]
- id: ruff-format
types: [file]
4 changes: 2 additions & 2 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

First, ensure that you have updated `HISTORY.rst` with the changes for the new release and committed the changes.

To prepare an ISPyB API release you need to install the package [bump2version](https://pypi.org/project/bump2version/):
To prepare an ISPyB API release you need to install the package [bump-my-version](https://github.com/callowayproject/bump-my-version):

```bash
pip install bump2version
pip install bump-my-version
```

and then, in the repository directory, run one of the following
Expand Down
1 change: 0 additions & 1 deletion bin/legacy/em_put_particle.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import sys

if __name__ == "__main__":

from ispyb_api.dbconnection import dbconnection
from ispyb_api.em import em

Expand Down
1 change: 0 additions & 1 deletion bin/legacy/em_put_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import sys

if __name__ == "__main__":

from ispyb_api.core import core
from ispyb_api.dbconnection import dbconnection

Expand Down
1 change: 0 additions & 1 deletion bin/legacy/put_dcgroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import sys

if __name__ == "__main__":

from datetime import datetime

from ispyb_api.core import core
Expand Down
1 change: 0 additions & 1 deletion bin/legacy/put_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
# 1 = success

if __name__ == "__main__":

from datetime import datetime

from ispyb_api.dbconnection import dbconnection
Expand Down
76 changes: 72 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,72 @@
[tool.isort]
#sections="FUTURE,STDLIB,THIRDPARTY,CCTBX,FIRSTPARTY,LOCALFOLDER"
known_firstparty="ispyb"
profile="black"
[build-system]
requires = ["setuptools>=61.2"]
build-backend = "setuptools.build_meta"

[project]
name = "ispyb"
version = "10.2.3"
description = "Python package to access ISPyB database"
authors = [
{ name = "Diamond Light Source", email = "[email protected]" },
]
classifiers = [
"Development Status :: 5 - Production/Stable",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Operating System :: OS Independent",
"Topic :: Software Development :: Libraries :: Python Modules",
]
keywords = ["ISPyB", "database"]
requires-python = ">=3.7"
readme = "README.md"
license = { text = "Apache License 2.0" }
dependencies = ["mysql-connector-python>=8.0.32", "sqlalchemy<2", "tabulate"]

[project.urls]
Documentation = "https://ispyb.readthedocs.io"
GitHub = "https://github.com/DiamondLightSource/ispyb-api"
Bug-Tracker = "https://github.com/DiamondLightSource/ispyb-api/issues"

[project.entry-points."libtbx.dispatcher.script"]
"ispyb.job" = "ispyb.job"
"ispyb.last_data_collections_on" = "ispyb.last_data_collections_on"

[project.entry-points."libtbx.precommit"]
ispyb = "ispyb"

[project.scripts]
"ispyb.job" = "ispyb.cli.job:main"
"ispyb.last_data_collections_on" = "ispyb.cli.last_data_collections_on:main"

[tool.setuptools]
script-files = ["bin/dimple2ispyb.py", "bin/mxdatareduction2ispyb.py"]

[tool.ruff.lint.isort]
known-first-party = ["ispyb"]

[tool.ruff.lint]
select = ["E", "F", "W", "C4", "I"]
unfixable = ["F841"]
# E501 line too long (if formatter cannot split, we don't worry)
ignore = ["E501"]

[tool.bumpversion]
current_version = "10.2.3"
commit = true
tag = true


[[tool.bumpversion.files]]
filename = "pyproject.toml"
search = 'version = "{current_version}"'
replace = 'version = "{new_version}"'

[[tool.bumpversion.files]]
filename = "src/ispyb/__init__.py"
search = '__version__ = "{current_version}"'
replace = '__version__ = "{new_version}"'
71 changes: 0 additions & 71 deletions setup.cfg

This file was deleted.

4 changes: 0 additions & 4 deletions setup.py

This file was deleted.