Commit Graph

30 Commits

Author SHA1 Message Date
Florian Bruhin
822623f2ed Finally update copyrights... 2017-05-09 21:37:03 +02:00
Florian Bruhin
1d0f187fab Adjustments for new pylint version 2017-04-13 18:22:16 +02:00
Florian Bruhin
97edc59f03 Add some logging to argparse.multitype_conv 2016-09-12 18:22:49 +02:00
Florian Bruhin
445d287955 Revert "Fix choices validation with unannotated args"
This reverts commit 12061b8bb1.
2016-08-23 23:34:02 +02:00
Florian Bruhin
12061b8bb1 Fix choices validation with unannotated args
Something like:

    @cmdutils.argument('foo', choices=['one', 'two'])
    def func(foo):
        # ...

didn't actually validate the foo argument, since the inferred type of
the argument is None, and that skipped all conversion (and thus
validation).

Fixes #1871
See #1885
2016-08-23 22:01:21 +02:00
Florian Bruhin
e4d84b0bfc Simplify argparser.type_check
If the value isn't param.default, it will always be a string or a flag, as
type_conv never gets called when the function is called from Python.
2016-05-18 07:16:17 +02:00
Florian Bruhin
a83bf9c3ee Simplify argparser.type_conv
Since we're not using those functions as argparse callbacks anymore, we
can write a normal function instead of factories, which simplifies
things a lot.
2016-05-18 06:55:27 +02:00
Florian Bruhin
6ed9b6b13f Make sure typing.Union[str, int] gets handled
str always needs to be the last element checked as otherwise it'd always
win.
2016-05-18 06:55:17 +02:00
Florian Bruhin
a0d0b6464f Use typing.py-like annotations for command args
This means:

- An annotation like (int, str) is now typing.Union[int, str].
- utils.typing got expanded so it acts like the real typing.py, with
  issubclass() working properly with typing.Union and __union_params__
  being set.
- A literal string doesn't exist anymore as annotation, instead
  @cmdutils.argument now has a 'choices' argument which can be used like
  @cmdutils.argument('arg', choices=['val1', 'val2']).
- Argument validating/converting is now entirely handled by
  argparser.type_conv instead of relying on python's argparse, i.e.
  type/choices is now not passed to argparse anymore.
2016-05-18 06:55:17 +02:00
Florian Bruhin
a5f2ac5f03 Adjust copyright years. 2016-01-04 07:12:39 +01:00
Florian Bruhin
d229e90724 Fix some splelling mistakes. 2015-10-04 15:41:42 +02:00
Florian Bruhin
ed70d636d0 argparser: Check for unknown types. 2015-08-20 07:09:09 +02:00
Florian Bruhin
506917882e argparser: Style fixes. 2015-08-20 07:08:59 +02:00
Florian Bruhin
82322beb03 Fix pep257 issues. 2015-03-26 07:08:54 +01:00
Florian Bruhin
450d1ab70d Update copyright years 2015-01-03 15:51:31 +01:00
Florian Bruhin
b54151f206 Use last focused window for download errors and other stuff.
When the event happens, it's possible we don't have any window focused yet, so
we display it in the window which was last focused.

Fixes #191.
2014-10-15 20:42:40 +02:00
Florian Bruhin
36f7ff6154 Fix some objreg.get calls. 2014-09-28 23:23:02 +02:00
Florian Bruhin
05ff908c4f Update attributes in docstrings. 2014-09-24 22:25:11 +02:00
Florian Bruhin
3f02451828 Move object registry to its own file. 2014-09-24 07:06:45 +02:00
Florian Bruhin
2b60cdb64c Object names cleanup 2014-09-23 23:05:55 +02:00
Florian Bruhin
a76c4c8ba5 Use object registry for tabbedbrowser. 2014-09-23 22:01:46 +02:00
Florian Bruhin
0267dac2be Add --help documentation 2014-09-08 07:36:18 +02:00
Florian Bruhin
13a2506c6a argparser: Also catch TypeError for multitype_conv. 2014-09-08 07:36:17 +02:00
Florian Bruhin
47f42f9e5a commands.argparser: Make type tuples a set(). 2014-09-08 07:36:17 +02:00
Florian Bruhin
05f3809d01 Fix lint 2014-09-08 07:36:17 +02:00
Florian Bruhin
b5f28b6ff2 commands.argparser: Make ArgumentParser take args, add name. 2014-09-08 07:36:17 +02:00
Florian Bruhin
a656c8cfb0 commands: Add initial --help argument support. 2014-09-08 07:36:17 +02:00
Florian Bruhin
03a0a1c599 commands: Handle ArgumentParser exit. 2014-09-08 07:36:17 +02:00
Florian Bruhin
57d51ad9bb Lots of fixes for new command system.
Squashed commit:

- Fix getting current URL
- Get rid of *args for hints.
- Make enums work.
- Fix moving commands to utilcmds.
- Fix enums in argparse
- Fix arg splitting for hints.
- Fix default enum args.
- Fix argument splitting for hints if None is given.
- Fix set_cmd_text with flags and fix {url}.
- Fix unittests
- Fix tuple types for arguments.
- Fix scroll-page.
- Fix lint
- Fix open_target.
- Others
2014-09-08 07:36:17 +02:00
Florian Bruhin
a811f8cb07 Start initial newcmd stuff. 2014-09-08 07:36:17 +02:00