IndentationError with python 3.9
tilmantroester opened this issue · 5 comments
Some of the generated python wrapper code causes IndentationError
with python 3.9. The same code works on 3.8.
_pyhmcode.f90wrap_halomod__set__dmonly_neutrino_halo_mass_correction(self._handle, \
^
IndentationError: expected an indented block
The offending block is
@dmonly_neutrino_halo_mass_correction.setter
def dmonly_neutrino_halo_mass_correction(self, \
dmonly_neutrino_halo_mass_correction):
\
_pyhmcode.f90wrap_halomod__set__dmonly_neutrino_halo_mass_correction(self._handle, \
dmonly_neutrino_halo_mass_correction)
Python 3.9 doesn't seem to like the empty line continuation. The following works on 3.8 but fails on 3.9:
def f():
\
pass
I can't see anything in the 3.9 change log that mentions this though.
Thanks for reporting. I guess we don't need the \
here in any case since the continuation is not needed within parenthesis. A PR to improve the logic would be most welcome, or I will probably get to it eventually.
Thanks for the quick reply. Where would I have to look to fix this?
https://github.com/jameskermode/f90wrap/blob/master/f90wrap/codegen.py#L111
could also just allow a larger max_length
to be passed in from the command line.
Ha. In fact the latter idea is already possible with --py-max-line-length
command line option to f90wrap
, which might solve your problem?
https://github.com/jameskermode/f90wrap/blob/master/scripts/f90wrap#L157
Setting --py-max-line-length=200
indeed solves this, thanks! I think I also fixed offending part of the line-splitting code (see #154).