asottile / setup-cfg-fmt

apply a consistent format to `setup.cfg` files
MIT License
153 stars 18 forks source link

_normalize_req causes error when requirement uses url #120

Closed s-weigand closed 2 years ago

s-weigand commented 2 years ago

This isn't a bug with setup-cfg-fmt but a bug in all python versions< 3.9 or released before 2021-12-16. If the requirement uses an URL for example

qtsass@https://github.com/spyder-ide/qtsass/archive/refs/heads/master.zip ;python_version >= '3.10'

It needs a space before the ; or it will cause a parsing error

InvalidRequirement: Parse error at "">= '3.10"": Expected string_end

This makes setup-cfg-fmt unusable for projects which have to use an URL in their requirements.

https://github.com/asottile/setup-cfg-fmt/blob/d3e358c2db3d8e480b207a098ade06ee2381e3f5/setup_cfg_fmt.py#L236

This change should fix the issue.

-     return f'{normalized};{envs}'
+     return f'{normalized} ;{envs}'

Since nearly all python versions are affected it would be nice if setup-cfg-fmt would implement this workaround.

asottile commented 2 years ago

urls aren't intended to be supported (they kinda break the packaging system) so I'd rather leave this "as intended"