Hello, I am upgrading our repository to python 3.1...
# general
t
Hello, I am upgrading our repository to python 3.10 and I am running into some issues running pyupgrade. I have an in-repo pants plugin. If pyupgrade updates the
Optional[...]
syntax in the plugin, I get this error on the next pants command:
Copy code
17:11:06.13 [ERROR] unsupported operand type(s) for |: 'type' and 'NoneType'
The workaround for now is:
Copy code
pants fix --only="['black', 'isort', 'autoflake', 'docformatter', 'shfmt']" ::
pants fix --filter-address-regex='-^pants-plugins/.*' --only=pyupgrade ::
I looked through the docs and didn't see any way to specify
--skip=pyupgrade
or something similar. Just wondering if there is a better approach than this. Thanks!
I should say my goal is to run every formatter+linter+checker on all the code except running pyupgrade on the pants-plugin directory recursively.
w
Skipping? https://www.pantsbuild.org/2.19/reference/subsystems/pyupgrade#skip I think the issue here, if memory serves, is that Pants itself, and all pants-plugins run only on Python 3.9 right now. I thought we had PBS downloaded to run pants and in-repo plugins, but that might just be me mis-remembering. I haven't played around with the interpreters in a while
You can also use aliases https://www.pantsbuild.org/2.19/reference/subsystems/cli#alias to make those commands a bit more usable, once they're stabilized
t
oh perfect! thanks!
g
https://www.pantsbuild.org/2.19/reference/targets/python_source#skip_pyupgrade
Copy code
__defaults__(python_source=dict(skip_pyupgrade=True))
🎉 1
(put that in your /pants-plugins/BUILD file)
c
I thought we had PBS downloaded to run pants and in-repo plugins, but that might just be me mis-remembering. I haven't played around with the interpreters in a while
That would be really cool! But I don't think that exits today.