The arguments passed to the extension tool menu items inside pythonista are not in sys.argv
Forum Archive
Tool Extension arguments not in sys.argv
They are there however the $0 is added to the end of the list
#!/usr/bin/env python
import sys
print(sys.argv)
Produces
['/private/var/mobile/Containers/Shared/AppGroup/975867AB-70F6-4767-BDCD-372CAB8745F4/Pythonista3/Documents/tmp/argument.py', '--help', '/private/var/mobile/Containers/Shared/AppGroup/975867AB-70F6-4767-BDCD-372CAB8745F4/Pythonista3/Documents/tmp/argument.py']
If you're referring to the wrench menu in Pythonista's editor - editor actions run from the wrench menu automatically get the path of the currently open file added to the end of sys.argv. This is to allow using "shell-style" scripts, which take filenames from sys.argv, as editor actions without having to modify them. I don't think there is a way to turn this off. Even if you have an empty editor tab open, it adds an empty string to sys.argv.
This can be used to resolve the issue
if sys.argv[-1] == editor.get_path():
args = parser.parse_args(sys.argv[1:-1])
else:
args = parser.parse_args()