Skip to content

Commit

Permalink
- Fix mypy error
Browse files Browse the repository at this point in the history
- Specify return type `resolve_basis_set`
  • Loading branch information
Nathan Daelman committed May 29, 2024
1 parent 8331c62 commit 87afb02
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions electronicparsers/gaussian/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import numpy as np
import logging
import ase
from typing import Optional

from .metainfo import m_env

Expand Down Expand Up @@ -1306,7 +1307,7 @@ def resolve_prefix(name):
name = res[2]
return prefix, name

def resolve_basis_set(parameter: str) -> tuple[str, str]:
def resolve_basis_set(parameter: str) -> Optional[tuple[str, str]]:
"""This function has 2 responsibilities:
1. discern `parameter` from other input settings.
2. verify that `parameter` is a valid basis set name."""
Expand All @@ -1324,6 +1325,9 @@ def resolve_basis_set(parameter: str) -> tuple[str, str]:
)
return (basis_keys[0], parameter)

# in case the setting was not recognized
return None

def resolve_xc_functional(parameter):
xc_functional = self._xc_functional_map.get(parameter, None)
if xc_functional is not None:
Expand Down Expand Up @@ -1379,7 +1383,7 @@ def resolve_xc_functional(parameter):
basis_set_parameter = parameter[0] if not parameter[1:] else parameter[1]
# ! invert logic
basis_set = resolve_basis_set(basis_set_parameter.strip())
if basis_set is not None:
if basis_set:
basis_sets.add(basis_set)
if len(basis_sets) == 0:
basis_sets.add(resolve_basis_set('STO-3G'))
Expand Down

0 comments on commit 87afb02

Please sign in to comment.