Commit graph

203 commits

Author SHA1 Message Date
Noorhteen Raja NJ
0c13e8c008
adding convention for short boolean flags (#4520)
* feat: use NumpyDoc to represent Parsed docstring

in cli_utils.py

* feat: set argparse boolean option from default values

* refactor: shorter Arg in annotation

by following convention in cli_utils.py

* fix: get description without Parameters

* fix: qa errors
2021-11-17 13:51:18 -05:00
Noorhteen Raja NJ
a3c1b2429e
argparserAlias - vox (#4437)
* feat: use argparser-alias for vox

* feat: vox.create --interpreter completions

* refactor: use func based completer

* fix: implement interpreter completion

* docs:

* refactor: update import path of cli_utils

* style: convert to f-strings

* fix: failing tests

* fix: failing tests

completer from base_completer appears
2021-10-13 10:02:06 -04:00
Noorhteen Raja NJ
ca9338149c
fix: vox system_site_packages option not passed (#4404)
* fix: vox system_site_packages option not passed

* docs: add news item

* docs: add todo nit
2021-08-11 09:46:32 +03:00
Daniel Shimon
8dac83a9a0
Fix jedi path completion (#4400)
* xontrib: jedi: Don't complete paths with '~'

* tests: xontrib: jedi: Update tests

* news: Add fix-jedi-path-completion
2021-07-29 10:02:25 +03:00
Noorhteen Raja NJ
3ce8c9b337
add py310 (#4270)
* chore: adding py310 to ci

though this will require code/parser changes, this is to prepare for
upcoming adoption

* fix: set python version as string

* fix: reference to master -> main

* fix: coverage is not reported in master

- disable amalgamation
	1. during coverage report tests
	2. qa tools like mypy may follow imports
- use python 3.9 for coverage and qa report. since it will have more
coverage and better typing support

* chore: use py3.10 with setup-py action

* chore: add news-item check job

* fix: py3.10 error while starting

the match statement is not supported.
while the syntax support is only upto py3.8

* fix: news-item checker

* chore: enable fail report for py310 tests

* test: add test for ptk_shell
2021-06-07 13:40:40 -04:00
Noorhteen Raja NJ
948129b7a0
feat: add flake8-bugbear (#4288)
* feat: add flake8-bugbear

* style: remove pylint disable comments

* chore: add flake8 as pre-push check

* chore: add bunch pf pre-commit hooks

* style: remove hasattr __call__
2021-05-26 23:15:34 +03:00
Noorhteen Raja NJ
38295a1dd9
Remove globals (#4280)
* refactor: remove usage of global variables in abbrevs.py

* chore: add flake8-mutable to prevent mutable defaults

* fix: abbrevs expand test

* refactor: add xonsh session singleton

* refactor: fix circular errors when using xonshSession as singleton

* refactor: remove black magicked builtin attributes

* style: black format tests as well

* refactor: update tests to use xonsh-session singleton

* refactor: update abbrevs to not use builtins

* test: remove DummyCommandsCache and patch orig class

* fix: failing test_command_completers

* test: use monkeypatch to update xession fixture

* fix: failing test_pipelines

* fix: failing test_main

* chore: run test suit as single invocation

* test: fix tests/test_xonsh.xsh

* refactor: remove builtins from docs/conf.py

* fix: mypy error in jobs

* fix: test error from test_main

* test: close xession error in test_command_completers

* chore: use pytest-cov for reporting coverage

this will include subprocess calls, and will increase coverage

* style:
2021-05-20 13:14:26 +03:00
Daniel Shimon
f960d4576f
Improve jedi completer (#4264)
* xontrib: jedi: Don't complete partial paths in commands

E.g. when completing "/bin/a" we don't want jedi to complete "/bin/abs"

* xontrib: jedi: Allow case-insensitive completions

* news: Add improve-jedi-completer
2021-05-11 13:10:58 +03:00
Daniel Shimon
224fc55e41
Completion context (#4017)
* completion-context: Add CompletionContextParser placeholder

Implements the xonsh (tab-)completion context parser.
This parser is meant to parse a (possibly incomplete) command line.

* completers: tools: Implement ``contextual_completer`` decorator

This is used to mark completers that want to use the parsed completion context.

* completers: Enable using contextual completers in xonsh/completer.py

* completers: readline, ptk, jupyter: Enable using contextual completers

Pass ``multiline_text`` and ``cursor_index`` to ``Completer.complete()``

* parsers: base: Refactor out a ``raise_parse_error`` function

* tokenize: Enable ``tolerant`` mode

If ``tolerant`` is True, yield ERRORTOKEN instead of
    throwing an exception when encountering an error.

* lexer: Enable ``tolerant`` mode

Tokenize without extra checks (e.g. paren matching).
When True, ERRORTOKEN contains the erroneous string instead of an error msg.

* tests: lexer: Test ``tolerant`` mode

* completion-context: Implement simple CommandContext parsing

* completion-context: tests: Test simple CommandContext parsing

* completion-context: Implement parsing sub-commands

* completion-context: tests: Test parsing sub-commands

* completion-context: Add news file

* completion-context: parser: Add parser table path to relevant locations

Code-coverage, mypy ignore list, etc.

* completion-context: Implement parsing partial strings and line continuations

* completion-context: tests: Test parsing partial strings and line continuations

* completion-context: Convert ``Span`` object to a ``slice``

* completion-context: Refactor out ``create_command`` and ``cursor_in_span``

* completion-context: Implement handling empty commands

* completion-context: tests: Test handling empty commands

* completion-context: Implement handling multiple commands

Separated by newlines, `;`, `and`, `or`, `|`, `&&`, `||`

* completion-context: tests: Test handling multiple commands

Separated by newlines, `;`, `and`, `or`, `|`, `&&`, `||`

* completion-context: Implement handling python context

* completion-context: tests: Test handling python context

* completers: tools: Add `contextual_command_completer`

* completers: Make `complete_skipper` contextual

* completers: Make `complete_from_man` contextual

* completers: Make `complete_from_bash` contextual and add test

* completers: Make `complete_pip` contextual and update tests

* completers: Keep opening string quote if it exists

* completion-context: Handle cursor after a closing quote

For example - cursor at the end of ``ls "/usr/"``.
1. The closing quote will be appended to all completions.
 I.e the completion ``/usr/bin`` will turn into ``/usr/bin"``
2. If not specified, lprefix will cover the closing prefix.
 I.e for ``ls "/usr/"``, the default lprefix will be 6 to include the closing quote.

* completion-context: tests: Test handling cursor after a closing quote

* completion-context: Fix bug with multiple empty commands

e.g. `;;;`

* completion-context: tests: Speed up tests

From ~15 seconds to ~500 ms

* completion-context: Expand commands and subcommands

* completion-context: Simplify `commands` rules

* completion-context: Simplify `sub_expression` rules

* completion-context: Simplify editing a multi-command token

* completion-context: Inline `create_command`

* completion-context: Implement `contextual_command_completer_for` helper

* completers: Make `complete_cd`/`complete_rmdir` contextual and add tests

* completers: path: Don't append a double-backslash in a raw string

When completing a path, if a raw string is used (e.g. `r"C:\Windows\"`),
there's no reason to append a double-backslash (e.g. `r"C:\Windows\\"`).

* completers: Make `complete_xonfig`/`complete_xontrib` contextual and add tests

* completers: Make `complete_completer` contextual and add tests

* completers: Make `complete_import` contextual and add tests

* completion-context: Add python `ctx` attribute

* completion: tools: Simplify `RichCompletion` attributes handling

* completers: Make `base`, `python`, and `commands` contextual

* Add tests
* No need for `python_mode` completer anymore

* completion: tools: Add `append_space` attribute to `RichCompletion`

* completion-context: Get all lines in a main python context

* xontrib: jedi: Make the `jedi` completer contextual

* completers: tools: Remove `get_ptk_completer` and `PromptToolkitCompleter.current_document`

These aren't needed anymore now that contextual completers can access the multiline code (via `PythonContext.multiline_code`).

* completion-context: ptk: Expand aliases

* completion-context: jupyter: Expand aliases and fix line handling

* completer: Preserve custom prefix after closing quote

* completers: bash: Ensure bash completion uses the complete prefix

* completers: pip: Append a space after a pip command

* completers: pip: Prevent bad package name completions

* completers: Remove a common prefix from `RichCompletion` if `display` wasn't provided

* completion-context: Treat cursor at edge of `&& || | ;` as normal args

This will be used for completing a space

* completers: Complete end proc keywords correctly
2021-03-30 13:37:56 -04:00
Noorhteen Raja NJ
b7b2c9a916
fix: abbrevs with callback alters buffer text before expansion (#4156)
* fix: abbrevs with callback alters buffer text before expansion

fixes #3642

* docs: add news item
2021-03-09 09:07:53 -05:00
Noorhteen Raja NJ
d50cf32f84
Feat abbrevs callback (#4031)
* feat: support callbacks in abbrevs dict

facilitate solving problems like #3642

fixes #3642

* test: add tests for abbrevs and news item

* fix: mypy error

* refactor: update imports for xontrib_meta module
2021-01-29 12:18:22 -05:00
Noorhteen Raja NJ
80aca856e4
refactor: convert prompt_ret_code to be a py file (#4032)
to take advantage of flake/coverage
2021-01-12 13:35:38 -05:00
Faris A Chugthai
b4aa80f097
Add brackets to ambiguous data type (#3981)
Without the brackets python defaults to assuming that the iterable is a tuple. In the reference guide `__all__` is explicitly stated to be of type `list`.

Functionally I'll admit this doesn't change anything but to observe the correct usage pattern of `__all__`, simply add the brackets.
2021-01-05 11:26:09 -05:00
Noortheen Raja
7fe724255f feat: upgrade black version to 20.8b1
this changes docstring indendation
but facilitates additional control over new lines with comma
2020-11-25 12:46:35 +05:30
Noorhteen Raja NJ
5ea2ae4f8f
refactor: rewrite xontribs/jedi.xsh -> xontribs/jedi.py to take advan… (#3965)
* refactor: rewrite xontribs/jedi.xsh -> xontribs/jedi.py to take advantage of python tooling

* chore: update elm ci workflow

* test: update test for jedi xontrib
2020-11-23 16:21:43 -05:00
Noortheen Raja
8c88030d6b refactor: some backlog from when flake8 setup 2020-11-08 23:31:10 +05:30
David Strobach
cc5ef74cd7
Add xog xontrib (#3896)
* Changelog entry

* Add xog xontrib

A simple command to establish and print temporary traceback log file.
2020-10-17 11:53:00 -04:00
Noortheen Raja
197251e818 fix: during amalgamate it removes type-ignore comments 2020-10-09 20:19:09 +05:30
a
b8caf65534 no_color to reset 2020-10-09 01:04:52 +03:00
a
19ea4d3af9 Bashisms shopt, complete 2020-09-25 09:57:36 +03:00
a
c3eb629912 new 2020-09-25 00:00:56 +03:00
a
b00cf677ad Mr. Black 2020-09-24 23:28:41 +03:00
anki-code
526bccef36
bashisms set 2020-09-24 23:13:20 +03:00
Bob Hyman
88bba37c3a Merge branch 'master' into environment_fixes 2020-09-23 04:40:26 -04:00
a
08765c4c90 black 2020-09-22 00:11:21 +03:00
anki-code
7f15ff0a64
Delete whole word with Shift+Del
Here should be Control+Backspace but https://github.com/prompt-toolkit/python-prompt-toolkit/issues/257#issuecomment-190328366
2020-09-21 23:51:36 +03:00
Bob Hyman
a9048d2841 Allow "ANSICON", "TERM", "VIRTUAL_ENV" registered envvars to not be in env. 2020-09-07 20:39:35 -04:00
David Strobach
0e2846d66a Use f-string as per the reviewer request 2020-08-28 16:53:45 +02:00
David Strobach
dc0b8a6839 black 2020-08-28 16:53:45 +02:00
David Strobach
dd4088b61d vox: Add combo new+activate and deactivate+rm actions
Implemented via "vox new --activate" and "vox deactivate --remove".
2020-08-28 16:53:45 +02:00
David Strobach
f4794caef7 vox: Fix virtual environment removal
Virtual environment was impossible to delete after
activation/deactivation cycle.
2020-08-23 20:49:32 +02:00
David Strobach
5c2e5a3d8d vox: Restore vox functionality
After the recent changes in environment defaults, the vox xontrib
could not "see" the virtual environments and work with them.
2020-08-23 11:16:26 +02:00
David Strobach
9ba2eb5934 abbrevs: Allow for setting cursor position within expanded abbrev 2020-08-13 14:12:16 +02:00
Anthony Scopatz
a816084d44
Merge pull request #3650 from daniel-shimon/improve-completers
Add tests and fix bugs for RichCompletion and Jedi xontrib
2020-08-04 21:11:47 -05:00
Daniel Shimon
5f8e27b666 xontrib: jedi: Fix bugs in jedi completer 2020-08-05 00:15:17 +03:00
David Strobach
7cf5a91673 Revert abbrevs expansion on the second consecutive space keypress 2020-08-04 16:19:41 +02:00
Anthony Scopatz
41a600de51 Merge branch 'patch-1' of https://github.com/sfermigier/xonsh into vox-rm 2020-08-01 14:37:38 -05:00
Anthony Scopatz
8d676bd061
Merge pull request #3606 from laloch/xontrib-pdb
Add pdb xontrib
2020-08-01 13:34:20 -05:00
Daniel Shimon
f48b37939d xontrib: jedi: Improve Jedi completer
* Use new Jedi API
* Replace the existing python completer
* Create rich completions with extra info
* Use entire multiline document if available
* Complete xonsh special tokens
* Be aware of _ (last result)
* Only show dunder attrs when prefix ends with '_'
2020-07-28 02:58:33 +03:00
David Strobach
bcffe825df Add xontrib-pdb. Runs pdb on SIGUSR1. 2020-06-05 13:35:53 +02:00
Bob Hyman
53bfe8c99c
Add ptk3 (#3521)
* delete package ptk; rename ptk2 to ptk_shell.; leave ptk2 as alias for ptk_shell.
* SHELL_TYPE "prompt_toolkit" only; remove ptk1 specific behavior.
* Doc updates: eliminate reference to prompt-toolkit < 2.0
* update requirements files ptk>=2; test shell_style="none"
* fix ptk2 stub per code review
* Add ptk2 to list of packages to install.
2020-04-18 10:44:27 -04:00
David Strobach
98bd6b6a48 Make autovox work with Python 3.5
We still can't use f-strings because of Python 3.5 support.
2020-04-08 20:13:12 +02:00
Morten Enemark Lund
0d8c0b613a
Merge pull request #3492 from laloch/abbrevs-completions-confirm
abbrevs: do not handle return key while a completion is selected
2020-03-31 14:17:24 +02:00
David Strobach
7e2b8105fa abbrevs: do not handle return key while a completion is selected 2020-03-30 20:05:38 +02:00
David Strobach
e7df18840d abbrevs: only trigger completion if the word is preceded by space 2020-03-27 23:12:34 +01:00
David Strobach
9978f6bdd7 abbrevs: fix possible exception and do some cleanup 2020-03-25 23:36:29 +01:00
David Strobach
20578fe806 black 2020-03-25 22:45:12 +01:00
David Strobach
6d1713c423 abbrevs: move abbrevs dict to the session context 2020-03-25 22:42:35 +01:00
David Strobach
43a4b9b66a abbrevs: fix ptk2 2020-03-25 20:46:41 +01:00
David Strobach
947fa2d0b5 abbrevs: don't overwrite the dictionary if it already exists 2020-03-25 20:35:19 +01:00