Skip to content

Commit

Permalink
Merge branch 'AntObi-ruff' into docs_updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthony Onwuli committed Aug 19, 2024
2 parents 4f9b176 + 5bbaad6 commit c240161
Show file tree
Hide file tree
Showing 33 changed files with 1,142 additions and 1,191 deletions.
33 changes: 10 additions & 23 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,11 @@
repos:
- repo: https://github.com/timothycrosley/isort
rev: "5.12.0"
hooks:
- id: isort
additional_dependencies: [toml]
args: ["--profile", "black", "--filter-files","--line-length=80"]
- repo: https://github.com/psf/black
rev: "23.1.0"
hooks:
- id: black-jupyter
args: [--line-length=80]
- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
hooks:
- id: pyupgrade
args: [--py38-plus]
- repo: https://github.com/nbQA-dev/nbQA
rev: "1.6.1"
hooks:
- id: nbqa-pyupgrade
additional_dependencies: [pyupgrade==3.3.1]
args: [--py38-plus]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.1
hooks:
# Run the linting tool
- id: ruff
types_or: [ python, pyi ]
args: [--fix]
# Run the formatter
- id: ruff-format
types_or: [ python, pyi ]
84 changes: 82 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,85 @@ build-backend = "setuptools.build_meta"
version_variable = "setup.py:__version__"
version_source = "tag"

[tool.black]
line-length = 79
[tool.ruff]
target-version = "py39"
line-length = 120
force-exclude = true

[tool.ruff.lint]
select = ["ALL"]
ignore = [
# Rule families
"ANN", # flake8-annotations (not ready, require types for ALL args)
"ARG", # Check for unused function arguments
"BLE", # General catch of Exception
"C90", # Check for functions with a high McCabe complexity
"COM", # flake8-commas (conflict with line wrapper)
"CPY", # Missing copyright notice at top of file (need preview mode)
"EM", # Format nice error messages
"ERA", # Check for commented-out code
"FIX", # Check for FIXME, TODO and other developer notes
"FURB", # refurb (need preview mode, too many preview errors)
"G", # Validate logging format strings
"INP", # Ban PEP-420 implicit namespace packages
"N", # PEP8-naming (many var/arg names are intended)
"PTH", # Prefer pathlib over os.path
"SLF", # Access "private" class members
"T20", # Check for print/pprint
"TD", # TODO tags related

# Single rules
"B023", # Function definition does not bind loop variable
"B028", # No explicit stacklevel keyword argument found
"B904", # Within an except clause, raise exceptions with ...
"C408", # unnecessary-collection-call
"D105", # Missing docstring in magic method
"D205", # One blank line required between summary line and description
"D212", # Multi-line docstring summary should start at the first line
"E501", # Line too long
"E722", # Do not use bare `except` TODO fix this
"FBT001", # Boolean-typed positional argument in function definition
"FBT002", # Boolean default positional argument in function
"ISC001",
"NPY201", # TODO: enable after migration to NumPy 2.0
"PD901", # pandas-df-variable-name
"PERF203", # Use of try-except in for/while loop
"PERF401", # Replace "for" loops with list comprehension
"PLR0911", # Too many return statements
"PLR0912", # Too many branches
"PLR0913", # Too many arguments
"PLR0915", # Too many statements
"PLR2004", # Magic-value-comparison TODO fix these
"PLW2901", # Outer for loop variable overwritten by inner assignment target
"PLW0603", # Using the global statement to update `_el_ox_states_wiki` is discouraged TODO fix these
"PT009", # Use a regular `assert` instead of unittest-style `assertAlmostEqual`
"PT011", # `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception TODO fix these
"PT013", # Incorrect import of pytest
"RET505", # Unnecessary `else` after `return` statement
"S101", # Use of "assert"
"S110", # Log for try-except-pass
"S112", # Log for try-except-continue
"S301", # `pickle` and modules that wrap it can be unsafe when used to deserialize untrusted data, possible security issue
"S311", # Use random module for cryptographic purposes
"S314", # Replace xml with defusedxml to avoid XML attacks
"S603", # Check source for use of "subprocess" call
"S607", # Start process with relative path
"S608", # Possible SQL injection vector through string-based query construction
"SIM105", # Use contextlib.suppress() instead of try-except-pass
"TRY002", # Create your own exception TODO fix these
"TRY003", # Avoid specifying long messages outside the exception class
"TRY300", # Check for return statements in try blocks
"TRY301", # Check for raise statements within try blocks
"E741", # Ambigous variable
]
exclude = ["docs/conf.py","smact/utils/*", "docs/*"]
pydocstyle.convention = "google"
isort.required-imports = ["from __future__ import annotations"]

[tool.ruff.format]
docstring-code-format = true


[tool.ruff.lint.per-file-ignores]
"smact/utils/*" = ["D"]
"smact/tests/*" = ["D"]
15 changes: 8 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
#!/usr/bin/env python
"""Installation for SMACT."""

from __future__ import annotations

__author__ = "Daniel W. Davies"
__author_email__ = "[email protected]"
__copyright__ = (
"Copyright Daniel W. Davies, Adam J. Jackson, Keith T. Butler (2019)"
)
__copyright__ = "Copyright Daniel W. Davies, Adam J. Jackson, Keith T. Butler (2019)"
__version__ = "2.6"
__maintainer__ = "Anthony O. Onwuli"
__maintaier_email__ = "[email protected]"
__date__ = "July 10 2024"

import os
import unittest

from setuptools import Extension, setup
from setuptools import setup

module_dir = os.path.dirname(os.path.abspath(__file__))
with open(os.path.join(module_dir, "README.md")) as f:
long_description = f.read()

if __name__ == "__main__":
setup(
name="SMACT",
version=__version__,
description="Semiconducting Materials by Analogy and Chemical Theory",
long_description=open(os.path.join(module_dir, "README.md")).read(),
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/WMD-group/SMACT",
author=__author__,
Expand Down
Loading

0 comments on commit c240161

Please sign in to comment.