2 ms·
It's a change which takes less time to fix than you've spent commenting in this thread: python-modernize --write --no-six PROJECT_DIR (https://python-mode
by acdha 7y ago
It's a change which takes less time to fix than you've spent commenting in this thread:
python-modernize --write --no-six PROJECT_DIR
(https://python-modernize.readthedocs.io/en/latest/ https://python-modernize.readthedocs.io/en/latest/)
futurize --write PROJECT_DIR
(https://python-future.org/quickstart.html https://python-future.org/quickstart.html)
- deleted 7y ago[deleted]
- htfy96 7y agoThis isn't ideal as a version upgrade may also change the parameter type from a third party library, and these tools cannot detect it: old.py: bs = raw_input() # Call a 3ps which originally accepts a bytestream, but now accepts a string some_3rd_party_function(bs) After python-modernize: from six.moves import input bs = input() # Your code using bs as a bytestring still works # Runtime Error: # This now accepts a string, and you need to modify your code to deal with random TypeError popping from everywhere some_3rd_party_function(bs)
- acdha 7y agoYour second case is why I had —no-six in my example to prevent what you showed. In both cases, as shown in the linked documentation, these tools are designed to support staged migrations for exactly this reason.