cli2 2.7.1__tar.gz → 2.7.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. {cli2-2.7.1/cli2.egg-info → cli2-2.7.2}/PKG-INFO +1 -1
  2. {cli2-2.7.1 → cli2-2.7.2}/cli2/command.py +12 -13
  3. {cli2-2.7.1 → cli2-2.7.2}/cli2/test_command.py +3 -5
  4. {cli2-2.7.1 → cli2-2.7.2/cli2.egg-info}/PKG-INFO +1 -1
  5. {cli2-2.7.1 → cli2-2.7.2}/setup.py +1 -1
  6. {cli2-2.7.1 → cli2-2.7.2}/MANIFEST.in +0 -0
  7. {cli2-2.7.1 → cli2-2.7.2}/README.rst +0 -0
  8. {cli2-2.7.1 → cli2-2.7.2}/classifiers.txt +0 -0
  9. {cli2-2.7.1 → cli2-2.7.2}/cli2/__init__.py +0 -0
  10. {cli2-2.7.1 → cli2-2.7.2}/cli2/argument.py +0 -0
  11. {cli2-2.7.1 → cli2-2.7.2}/cli2/cli.py +0 -0
  12. {cli2-2.7.1 → cli2-2.7.2}/cli2/colors.py +0 -0
  13. {cli2-2.7.1 → cli2-2.7.2}/cli2/decorators.py +0 -0
  14. {cli2-2.7.1 → cli2-2.7.2}/cli2/entry_point.py +0 -0
  15. {cli2-2.7.1 → cli2-2.7.2}/cli2/group.py +0 -0
  16. {cli2-2.7.1 → cli2-2.7.2}/cli2/node.py +0 -0
  17. {cli2-2.7.1 → cli2-2.7.2}/cli2/table.py +0 -0
  18. {cli2-2.7.1 → cli2-2.7.2}/cli2/test.py +0 -0
  19. {cli2-2.7.1 → cli2-2.7.2}/cli2/test_cli.py +0 -0
  20. {cli2-2.7.1 → cli2-2.7.2}/cli2/test_decorators.py +0 -0
  21. {cli2-2.7.1 → cli2-2.7.2}/cli2/test_entrypoint.py +0 -0
  22. {cli2-2.7.1 → cli2-2.7.2}/cli2/test_group.py +0 -0
  23. {cli2-2.7.1 → cli2-2.7.2}/cli2/test_inject.py +0 -0
  24. {cli2-2.7.1 → cli2-2.7.2}/cli2/test_node.py +0 -0
  25. {cli2-2.7.1 → cli2-2.7.2}/cli2/test_table.py +0 -0
  26. {cli2-2.7.1 → cli2-2.7.2}/cli2.egg-info/SOURCES.txt +0 -0
  27. {cli2-2.7.1 → cli2-2.7.2}/cli2.egg-info/dependency_links.txt +0 -0
  28. {cli2-2.7.1 → cli2-2.7.2}/cli2.egg-info/entry_points.txt +0 -0
  29. {cli2-2.7.1 → cli2-2.7.2}/cli2.egg-info/requires.txt +0 -0
  30. {cli2-2.7.1 → cli2-2.7.2}/cli2.egg-info/top_level.txt +0 -0
  31. {cli2-2.7.1 → cli2-2.7.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cli2
3
- Version: 2.7.1
3
+ Version: 2.7.2
4
4
  Summary: image:: https://yourlabs.io/oss/cli2/badges/master/pipeline.svg
5
5
  Home-page: https://yourlabs.io/oss/cli2
6
6
  Author: James Pic
@@ -164,21 +164,18 @@ class Command(EntryPoint, dict):
164
164
  self.exit_code = 1
165
165
  return self.help(error=error)
166
166
 
167
- required = [
168
- arg
169
- for arg in self.values()
170
- if arg.default == inspect._empty
171
- and arg.param.name not in self.bound.kwargs
172
- and arg.param.kind not in (
173
- arg.param.VAR_KEYWORD,
174
- arg.param.VAR_POSITIONAL,
167
+ missing = [
168
+ name
169
+ for name, arg in self.items()
170
+ if name not in self.bound.arguments
171
+ and name not in self.bound.kwargs
172
+ and arg.param.default == arg.param.empty
173
+ and arg.param.kind in (
174
+ arg.param.POSITIONAL_ONLY,
175
+ arg.param.POSITIONAL_OR_KEYWORD,
175
176
  )
176
177
  ]
177
- if len(self.bound.args) < len(required):
178
- missing = [
179
- arg.param.name
180
- for arg in required[len(self.bound.args):]
181
- ]
178
+ if missing:
182
179
  error = (
183
180
  f'missing {len(missing)} required argument'
184
181
  f'{"s" if len(missing) > 1 else ""}'
@@ -192,6 +189,8 @@ class Command(EntryPoint, dict):
192
189
  if inspect.iscoroutine(result):
193
190
  result = asyncio.run(result)
194
191
  except TypeError as exc:
192
+ # keeping this as fallback for now, in case the above missing
193
+ # detection doesn't work
195
194
  self.exit_code = 1
196
195
  if hasattr(self.target, '__name__'):
197
196
  rep = getattr(self.target, '__name__')
@@ -499,13 +499,11 @@ def test_arg_reorder():
499
499
 
500
500
 
501
501
  def test_arg():
502
- class TestCommand(Command):
503
- def call(self, *args, **kwargs):
504
- return (args, kwargs)
505
-
506
- cmd = TestCommand(lambda foo: True)
502
+ cmd = Command(lambda foo: foo)
507
503
  cmd.arg('bar', position=0)
508
504
  assert list(cmd.keys()) == ['bar', 'foo']
505
+ assert cmd('bar', 'foo') == 'foo'
506
+ assert cmd['bar'].value == 'bar'
509
507
 
510
508
 
511
509
  def test_helphack():
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cli2
3
- Version: 2.7.1
3
+ Version: 2.7.2
4
4
  Summary: image:: https://yourlabs.io/oss/cli2/badges/master/pipeline.svg
5
5
  Home-page: https://yourlabs.io/oss/cli2
6
6
  Author: James Pic
@@ -3,7 +3,7 @@ from setuptools import setup
3
3
 
4
4
  setup(
5
5
  name='cli2',
6
- version='2.7.1',
6
+ version='2.7.2',
7
7
  setup_requires='setupmeta',
8
8
  install_requires=['docstring_parser'],
9
9
  extras_require=dict(
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes