Comments (7)
Additions:
Varargs
#!python
def cmd(*paths):
pass
# ...is the same as:
@arg('paths', nargs='*')
def cmd(paths):
pass
# ...and same as:
@arg('paths', nargs='*')
@expects_obj
def cmd(args):
pass
Keywords
**kwargs
contains all arguments not fitting ArgSpec.args
and ArgSpec.varargs
. If ArgSpec.keywords
in None, all @arg()
's will have to fit ArgSpec.args
.
#!python
@arg('foo')
@arg('--bar', default=1)
def cmd(**kwargs):
pass
# ...is the same as:
def cmd(foo, bar=1):
pass
# ...and same as:
@arg('foo')
@arg('--bar', default=1)
@expects_obj
def cmd(args):
pass
The first block does not require a default value to be specified.
Note: This comment has been automatically migrated from Bitbucket
Created by @neithere on 2012-12-26 09:15:24+00:00, last updated: 2012-12-26 16:01:27+00:00
from argh.
Backwards Compatibility
- The
command()
decorator becomes no-op. It may set an attribute though, see below. A deprecation warning is raised. - If a function is not wrapped in
command()
and expects a single argument namedargs
, it is likely to follow the old convention, i.e. implicitly expects a namespace object by default. After Argh is upgraded such function will break unless wrapped inexpects_obj()
. Thereforeset_default_function()
automatically wraps such function inexpects_obj()
to ease transition between the versions of API. A deprecation warning is raised.
Release 1.0 removes the command()
decorator and the "magical" wrapping of func(args)
in expects_obj()
.
Note: This comment has been automatically migrated from Bitbucket
Created by @neithere on 2012-12-27 07:45:46+00:00
from argh.
As DeprecationWarning is no longer loud since Python 2.7, it is required that the application developer runs the code as follows to ensure that the code is up to date:
#!bash
$ python -Wd app.py
Note: This comment has been automatically migrated from Bitbucket
Created by @neithere on 2012-12-27 10:38:48+00:00
from argh.
Re issue #29: implement new-style API, deprecate old functions, add compat fixes
Introspection/merging of varargs and keywords is not supported yet.
→ <>
Note: This comment has been automatically migrated from Bitbucket
Created by @neithere on 2012-12-27 16:11:31+00:00
from argh.
Re #29: add support for varargs.
→ <<cset 915a6aa05981>>
Note: This comment has been automatically migrated from Bitbucket
Created by @neithere on 2012-12-27 16:18:35+00:00
from argh.
Re #29: add support for varkw.
→ <>
Note: This comment has been automatically migrated from Bitbucket
Created by @neithere on 2012-12-27 16:18:35+00:00
from argh.
Well, the feature seems to be fully implemented and tested enough. Sure the code needs some refactoring and there are bugs yet to be found, but the issue can be closed.
Note: This comment has been automatically migrated from Bitbucket
Created by @neithere on 2012-12-30 16:34:04+00:00
from argh.
Related Issues (20)
- Expose version information at runtime
- Revamp unit tests
- Remove previously deprecated stuff HOT 1
- Add type annotations to existing code
- Test coverage reported as <100% when argcomplete is installed HOT 5
- Keyword-Only Arguments as Options
- Add support for Python 3.12
- Refactor assembling module
- Type hints: basic usage to infer argument types HOT 2
- TypeError: cannot picke '_io.TextIOWrapper' regression in 0.30 for `type=FileType(..), default=sys.stdin)` HOT 2
- 0.30.X is breaking console scripts by moving options to positional arguments HOT 5
- Issue with underscores in positional arguments since 0.30.0 HOT 1
- Using argh.argh(args=... , default=...) causes double nesting of passed arguments HOT 1
- TypingHintArgSpecGuesser breaks on type alias List HOT 11
- Option to disable replacement of "_" with "-" in named cli arguments HOT 3
- Trim trailing `_` from argument names
- Setting the argument name with `dest` is ignored HOT 2
- cmake deprecation warning with cmake<3.5 HOT 1
- Test failures with Python 3.13.0b2 HOT 3
- Add ability to display long options in usage message
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from argh.