GMLC-TDC / pyhelics

CFFI Python interface for HELICS
https://python.helics.org
BSD 3-Clause "New" or "Revised" License
3 stars 7 forks source link

Remove Python2 only code #89

Open kdheepak opened 4 months ago

kdheepak commented 4 months ago

With Python2 support being dropped in #78, code associated with Python2 syntax can be upgraded to more idiomatic Python3 syntax.

This is a tracking issue for making these changes.

kdheepak commented 4 months ago

This try block can be simplified to remove the except block:

https://github.com/GMLC-TDC/pyhelics/blob/5516142dfa81de726357c6986444c5f310240e24/helics/capi.py#L12-L24

kdheepak commented 4 months ago

In Python2, f-string syntax was not supported, and Python 2 compatible s.format() needed to be used instead, e.g.

https://github.com/GMLC-TDC/pyhelics/blob/5516142dfa81de726357c6986444c5f310240e24/helics/capi.py#L1070-L1075

These can be changed to using f-string syntax:

f"""<helics.{self.__class__.__name__}(identifier = "{identifier}", address = "{address}") at {hex(id(self))}>"""
kdheepak commented 4 months ago

I believe you don't need these at the top of the file any more:

https://github.com/GMLC-TDC/pyhelics/blob/5516142dfa81de726357c6986444c5f310240e24/helics/capi.py#L1

kdheepak commented 4 months ago

You can drop enum34 from the dependencies:

https://github.com/GMLC-TDC/pyhelics/blob/5516142dfa81de726357c6986444c5f310240e24/setup.py#L558-L559

nightlark commented 4 months ago

It looks like ruff implements pyupgrade checks/fixes, so maybe we could also run this to catch some syntax related updates: https://docs.astral.sh/ruff/rules/#pyupgrade-up