Commit graph

1713 commits

Author SHA1 Message Date
Gil Forsyth
df8952d99e fix(sqlite): skip sqlite history tests on windows with python 3.11
I've tried several workarounds and this isn't important enough to keep
spending time on.
2023-01-17 13:27:17 -05:00
Gil Forsyth
33b2ac052b fix: update ptk highlight tests to reflect new tokenizing
temporary fix while we sort out what broke upstream
2023-01-17 13:27:17 -05:00
yotamolenik
e6932747f9
commands_cache: ignore mtime check on non-darwin os (#4988)
* environ: add a configurable value to disable cache

* docs: update env variable doc

Co-authored-by: Noorhteen Raja NJ <jnoortheen@gmail.com>
2022-12-05 21:04:20 +05:30
Noorhteen Raja NJ
c63f75efd0
cmd cache refactor - optimize cache usage (#4954)
* todo:

* refactor: remove usage of singleton in cmd-cache

* refactor: pass aliases/env to commands_cache on creation

reduce the usage of singletons

* fix: setting up mockups for tests

* feat: add $XONSH_CACHE_DIR

* refactor: use cache path to stire cmds-cache

* chore: todo

* feat: efficient cache commands per path and modified time

* refactor: move aliases to commands cache

now XonshSession is not needed to setup cmds-cache

* refactor: update tests

* fix: type annotation

* refactor: init aliases at commands-cache

* test: update failing tests

* fix: handle paths mtime changing

* docs: add news item

* refactor: remove $COMMANDS_CACHE_SIZE_WARNING

* fix: loading on windows fails because of setup sequence

* fix: failing tests
2022-11-14 23:52:10 +05:30
austin-yang
ed11f319fa
Fix: Allows user to assign #XONSH_STYLE_OVERRIDES a {Token:str} dictionary #4375 (#4973)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-10-24 10:46:52 -04:00
Vasilis Gerakaris
9c1a751fee
Fix auto-suggestion completion stacking if no normal completion exists (#4970)
* Fix auto-suggestion completion stacking if no normal completion exists

* Add tests for auto-suggest completions
2022-10-21 00:48:31 +05:30
Blake Ramsdell
b0c81048af
feat: add on_command_not_found event (#4959) 2022-10-11 08:54:12 -04:00
Blake Ramsdell
b5c42d6716
Add XONSH_HISTORY_IGNORE_REGEX support (#4953)
* Add XONSH_HISTORY_IGNORE_REGEX support

* Add changelog text

* Add cleanup notes for XONSH_HISTORY_IGNORE_REGEX

* Rename should_append to is_ignored

* Change is_ignored to a History method

* Remove unused re imports

* Docstring formatting cleanup, Black compliance

* Move XONSH_HISTORY_IGNORE_REGEX to History class

* Clarify with parenthesis

* Formatting compliance

* Add validate_ignore_regex check

* Remove validation comment

* Remove XONSH_HISTORY_IGNORE_REGEX test comments

* Add __init__ chaining to DummyHistory

* Add broken test for XONSH_IGNORE_REGEX

* Remove extra test variants

* Fix unit test environment variable name

* Add test for bad regex error output

* Remove unneeded __init__ chaining

* Add test_is_ignore

* Add is_regex and associated tests

* Add doc for XONSH_HISTORY_IGNORE_REGEX

* Change validate_ignore_regex to use is_regex

* Compile regex once and use a cached property

* Let cached_property handle saving regex
2022-10-05 00:16:42 +05:30
Peter Ye
588881803c
Make gitstatus prompt field values None when there is no git repo (#4920)
Make gitstatus prompt fields None when there is no git repo
2022-08-17 10:08:02 +05:30
Peter Ye
6fa83f8305
Do not capture unthreaded callable aliases run with ![] (#4919)
* Fix `cd` command error message when `$THREAD_SUBPROCS=False`

* also test $[]
2022-08-11 22:50:21 +05:30
Peter Ye
08b302364a
Update terminal title before executing subprocess (#4916)
* Update terminal title before executing subprocess

This eliminates the need to use `pause_call_resume()`, which causes issues
when it sends SIGSTOP to a process that is in the middle of a syscall
(for example, the `swaymsg` command fails when it gets stopped during
a `recv` syscall).

Additionally, this approach is more flexible, as it allows captured
commands and callable aliases to also be updated as expected in the
terminal's title.

* Clear prompt cache in readline shell

* Add type annotation

* Use reset_key() to only reset current_job

* Convert into PromptField class

* Support PromptField with value of None

Allows {current_job:{} | } to work as expected when current_job is a
PromptField.

* Add tests
2022-08-10 09:50:09 +05:30
Stefano Rivera
9e5af81b89
We can't be sure there's a python binary (#4917)
Debian doesn't currently ship a /usr/bin/python binary, unless a user
specifically installs python-is-python3.

See also: #4802
2022-08-09 21:12:40 +05:30
jbw3
f2ca59a291
Fixing bash completion bug when prefix started with '>', '<', or ':' (#4826)
* Fixing bash completion bug when prefix started with '>', '<', or ':'

* Fixing code formatting

* More code formatting fixes

* Fixing test

* Refactor to fix bug by improving completion parser

* Supporting '<' and '>>' in completion parser

* Support for all IO redirect tokens
2022-08-06 14:37:09 +05:30
Noorhteen Raja NJ
dd6c873f3c
fix: empty gitstatus on paths without repo (#4907)
* fix: empty gitstatus on paths without repo

fixes #4900

* docs: add news item

* fix: failing test because of cache in git-dir per cwd
2022-08-03 19:09:43 +05:30
Peter Ye
86e4f004e3
Fix job control for callable aliases (#4901)
* Make job control task queue thread-local

This allows callable aliases to maintain a separate task queue from the
main thread.

* Make job control dictionary thread-local

Use XSH.all_jobs for the main thread and a separate dictionary for other
threads. This allows callable aliases to keep track of their jobs
separate from the main thread.

* Implement use_main_jobs() context manager

This allows threaded commands like jobs, disown, and bg to handle the
main thread's job control

* Run commands in the same process group if in a thread

* Fix tests that use jobs and tasks

* Add tests for subprocess call inside alias

* Add news

* Remove type declarations for _jobs_thread_local

Fixes the mypy error: "Type cannot be declared in assignment to non-self attribute"

Co-authored-by: Noorhteen Raja NJ <jnoortheen@gmail.com>
2022-08-03 11:37:26 +05:30
Noorhteen Raja NJ
8a5b50e084
Update test_pip_completer.py (#4890)
* Update test_pip_completer.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-07-25 15:05:00 +05:30
Eddie Peters
8b9a7e2782
fix(pyghooks): Fix some errors caused by an unset Xonsh session env when using XonshLexer as a Pygments plugin. (#4860) 2022-06-30 10:40:58 -04:00
Peter Ye
ed213f852b
fix: string literal concatenation (#4838)
* fix: string literal concatenation

Fix string literal concatenation involving f-strings and path literals.
Raise SyntaxError when string literal concatenation is attempted between
different literal types (e.g. str and bytes).

* Add tests

Make nodes_equal() check whether the values of Constant nodes are equal.

* add news

* update nodes_equal() error msg
2022-06-18 08:34:34 +05:30
Noorhteen Raja NJ
3716f3da86
Pr5 xontrib entrypoints (#4827) 2022-06-17 12:39:12 -04:00
Peter Ye
b2c42ed2f3
feat: f-glob strings (#4835)
* feat: add support for f-glob strings

Move xonsh_pathsearch() into the BaseParser class because it needs to use self._set_error()

Parametrize 6 backtick tests in test_parser.py into test_backtick() (and add cases for f-glob strings)

* add news

* docs: update tutorial

* fix news file
2022-06-12 13:45:16 +05:30
Peter Ye
0202affb1a
Fix ExecAlias return value (#4829) 2022-06-06 10:43:22 +05:30
Peter Ye
be604e7f48
Change ![] to return an object for background command (#4823)
* Change ![] to return an object for background command

* Fix `fg` for commands started in the background

Fixes #4595

This issue was caused by `CommandPipeline.term_pgid` not being set for commands started in the background.
2022-06-05 21:10:21 +05:30
Noorhteen Raja NJ
ecc1ab1020
xontrib load/unload (#4817)
* feat: add function to make event registration from function signature

* docs: add xontrib special functions description

* feat: handle xontribs with special functions

also reduce usage of XSH singleton

* fix: missing XSH

for now import singleton

* docs: fix .rst format

* fix: failing tests

* feat: implement primitive xontrib-unload and xontrib-reload

* chore: give explicit name

* docs: update doc
2022-05-30 15:33:17 +05:30
Peter Ye
259fbe540c
fix: do not append empty/comment-only input to history (#4822)
* add test for importing empty .xsh file

* test: empty lines do not get appended to history

prompt-toolkit needs its own test outside of test_base_shell.py because it uses a custom _push() method

* fix: do not append empty/comment-only input to history

Adds a compile_empty_tree argument to Execer.compile()
By default, the argument is `True`, and `compile()` returns a compiled `pass` statement for comment-only input.
When the argument is `False`, `compile()` returns `None` for comment-only input.

The base shell and prompt-toolkit shell use `compile_empty_tree = False` so that they get `None` as the compiled code and don't append the command to the history.

* add news

* fix tests
2022-05-26 17:50:08 +05:30
Peter Ye
8e1593b6e7
Update prompt-toolkit to 3.0.29 and remove xfail (#4818)
This fixes the failing test_ptk_prompt() test on Windows.
2022-05-25 09:16:34 +05:30
Noorhteen Raja NJ
1e4eb3ade0
feat: filter completions from fish (#4765)
* feat: filter completions from fish

* docs:
2022-05-22 22:44:36 +05:30
Timmy Welch
b123273319
Fix environment variable completion in strings (#4804) 2022-05-21 10:54:36 +05:30
Stefano Rivera
2f3e292cee
We can't be sure there's a python binary (#4802)
* We can't be sure there's a python binary

Debian doesn't currently ship a /usr/bin/python binary, unless a user
specifically installs python-is-python3.

However, we can safely assume that a python3 binary exists.

* Use shutil.which, as suggested in review
2022-05-10 15:55:03 +05:30
Noorhteen Raja NJ
15ff663530
Rm xontrib meta (#4790) 2022-05-04 15:02:20 -04:00
Peter Ye
baa4ade262
fix: item order of pretty-printed dictionaries (#4786) 2022-04-30 08:25:52 +05:30
Noorhteen Raja NJ
5da6a1babc
fix: gitstatus prompt (#4772) 2022-04-23 07:01:04 +05:30
Peter Ye
e1dc61eb04
fix: completions for command argument paths after equal signs (#4767)
* fix: completions for command argument paths after equal signs

* found a better solution to the problem
2022-04-21 21:08:30 +05:30
Peter Ye
09a77c15c9
Fix tab-completion trailing space for cmd arguments that use equals sign (#4750)
* Fix tab-completion trailing space for command arguments that use equals sign

* Add test for completion of path ending with equal sign

* Move test_path_completers.py to tests/completers

* Restore _quote_paths() to original behaviour

* Apply trailing equal sign fix to _bash_quote_paths()

Use _bash_quote_paths instead of _quote_paths in complete_from_bash()

* Do not need to pass quote_paths=_bash_quote_paths
2022-04-16 08:22:54 +05:30
Noorhteen Raja NJ
011c5c00e9
Fix vox env dir (#4736)
* refactor: use stdout passed from function

better handling of errors

* test: no need to skip these on windows

* test: load local plugin

* test: update vox-runin

* test: speedup vox tests

we dont need to test venv, only calls made to it via subprocess

* test: pip.exe on windows
2022-03-27 17:12:52 +05:30
Noortheen Raja
358f501a8a fix: qa errors 2022-03-26 17:43:51 +05:30
Daniel Shimon
71e256e762 tests: virtualenv: Test virtualenv activator 2022-03-26 17:43:51 +05:30
Noortheen Raja
284f794132 test: add back xonfig-info test 2022-03-25 10:41:42 -04:00
Noortheen Raja
6e7ad50968 test: update tests 2022-03-24 19:49:30 +05:30
Noortheen Raja
f2b7d4ed4f style: sort imports 2022-03-24 19:49:30 +05:30
Noortheen Raja
576842c448 refactor: move out jupyter tests 2022-03-24 19:49:30 +05:30
Noortheen Raja
81b65556a5 chore: update tests 2022-03-24 19:49:30 +05:30
Noortheen Raja
8cff41b081 chore: move out jupyter, mpl, distributed, jedi xontribs
they are require extra packages for testing and usage
closes #4726
2022-03-24 19:49:30 +05:30
Noortheen Raja
43cbc770e9 refactor: move xontrib.jedi out 2022-03-24 19:49:30 +05:30
Noortheen Raja
48086a5778 feat: move fixtures to pytest-plugin 2022-03-24 19:49:30 +05:30
Noortheen Raja
4983e67224 test: python completers have become flaky
fix: qa error, it is not a class method

still B019 is raised from bugbear

fix: failing vox tests in windows

fix: unc check on windows on ci

fix: vox failing on windows

get_binary_path already appends .exe
2022-03-22 19:13:11 +05:30
Noortheen Raja
9c2d10c416 fix: ci failure on linux 2022-03-22 19:13:11 +05:30
Noorhteen Raja NJ
d49b164379
gitstatus modular (#4697) 2022-03-21 11:18:36 -04:00
Peter Ye
e5af63bff7
Fix regex globbing for paths that contain special regex characters (#4715)
* Fix regex globbing for paths that contain special regex characters

* Skip regex globbing asterisk character tests on Windows

Asterisks are forbidden in Windows filenames. Plus signs are allowed in Windows filenames, so the plus sign tests run properly.
2022-03-20 01:10:57 +05:30
Peter Ye
b581edb05d
Fix $XONSH_TRACEBACK_LOGFILE path expansion (#4713) 2022-03-15 00:31:24 +05:30
dev2718
0ba5bec86f
Feat: support for match statement for python >= 3.10 (#4672)
* feat: initial match statement support

* refactor assignment exprs for <3.8 compatibility; sort imports

* remove match extensions

* bump qa-workflow python version, minor alterations for qa-pipeline

* add mypy exception

* update mypy version

* Bump workflow main python version to 3.10

* remove outdated note

Co-authored-by: Alexander Firbas <alexander.firbas@gmail.com>
2022-02-25 17:00:00 +05:30