Skip to content

Commit

Permalink
Avoided 3.9 attributeError limits.
Browse files Browse the repository at this point in the history
  • Loading branch information
MicahGale committed Nov 29, 2024
1 parent e8f8501 commit e4db053
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
19 changes: 13 additions & 6 deletions montepy/mcnp_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
import copy
import functools
import itertools as it
import numpy as np
import sys
import textwrap
import warnings
import weakref

from montepy.errors import *
from montepy.constants import (
BLANK_SPACE_CONTINUE,
Expand All @@ -18,10 +24,6 @@
ValueNode,
)
import montepy
import numpy as np
import textwrap
import warnings
import weakref


class _ExceptionContextAdder(ABCMeta):
Expand Down Expand Up @@ -146,10 +148,15 @@ def __setattr__(self, key, value):
if key.startswith("_"):
super().__setattr__(key, value)
else:
# kwargs added in 3.10
if sys.version_info >= (3, 10):
raise AttributeError(
f"'{type(self).__name__}' object has no attribute '{key}'",
obj=self,
name=key,
)
raise AttributeError(
f"'{type(self).__name__}' object has no attribute '{key}'",
obj=self,
name=key,
)

@staticmethod
Expand Down
1 change: 1 addition & 0 deletions tests/test_cell_problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ def test_cell_clone_bad(args, error):
with pytest.raises(error):
cell.clone(*args)


def test_bad_setattr():
cell = montepy.Cell()
with pytest.raises(AttributeError):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_nuclide.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def test_fancy_names_pbt(
new_isotope = Nuclide(Z=Z, A=A + 5, meta_state=meta)
assert new_isotope != isotope
assert isotope < new_isotope
if library_base < 999:
if library_base < 998:
new_isotope = Nuclide(
Z=Z,
A=A,
Expand Down

0 comments on commit e4db053

Please sign in to comment.