Skip to content

Commit

Permalink
bugfixes for new evaluate_settings_once logic (#18)
Browse files Browse the repository at this point in the history
Changes:
- fix return value when already evaluated
- also catch AttributeError as an import error
- bump version
  • Loading branch information
devkral authored Jan 7, 2025
1 parent f2c56e8 commit 20f188f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
6 changes: 6 additions & 0 deletions docs/release-notes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Release notes

## Version 0.2.1

### Fixed

- Add AttributeError to the ignored import errors.
- Wrong return value for `evaluate_settings_once` when already evaluated.

## Version 0.2.0

Expand Down
2 changes: 1 addition & 1 deletion monkay/__about__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2024-present alex <[email protected]>
#
# SPDX-License-Identifier: BSD-3-Clauses
__version__ = "0.2.0"
__version__ = "0.2.1"
4 changes: 2 additions & 2 deletions monkay/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,11 @@ def evaluate_settings_once(
ignore_import_errors: bool = True,
) -> bool:
if self.settings_evaluated:
return False
return True
if ignore_import_errors:
try:
self.evaluate_settings(on_conflict=on_conflict)
except ImportError:
except (ImportError, AttributeError):
return False
else:
self.evaluate_settings(on_conflict=on_conflict)
Expand Down
9 changes: 8 additions & 1 deletion tests/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,14 @@ def test_settings_overwrite():
mod.monkay.evaluate_settings()
assert mod.monkay.settings_evaluated
# assert no evaluation anymore
assert not mod.monkay.evaluate_settings_once()
old_evaluate_settings = mod.monkay.evaluate_settings

def fake_evaluate():
raise

mod.monkay.evaluate_settings = fake_evaluate
assert mod.monkay.evaluate_settings_once()
mod.monkay.evaluate_settings = old_evaluate_settings
assert "tests.targets.module_settings_preloaded" in sys.modules

# overwriting settings doesn't affect temporary scope
Expand Down

0 comments on commit 20f188f

Please sign in to comment.