diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 4a8ce39..34224c6 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -26,10 +26,8 @@ jobs: python-version: "3.11" - name: Install dependencies run: make setup-dev - - name: Lint with flake8 - run: make flake8 - - name: Run formatters - run: make format-check + - name: Lint and check formatting + run: make check - name: Typecheck with mypy run: make mypy - name: Check script diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e03a73b..0a26ffc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,25 +1,20 @@ # See https://pre-commit.com for more information # See https://pre-commit.com/hooks.html for more hooks repos: -- repo: local - hooks: - - id: mypy - name: mypy - entry: mypy --strict - language: system - types: [python] - - id: black - name: black - entry: black - language: system - types: [python] - - id: isort - name: isort - entry: isort - language: system - types: [python] - - id: flake8 - name: flake8 - entry: flake8 - language: system - types: [python] + - repo: local + hooks: + - id: mypy + name: mypy + entry: mypy --strict + language: system + types: [python] + - id: ruff-check + name: ruff check + entry: ruff check --fix + language: system + types: [python] + - id: ruff-format + name: ruff format + entry: ruff format + language: system + types: [python] diff --git a/bibtexautocomplete/utils/constants.py b/bibtexautocomplete/utils/constants.py index 820f0ea..6804f4a 100644 --- a/bibtexautocomplete/utils/constants.py +++ b/bibtexautocomplete/utils/constants.py @@ -10,7 +10,7 @@ URL = "https://github.com/dlesbre/bibtex-autocomplete" ISSUES_URL = URL + "/issues" LICENSE = "MIT" -DESCRIPTION = "Module to complete bibtex files by polling online databases" +DESCRIPTION = "Script to autocomplete bibtex files by polling online databases" VERSION_MAJOR = 1 VERSION_MINOR = 3 diff --git a/makefile b/makefile index 7cb9f0d..06fdfa0 100644 --- a/makefile +++ b/makefile @@ -95,25 +95,19 @@ mypy: ## Typecheck all files $(call print,Running mypy) $(MYPY) --strict ./bibtexautocomplete/ ./tests ./setup.py -.PHONY: flake8 -flake8: ## Run flake8 on all files - $(call print,Running flake8) - find bibtexautocomplete -type f -name "*.py" -exec flake8 {} ';' - find tests -type f -name "*.py" -exec flake8 {} ';' - .PHONY: format format: ## Format files with black and isort - $(call print,Running black) - black ./bibtexautocomplete/ ./tests/ - $(call print,Running isort) - isort ./bibtexautocomplete/ ./tests/ + $(call print,Running ruff format) + ruff format + $(call print,Running ruff check and fix) + ruff check --fix .PHONY: format-check -format-check: ## Check that all files are formatted - $(call print,Running black) - black ./bibtexautocomplete/ ./tests/ --check - $(call print,Running isort) - isort ./bibtexautocomplete/ ./tests/ --check +check: ## Check that all files are formatted and lint + $(call print,Running ruff format) + ruff format --check + $(call print,Running ruff check) + ruff check # ================================================= # Installation @@ -143,15 +137,15 @@ clean: ## Remove package .PHONY: clean-all clean-all: ## Remove package and venv $(call print,Removing package and dependencies and virtual environment) - rm -rf build bibtexautocomplete.egg-info + rm -rf build bibtexautocomplete.egg-info htmlcov rm -rf venv .PHONY: deploy deploy: ## Build and deploys the package $(call print,Removing previous dist) - rm -rf dist/* + rm -rf dist/* bibtexautocomplete.egg-info build $(call print,Building package) - $(PYTHON) setup.py sdist bdist_wheel + $(PYTHON) -m build $(call print,Deploying package) twine upload dist/* diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..d110b39 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,71 @@ +[project] +name = "bibtexautocomplete" +authors = [{ name = "Dorian Lesbre", email = "dorian.lesbre@gmail.com" }] +maintainers = [{ name = "Dorian Lesbre", email = "dorian.lesbre@gmail.com" }] +dynamic = ["version"] +description = "Script to autocomplete bibtex files by polling online databases" +requires-python = ">= 3.8" +readme = "README.md" +license = {file = "LICENSE"} +keywords = ["bibtex", "biblatex", "latex", "autocomplete", "btac"] +dependencies = [ + "bibtexparser<2.0.0", + "alive-progress>=3.0.0", +] +classifiers = [ + # How mature is this project? Common values are + # 3 - Alpha + # 4 - Beta + # 5 - Production/Stable + "Development Status :: 5 - Production/Stable", + # Indicate who your project is intended for + "Intended Audience :: Science/Research", + "Intended Audience :: Developers", + "Environment :: Console", + "Natural Language :: English", + # Pick your license as you wish (should match "license" above) + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3", + "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 :: Text Processing :: Markup :: LaTeX", + "Topic :: Utilities", + "Topic :: Scientific/Engineering", + "Typing :: Typed", +] + +[project.urls] +Homepage = "https://github.com/dlesbre/bibtex-autocomplete" +Repository = "https://github.com/dlesbre/bibtex-autocomplete/spam.git" +Issues = "https://github.com/dlesbre/bibtex-autocomplete/issues" +Changelog = "https://github.com/dlesbre/bibtex-autocomplete/blob/master/CHANGELOG.md" + +[project.scripts] +btac = "bibtexautocomplete.core:main" + +[project.optional-dependencies] +dev = [ + "pre-commit", + "pytest", + "mypy", + "ruff", + "coverage", + "pytest-cov", +] + +[tool.ruff] +line-length = 120 + +[tool.ruff.lint] +select = ["E", "F", "B", "W", "I"] + +[tool.mypy] +strict = true + +[[tool.mypy.overrides]] +module = "bibtexparser.*" +ignore_missing_imports = true diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 5b24d3b..0000000 --- a/setup.cfg +++ /dev/null @@ -1,25 +0,0 @@ -[flake8] -max-line-length = 110 -ignore = - # whitespace before ':' (not PEP8-compliant for slicing) - E203, - # lambda expression - E731, - # line break before binary operator (not PEP8-compliant) - W503, - -[isort] -# For black compat: https://github.com/ambv/black#how-black-wraps-lines -combine_as_imports = true -default_section = THIRDPARTY -force_grid_wrap = 0 -include_trailing_comma = true -known_first_party = -line_length = 88 -multi_line_output = 3 -sections = FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER - -[mypy] - -[mypy-bibtexparser.*] -ignore_missing_imports = True diff --git a/setup.py b/setup.py deleted file mode 100644 index e7b0cda..0000000 --- a/setup.py +++ /dev/null @@ -1,71 +0,0 @@ -""" -setup file. run 'python3 setup.py install' to install. -""" -from setuptools import find_packages, setup # type: ignore - -import bibtexautocomplete - -with open("README.md", "r", encoding="utf-8") as fh: - long_description = fh.read() - -setup( - name=bibtexautocomplete.__name__, - version=bibtexautocomplete.__version__, - author=bibtexautocomplete.__author__, - author_email=bibtexautocomplete.__email__, - url=bibtexautocomplete.__url__, - description=bibtexautocomplete.__description__, - long_description=long_description, - long_description_content_type="text/markdown", - packages=find_packages(), - entry_points={ - "console_scripts": "btac = bibtexautocomplete.core:main", - }, - install_requires=[ - "bibtexparser<2.0.0", - "alive-progress>=3.0.0", - ], - extras_require={ - "dev": [ - "pre-commit", - "pytest", - "mypy", - "black", - "flake8", - "isort", - "coverage", - "pytest-cov", - ], - "deploy": ["wheel", "twine"], - }, - python_requires=">=3.8", - license="MIT", - platforms=["any"], - keywords=["bibtex biblatex latex autocomplete btac"], - classifiers=[ - # How mature is this project? Common values are - # 3 - Alpha - # 4 - Beta - # 5 - Production/Stable - "Development Status :: 5 - Production/Stable", - # Indicate who your project is intended for - "Intended Audience :: Science/Research", - "Intended Audience :: Developers", - "Environment :: Console", - "Natural Language :: English", - # Pick your license as you wish (should match "license" above) - "License :: OSI Approved :: MIT License", - "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3", - "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 :: Text Processing :: Markup :: LaTeX", - "Topic :: Utilities", - "Topic :: Scientific/Engineering", - "Typing :: Typed", - ], - data_files=[("", ["LICENSE"])], -)