Skip to content

Python: fix static arguments on methods and class constructors - #263

Open
Tom-Kingstone wants to merge 2 commits into
developfrom
Python_Toolkit-#260-FixStaticArguments
Open

Tom-Kingstone wants to merge 2 commits into
developfrom
Python_Toolkit-#260-FixStaticArguments

Conversation

@Tom-Kingstone

Copy link
Copy Markdown
Contributor

NOTE: Depends on

Issues addressed by this PR

Closes #260

see issue, this fixes the problem where applicable across the toolkit.

Also fixed deprecation warnings for datetime.utcnow() (as the method was being changed anyway) and fixed anywhere that it was being called directly with non timezone aware datetimes.

Test files

run the python unit test scripts.

Changelog

Additional comments

@Tom-Kingstone Tom-Kingstone self-assigned this Oct 29, 2026
@Tom-Kingstone Tom-Kingstone added the type:bug Error or unexpected behaviour label Oct 29, 2026
@dataclass
class UsageLogEntry():
BHoMVersion:str = BHOM_VERSION
BHoM_Guid:uuid.UUID = uuid.uuid4()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there could be the same issue here for initialising this uuid

BHoMVersion:str = BHOM_VERSION
BHoM_Guid:uuid.UUID = uuid.uuid4()
CallerName:str = ""
ComponentId:uuid.UUID = uuid.uuid4()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above here

BHoM_Guid:uuid.UUID = uuid.uuid4()
CallerName:str = ""
ComponentId:uuid.UUID = uuid.uuid4()
CustomData:Dict = field(default_factory = {"interpreter", sys.executable})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this supposed to be a dict ? (appreciate this is not your changes)

Fragments:List[str] = field(default_factory = [])
Name:str = ""
ProjectID:str = ""
SelectedItem:Dict = field(default_factory = {"MethodName": "", "Parameters": [], "TypeName": ""})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

according to claude this is going raise TypeError: 'set' object is not callable.

Comment on lines 150 to 152
return {"$date": bson_unix_ticks(o.to_pydatetime(), True)}
elif isinstance(o, datetime):
return {"$date": bson_unix_ticks(o, True)}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you now using timezone aware in bson_unix_ticks , I believe this would now cause a TypeError

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:bug Error or unexpected behaviour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix python using the same property for multiple instances of a class if the property has an initialiser in the constructor arguments

2 participants