Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐞[Bug] StashEnum error when printing value. #19

Open
David-Maisonave opened this issue Sep 15, 2024 · 0 comments
Open

🐞[Bug] StashEnum error when printing value. #19

David-Maisonave opened this issue Sep 15, 2024 · 0 comments

Comments

@David-Maisonave
Copy link
Contributor

David-Maisonave commented Sep 15, 2024

Error triggered when trying to convert a class derived from (stash_types.py) StashEnum to string value.
An error occurs for both of the following lines of code:

high = str(PhashDistance.HIGH)
stash.Log(f"HIGH={PhashDistance.HIGH}")

Produces the following error:

Traceback (most recent call last):
  File "E:\_Dev\Scripts\PythonScripts\StashTestWithStashPluginHelperpy.py", line 149, in <module>
    high = str(PhashDistance.HIGH)
TypeError: __str__ returned non-string (type int)

Here's the fix:

class StashEnum(Enum):
	def __repr__(self) -> str:
		return f"{self.__class__.__name__}.{self.name}"
	def __str__(self) -> str:
		return str(self.value)
	def serialize(self):
		return self.value

In __str__ replace return self.value with return str(self.value)

FYI:
I don't believe importing IntEnum is needed in stash_types.py. It's not used in stash_types.py.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant