Skip to content

Commit

Permalink
Merge pull request #387 from materialsproject/fix-mutable-dataclass-f…
Browse files Browse the repository at this point in the history
…ield

Fix ValueError: mutable default for field `add_maker` is not allowed: use default_factory
  • Loading branch information
janosh authored Aug 7, 2023
2 parents 9446d2f + c4e9530 commit 108d2f4
Show file tree
Hide file tree
Showing 17 changed files with 196 additions and 205 deletions.
120 changes: 60 additions & 60 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,63 +1,63 @@
default_language_version:
python: python3
exclude: '^src/atomate2/vasp/schemas/calc_types/'
exclude: "^src/atomate2/vasp/schemas/calc_types/"
repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.250
hooks:
- id: ruff
args: [--fix]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-yaml
- id: fix-encoding-pragma
args: [--remove]
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 22.12.0
hooks:
- id: black
- repo: https://github.com/asottile/blacken-docs
rev: v1.12.1
hooks:
- id: blacken-docs
additional_dependencies: [black]
exclude: README.md
- repo: https://github.com/pycqa/flake8
rev: 6.0.0
hooks:
- id: flake8
entry: pflake8
files: ^src/
additional_dependencies:
- pyproject-flake8==6.0.0
- flake8-bugbear==22.12.6
- flake8-typing-imports==1.14.0
- flake8-docstrings==1.6.0
- flake8-rst-docstrings==0.3.0
- flake8-rst==0.8.0
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: python-use-type-annotations
- id: rst-backticks
- id: rst-directive-colons
- id: rst-inline-touching-normal
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.991
hooks:
- id: mypy
files: ^src/
additional_dependencies:
- tokenize-rt==4.1.0
- types-pkg_resources==0.1.2
- types-paramiko
- repo: https://github.com/codespell-project/codespell
rev: v2.2.2
hooks:
- id: codespell
stages: [commit, commit-msg]
args: [--ignore-words-list, 'titel,statics,ba,nd,te']
types_or: [python, rst, markdown]
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.282
hooks:
- id: ruff
args: [--fix]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-yaml
- id: fix-encoding-pragma
args: [--remove]
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 22.12.0
hooks:
- id: black
- repo: https://github.com/asottile/blacken-docs
rev: v1.12.1
hooks:
- id: blacken-docs
additional_dependencies: [black]
exclude: README.md
- repo: https://github.com/pycqa/flake8
rev: 6.0.0
hooks:
- id: flake8
entry: pflake8
files: ^src/
additional_dependencies:
- pyproject-flake8==6.0.0
- flake8-bugbear==22.12.6
- flake8-typing-imports==1.14.0
- flake8-docstrings==1.6.0
- flake8-rst-docstrings==0.3.0
- flake8-rst==0.8.0
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: python-use-type-annotations
- id: rst-backticks
- id: rst-directive-colons
- id: rst-inline-touching-normal
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.991
hooks:
- id: mypy
files: ^src/
additional_dependencies:
- tokenize-rt==4.1.0
- types-pkg_resources==0.1.2
- types-paramiko
- repo: https://github.com/codespell-project/codespell
rev: v2.2.2
hooks:
- id: codespell
stages: [commit, commit-msg]
args: [--ignore-words-list, "titel,statics,ba,nd,te"]
types_or: [python, rst, markdown]
2 changes: 1 addition & 1 deletion examples/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ def compute(a: float, b: float):
print(compute_job.output.total)
# OutputReference(8ff2a94e-7633-42e9-8aa0-8479801347d5, .total)

compute_job.output.not_in_schema
_ = compute_job.output.not_in_schema
# AttributeError: ComputeSchema does not have property 'not_in_schema'.
45 changes: 23 additions & 22 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,54 +11,54 @@ license = { text = "modified BSD" }
authors = [{ name = "Alex Ganose", email = "alexganose@gmail.com" }]
dynamic = ["version"]
classifiers = [
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Development Status :: 2 - Pre-Alpha",
"Intended Audience :: Information Technology",
"Intended Audience :: Science/Research",
"Intended Audience :: System Administrators",
"Intended Audience :: Information Technology",
"Operating System :: OS Independent",
"Topic :: Other/Nonlisted Topic",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Topic :: Database :: Front-Ends",
"Topic :: Other/Nonlisted Topic",
"Topic :: Scientific/Engineering",
]
requires-python = ">=3.8"
dependencies = [
"PyYAML",
"maggma>=0.38.1",
"monty>=2021.5.9",
"pydash",
"networkx",
"maggma>=0.38.1",
"pydantic",
"PyYAML",
"pydash",
]

