Commit graph

1735 commits

Author SHA1 Message Date
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
Daniel Shimon
4c055d82e8
Update completer cli (#4299)
* completers: Add new completers after the non-exclusives

* completer: Print whether a completer is non-exclusive

* news: Add update-completer-cli
2021-05-30 09:42:55 +03:00
Daniel Shimon
7f8aeefae8
tests: Run tests with the amalgamated xonsh (#4290)
* tests: Run tests with the amalgamated xonsh

* tests: Test xonsh loads correctly interactively

* tests: Ensure tests run from amalgamated xonsh

* environ: Separate $XONSH_DEBUG and $XONSH_NO_AMALGAMATE

* tests: Keep XONSH_NO_AMALGAMATE in a comment for ease of debugging

* tests: Fix monkeypatch for amalgamated code
2021-05-28 15:42:37 +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
Gordon Ball
e02c7d76c4
Test RC loading in different startup configurations (#4279)
* test_main: test lots of startup order combinations

This is based on the startup order described in
https://github.com/xonsh/xonsh/issues/4096#issuecomment-791991841
and adds an (ugly) parameterised test which tries lots of different
CLI combinations, and verifies which RC files (if any) get loaded,
and in what order.

* test_script_startup: skip on windows
2021-05-14 16:12:34 +03:00
Daniel Shimon
27db574d99
Fix annotated assignment (#4278)
* ast: Fix annotated assignment

* ast: Support annotated variable without a value

* tests: Test annotated assign statements

* news: Add annotated-assignment
2021-05-12 12:39:11 -04:00
Gordon Ball
d48c93bdb5
Add support for rc.d drop-in configuration directories (#4256)
* Add support for rc.d drop-in configuration directories

* main: change how --rc, --no-rc are handled

Explicitly pass --no-rc rather than signalling it as an empty --rc, to
indicate that we should suppress both XONSHRC and XONSHRCDIR in that
case.

* Rename XONSHRCDIR -> XONSHRC_DIR

* xonshrc_context: document setting env for XONSHRC_DIR

* main: --rc foo.xsh should suppress XONSHRC_DIR
2021-05-11 16:42:37 -04:00
Gyuri Horak
9400a7cbd4
Fix for crash if $XONSH_COLOR_STYLE is set to something invalid (#4253)
* Fix crash if gruvbox is set to something invalid

* unit test for `ansi_style_by_name` + news
2021-05-11 15:51:50 -04:00
Daniel Shimon
fe63279d26
Fix skip completer (#4263)
* completer: Refactor out complete_from_context

* completers: Fix `skip` completer calculation and completers invocation

* tests: Test commands completers

* news: Add fix-skip-completer

* completers: Make `complete_path` contextual
2021-05-11 15:49:45 -04:00
Andy Kipp
09b31bec10
feat: Add saving current working directory (cwd) to the history (#4271)
* Add saving current working directory (cwd) to the history

* Added XONSH_HISTORY_SAVE_CWD and create PromptHistorySetting section

* news

* Move dummy history to the distinct file

* tests

* tests

Co-authored-by: a <a@a.a>
2021-05-11 15:23:57 -04:00
Daniel Shimon
6df8fe9ba7
Non exclusive completers (#4259)
* completers: Move `apply_lprefix` to completers/tools.py

* completers: Implement non-exclusive completers

* completers: Make end_proc keywords and tokens non-exclusive

* completers: Implement environment vars non-exclusive completer

* news: Add non-exclusive-completers
2021-05-11 09:50:40 -04: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
35f1ba1819
Improve import completions (#4265)
* completers: import: Move `import` completer before `bash` completer

If this completer returns a result, it's definitely an import statement

* completers: import: Complete `import` keyword in `from ... import` statements

* news: Add improve-import-completions
2021-05-11 01:48:53 +03:00
Andy Kipp
0dc896c284
feat: Ability to call the program by name from callable alias with the same name without the infinite loop error (#4218)
* fix aliases infinite loop

* black

* cleaning

* skip_if_on_windows

* skip_if_on_windows

* bump tests

* bump tests

* skip test

* remove skipping test

* Update xonsh/procs/specs.py

Co-authored-by: Daniel Shimon <daniel.shimon22@gmail.com>

* Update xonsh/procs/proxies.py

Co-authored-by: Daniel Shimon <daniel.shimon22@gmail.com>

* Make alias names internal

* Tests

* Tests

* Tests

* tests

Co-authored-by: a <a@a.a>
Co-authored-by: Daniel Shimon <daniel.shimon22@gmail.com>
2021-05-10 09:30:41 -04:00
Noorhteen Raja NJ
4dc08232e6
Fix commands cache testing (#4257)
* fix: update failing commands-cache tests

in some cases, the thread updates the binaries faster than the next call

* chore: upgrade black to 21.5b0

* chore: upgrade mypy to 0.812 version

* fix: handle corrupt commands-cache file

* fix: parser-table output dir. this should be same as the defaults

* fix: flake8 error
2021-05-06 09:54:09 -04:00
Andy Kipp
6d0c23e16f
Close 4215: Added env variable to ignore ./ and ../ in filepath completion (#4241)
* Added env variable to ignore ./ and ../ in filepath completion

* Changed ignore_dots to complete dots as always, never, or upon matching

* Updated news

* Added default 'matching'

* Update ignore_dots.rst

* black

* fix test

* tests

Co-authored-by: Bailey Morgan <bailey.mccarty.morgan@gmail.com>
Co-authored-by: a <a@a.a>
2021-04-27 09:28:17 -04:00
Noorhteen Raja NJ
cb7db29991
Feature/speed up startup (#4106)
* feat: use saved commands_cache between runs

this will speed-up startup time by a small factor (around 0.15s on my
system with ssd and ryzen5)

* test: update env-variable handling for cmds-cache tests

* refactor: add env-variable to control saving commands-cache

* refactor: mypy error fix for commands_cache

* fix: update handling max(iterable

* test: add tests for commands-cache new version

* docs: update env variable doc

* test: add more test for commands-cache caching behaviour
2021-04-21 11:38:06 -04:00
Andy Kipp
039ce96dcd
feat: Added ability to get arguments list in ExecAlias (#4201)
* black

* news

* test

* alias_argN

* ExecAlias docs

* note about merge operator

* $args

* docs

Co-authored-by: a <a@a.a>
2021-04-15 09:39:13 -04:00
Andy Kipp
3785cbf8b4
XONSH_SUBPROC_CAPTURED_PRINT_STDERR to False (#4231)
Co-authored-by: a <a@a.a>
2021-04-13 13:21:43 -04:00
Daniel Shimon
0ac7051db3
Improve bash completions - Pass parsed command line to py-bash-commands (#4219)
* completers: bash: Fix begidx calculation error

* completers: bash: Pass parsed args and quotes to py-bash-completion

* news: Improve bash completions
2021-04-12 15:37:35 -04:00
Andy Kipp
e7b0977910
feat: Added environment variable to hide unwanted printing the stderr when using captured object. (#4221)
* Added XONSH_SUBPROC_CAPTURED_PRINT_STDERR

* black

Co-authored-by: a <a@a.a>
2021-04-12 15:31:45 -04:00
Andy Kipp
16884fc605
Update test_main.py (#4223) 2021-04-07 14:37:21 -04: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
Andy Kipp
9618fa2a36
Added casting CommandPipeline to int, hash, str (#4205)
* cast

* test

* added tests and str

* news

* test

* skip windows

* docs

* docs

* tests

Co-authored-by: a <a@a.a>
2021-03-30 13:36:01 -04:00
bhawkins
7168b262ae
Fix garbage collection of JSON history specified in seconds. (#4098)
* Fix garbage collection of JSON history specified in seconds.

* Add news entry.

* Avoid possible off-by-one error

* Make size_over return value easier to reason about.

* Update gc_seconds test cases.

Co-authored-by: bhawkins <bhawkins@github.com>
2021-03-22 16:20:36 -04:00
Andy Kipp
8ad8b043e8
feat: Added ability to set XONSH_HISTORY_FILE (#4175)
* Added ability to set XONSH_HISTORY_FILE before loading the history backend.

* black

* using XONSH_HISTORY_FILE

* tests

* black

* Convert WindowsPath to str

* Update xonsh/environ.py

Co-authored-by: Gil Forsyth <gforsyth@users.noreply.github.com>

* cleaning

* test sqlite

* test dummy

* typo

* fix 3.6

Co-authored-by: a <a>
Co-authored-by: Gil Forsyth <gforsyth@users.noreply.github.com>
2021-03-16 17:07:11 -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
Gil Forsyth
9bb91a0b4b
Cleanup remaining vended ptk bits (#4130) 2021-03-01 16:55:23 -05:00
Noorhteen Raja NJ
a5522dbb1e
Remove vended ptk (#4107)
* refactor: remove vended_ptk from project

* refactor: handle removal of ptk vendoring

* refactor: update usage of os.scandir

* fix: update incorrect import xonsh.platform.scandir

* test: update os.scandir

* test: update tests that check ptk version matrix

* fix: add missing import ctypes
2021-03-01 11:56:32 -05:00
Noorhteen Raja NJ
c2d5e60799
Py39 support (#4101)
* fix: handle ast.Index and ast.ExtSlice change while Parsing

related to #4100, #4099, #4068, #4038, #4028, #4005,

* fix: py39 raises when lineno & col not given

TypeError: required field "col_offset" missing from keyword

* fix: tuple inside scbscriptor support for py39

* chore: enable py39 ci checks

they were silently failing before

* test: a backlog test for attributes inside subscriptors

this would require debugging deep into the ply parser methods.

* docs: add news item

* test: skip test_rc_with_modified_path on windows

* Update tests/test_parser.py

Co-authored-by: Gil Forsyth <gforsyth@users.noreply.github.com>

* test: mark failing tests for py39 parser

Co-authored-by: Gil Forsyth <gforsyth@users.noreply.github.com>
2021-02-17 12:31:33 -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
Aneesh Durg
1f7f33c93f
Add $HISTCONTROL=ignorespace support (#4062)
* Add $HISTCONTROL=ignorespace support

* Add news and fix formatting

* Move ignore space to happend in append and fix test bugs

* invert conditional

* remove leftover debug info
2021-01-25 16:37:29 -05:00
Danny Sepler
97cb072f9f
Add a better test suite for "vc.py", and fix "include_untracked" logic (#4041)
* move test_prompt to test_base

* move test_prompt to test_vc

* revamp test_vc file

* Add VC_GIT_INCLUDE_UNTRACKED variable, move test_prompt.py to test_base.py

* reduce test_base
2021-01-05 09:26:19 -05:00
Asaf Fisher
da415caf06
Add 'dict' merging operation for the aliases class (#4037)
* aliases: Add merging operation to the aliases dict

* tests: Add tests to the aliases merging operation

* news: Add summary about the Alias merging functionality
2021-01-04 12:44:21 -05:00
Leandro Emmanuel Reina Kiperman
e7e6fd90a7
Edit sys.path while loading RC files (squashed) (#3950) 2021-01-04 12:31:05 -05:00
Noorhteen Raja NJ
bceaafae4d
Add groups to env vars (#4026)
* feat: add grouped-settings for env variables

fixes #4014

style: fix mypy errors

chore: update testing requirements versions

fix: update xonsh.tools import error

* chore: add news item

* fix: update Var.with_default handling env defaults

* fix: set env var.doc_default=DefaultNotGiven

there is a custom handler for it

* chore: update travis

speedup docs generation

* chore: add command to serve docs during development

* docs: add jinja2 helpers/renderers extension for sphinx

* docs: update envvars document

* docs: fix docs failing

* Update xonsh/environ.py

commit suggestion

Co-authored-by: Gil Forsyth <gforsyth@users.noreply.github.com>

* Update xonsh/environ.py

Co-authored-by: Gil Forsyth <gforsyth@users.noreply.github.com>

* Update xonsh/environ.py

Co-authored-by: Gil Forsyth <gforsyth@users.noreply.github.com>

* Update xonsh/environ.py

Co-authored-by: Gil Forsyth <gforsyth@users.noreply.github.com>

* Update xonsh/environ.py

Co-authored-by: Gil Forsyth <gforsyth@users.noreply.github.com>

* Update xonsh/environ.py

Co-authored-by: Gil Forsyth <gforsyth@users.noreply.github.com>

* refactor: update rst-extension

Co-authored-by: Gil Forsyth <gforsyth@users.noreply.github.com>
2021-01-04 12:21:44 -05:00
Anthony Scopatz
17f86d359e
callable default skips validation (#3668)
* callable default skips validation

* default value

* black

* today func

* store called defaults
2020-12-18 14:42:18 -05:00
Noorhteen Raja NJ
a083d28461
Completer py api (#4018)
* feat: add index to sqlite-history table

* feat: support style argument to RichCompletion object

this will enable setting style for ptk completers

* feat: add xonsh cli/argparser utils

* feat: add python api for adding/removing completers

fixes #3972

* fix: mypy error

* docs: add api doc

* fix: circular imports

* docs:

* fix: testing get-doc cross-platform

* Update xonsh/completers/_aliases.py

Co-authored-by: Gil Forsyth <gforsyth@users.noreply.github.com>

* Update xonsh/completers/_aliases.py

Co-authored-by: Gil Forsyth <gforsyth@users.noreply.github.com>

* style: convert % to f-strings

Co-authored-by: Gil Forsyth <gforsyth@users.noreply.github.com>

Co-authored-by: Gil Forsyth <gforsyth@users.noreply.github.com>
2020-12-16 14:26:22 -05:00
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
Dominic Ward
aa7279b987
Path complete given path literal (#3828)
* Support path completion from path literal

* Test path completion when prefix is partial p-string

* Update news

* Update news

* fix test: expect string literal

* Support completion of raw-path strings

* Resolve raw-string issues when testing on Windows

* Simplify p-string prefix checks

* Fix test

* Update news

* fix news: rst

* Use raw path string to simplify test

* Test path from partial string

* Try case sensitive completion
2020-11-16 09:46:42 -05:00
Anthony Scopatz
913077b0b0
Merge pull request #3960 from jnoortheen/use-individual-file-for-xontrib-meta
Use individual file for xontrib meta
2020-11-10 14:44:41 -06:00
Noortheen Raja
2b947e9e66 refactor: replace xontribs.json with xontribs_meta.py
closes #3931
2020-11-10 22:12:27 +05:30
Anthony Scopatz
4087fc95a8
Merge pull request #3925 from daniel-shimon/command-pipeline-raw-out
procs: Add CommandPipeline.raw_out for retreival of the raw stdout bytes
2020-11-10 10:07:27 -06:00
Anthony Scopatz
996892aec8
Merge pull request #3933 from dyuri/ptk_support_for_themes
PTK support for custom themes (second try)
2020-11-09 22:09:06 -06:00
Daniel Shimon
97d076855b procs: Allow bytes objects in the @() operator 2020-11-06 18:33:27 +02:00
Daniel Shimon
fb9b5eb709 procs: Add CommandPipeline.raw_out and raw_err for retreival of the raw stdout/err bytes 2020-11-06 15:38:34 +02:00
Bob Hyman
b44dc70af7
Add $COMPLETION_MODE='menu-complete' to enable readline menu-complete (#3876)
* Add $COMPLETION_MODE='menu-complete' to enablereadline menu-complete -like behavor in completion.

* Tests

Co-authored-by: Bob Hyman <bob.hyman@bobssoftwareworks.com>
2020-11-05 16:12:15 -05:00
Gyuri Horak
e2701cb134
ansi color fix + unit tests extended with new (non-pygments) values 2020-10-27 17:28:19 +01:00
Gyuri Horak
31dd811ef0
re-apply original changes 2020-10-27 15:23:58 +01:00
Anthony Scopatz
f99bfe1c94
Revert "PTK support for custom themes" 2020-10-26 10:48:00 -05:00