Skip to content
Open
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
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.9.2'
rev: 'v0.15.21'
hooks:
- id: ruff
args: [ --fix, --exit-non-zero-on-fix ]
- repo: https://github.com/psf/black
rev: 24.10.0
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 26.5.1
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.14.1
rev: v2.3.0
hooks:
- id: mypy
additional_dependencies: ["pydantic>=2"]
6 changes: 2 additions & 4 deletions cp2k_input_tools/cli/lsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@

from cp2k_input_tools.ls import cp2k_server
except ImportError:
print(
"""Could not import the pygls package. You have to install the cp2k-input-tools with the 'lsp' extra:
print("""Could not import the pygls package. You have to install the cp2k-input-tools with the 'lsp' extra:

pip install cp2k-input-tools[lsp]
"""
)
""")
sys.exit(1)


Expand Down
48 changes: 16 additions & 32 deletions tests/test_parser_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,12 @@ def test_undefined_preprocessor_var():
def test_multiple_defined_non_repeating_section():
cp2k_parser = CP2KInputParser(DEFAULT_CP2K_INPUT_XML)

fhandle = io.StringIO(
"""
fhandle = io.StringIO("""
&GLOBAL
&END GLOBAL
&GLOBAL
&END GLOBAL
"""
)
""")

with pytest.raises(InvalidNameError) as excinfo:
cp2k_parser.parse(fhandle)
Expand All @@ -71,27 +69,23 @@ def test_multiple_defined_non_repeating_section():
def test_missing_section_end():
cp2k_parser = CP2KInputParser(DEFAULT_CP2K_INPUT_XML)

fhandle = io.StringIO(
"""
fhandle = io.StringIO("""
&GLOBAL
! &END GLOBAL
&FORCE_EVAL
&END FORCE_EVAL
"""
)
""")

with pytest.raises(InvalidSectionError) as excinfo:
cp2k_parser.parse(fhandle)

assert "invalid section" in excinfo.value.args[0]

fhandle = io.StringIO(
"""
fhandle = io.StringIO("""
&GLOBAL
&END GLOBAL
&FORCE_EVAL
"""
)
""")

with pytest.raises(SectionMismatchError) as excinfo:
cp2k_parser.parse(fhandle)
Expand All @@ -102,14 +96,12 @@ def test_missing_section_end():
def test_section_end_mismatch():
cp2k_parser = CP2KInputParser(DEFAULT_CP2K_INPUT_XML)

fhandle = io.StringIO(
"""
fhandle = io.StringIO("""
&GLOBAL
&END GLOBI
&FORCE_EVAL
&END FORCE_EVAL
"""
)
""")

with pytest.raises(SectionMismatchError) as excinfo:
cp2k_parser.parse(fhandle)
Expand All @@ -120,12 +112,10 @@ def test_section_end_mismatch():
def test_section_parameter_error():
cp2k_parser = CP2KInputParser(DEFAULT_CP2K_INPUT_XML)

fhandle = io.StringIO(
"""
fhandle = io.StringIO("""
&GLOBAL invalidparam
&END GLOBAL
"""
)
""")

with pytest.raises(InvalidParameterError) as excinfo:
cp2k_parser.parse(fhandle)
Expand All @@ -136,15 +126,13 @@ def test_section_parameter_error():
def test_invalid_keyword():
cp2k_parser = CP2KInputParser(DEFAULT_CP2K_INPUT_XML)

fhandle = io.StringIO(
"""
fhandle = io.StringIO("""
&FORCE_EVAL
&SUBSYS
BASIS_SET TZVPd-MOLOPT-SR-GTH
&END SUBSYS
&END FORCE_EVAL
"""
)
""")

with pytest.raises(InvalidNameError) as excinfo:
cp2k_parser.parse(fhandle)
Expand All @@ -160,8 +148,7 @@ def test_internal_cp2k_unit():

cp2k_parser = CP2KInputParser(DEFAULT_CP2K_INPUT_XML)

fhandle_no_extra_unit = io.StringIO(
"""
fhandle_no_extra_unit = io.StringIO("""
&FORCE_EVAL
METHOD FIST
&MM
Expand All @@ -182,13 +169,11 @@ def test_internal_cp2k_unit():
&END FORCEFIELD
&END MM
&END FORCE_EVAL
"""
)
""")

cp2k_parser.parse(fhandle_no_extra_unit)

fhandle_extra_unit = io.StringIO(
"""
fhandle_extra_unit = io.StringIO("""
&FORCE_EVAL
METHOD FIST
&MM
Expand All @@ -209,8 +194,7 @@ def test_internal_cp2k_unit():
&END FORCEFIELD
&END MM
&END FORCE_EVAL
"""
)
""")

with pytest.raises(InvalidParameterError) as excinfo:
cp2k_parser.parse(fhandle_extra_unit)
Expand Down
Loading