[project.optional-dependencies]
docs = [
"sphinx==7.1.1",
"autodoc_pydantic==1.9.0",
"furo==2023.7.26",
"myst_parser==2.0.0",
"ipython==8.14.0",
"myst_parser==2.0.0",
"nbsphinx==0.9.2",
"autodoc_pydantic==1.9.0",
"sphinx-copybutton==0.5.2",
"sphinx==7.1.1",
]
dev = ["pre-commit>=2.12.1"]
tests = ["pytest==7.4.0", "pytest-cov==4.1.0"]
tests = ["pytest-cov==4.1.0", "pytest==7.4.0"]
vis = ["matplotlib", "pydot"]
fireworks = ["FireWorks"]
strict = [
"FireWorks==2.0.3",
"PyYAML==6.0.1",
"maggma==0.51.24",
"matplotlib==3.7.2",
"monty==2023.5.8",
"moto==4.1.14",
"networkx==3.1",
"pydash==7.0.6",
"maggma==0.51.24",
"pydantic==1.10.9",
"PyYAML==6.0.1",
"FireWorks==2.0.3",
"matplotlib==3.7.2",
"pydash==7.0.6",
"pydot==1.4.2",
"moto==4.1.14",
"typing-extensions==4.7.1",
]

Expand Down Expand Up @@ -91,9 +91,9 @@ no_strict_optional = true
[tool.pytest.ini_options]
filterwarnings = [
"ignore:.*POTCAR.*:UserWarning",
"ignore:.*magmom.*:UserWarning",
"ignore:.*is not gzipped.*:UserWarning",
"ignore:.*input structure.*:UserWarning",
"ignore:.*is not gzipped.*:UserWarning",
"ignore:.*magmom.*:UserWarning",
"ignore::DeprecationWarning",
]

Expand All @@ -109,9 +109,9 @@ source = ["src/"]
skip_covered = true
show_missing = true
exclude_lines = [
'^\s*@overload( |$)',
'^\s*assert False(,|$)',
'if typing.TYPE_CHECKING:',
'^\s*@overload( |$)',
]

[tool.ruff]
Expand All @@ -134,6 +134,7 @@ select = [
"W", # pycodestyle
"YTT", # flake8-2020
]
ignore = ["B028", "PLW0603", "RUF013"]
pydocstyle.convention = "numpy"
isort.known-first-party = ["jobflow"]

Expand Down
18 changes: 9 additions & 9 deletions src/jobflow/core/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ class Flow(MSONable):
def __init__(
self,
jobs: list[Flow | jobflow.Job] | jobflow.Job | Flow,
output: Any | None = None,
output: Any = None,
name: str = "Flow",
order: JobOrder = JobOrder.AUTO,
uuid: str = None,
hosts: list[str] | None = None,
hosts: list[str] = None,
):
from jobflow.core.job import Job

Expand Down Expand Up @@ -336,8 +336,8 @@ def iterflow(self):
def update_kwargs(
self,
update: dict[str, Any],
name_filter: str | None = None,
function_filter: Callable | None = None,
name_filter: str = None,
function_filter: Callable = None,
dict_mod: bool = False,
):
"""
Expand Down Expand Up @@ -392,8 +392,8 @@ def update_kwargs(
def update_maker_kwargs(
self,
update: dict[str, Any],
name_filter: str | None = None,
class_filter: type[jobflow.Maker] | None = None,
name_filter: str = None,
class_filter: type[jobflow.Maker] = None,
nested: bool = True,
dict_mod: bool = False,
):
Expand Down Expand Up @@ -511,8 +511,8 @@ def append_name(self, append_str: str, prepend: bool = False):
def update_metadata(
self,
update: dict[str, Any],
name_filter: str | None = None,
function_filter: Callable | None = None,
name_filter: str = None,
function_filter: Callable = None,
dict_mod: bool = False,
dynamic: bool = True,
):
Expand Down Expand Up @@ -634,7 +634,7 @@ def update_config(
)

def add_hosts_uuids(
self, hosts_uuids: str | list[str] | None = None, prepend: bool = False
self, hosts_uuids: str | list[str] = None, prepend: bool = False
):
"""
Add a list of UUIDs to the internal list of hosts.
Expand Down
Loading

0 comments on commit 108d2f4

Please sign in to comment.