Commit graph

10267 commits

Author SHA1 Message Date
Vasilis Gerakaris
a5fcfba8be
fix: implement __hash__ method for Env (#4512)
Allows caching in `lru_cache` for `tools.suggest_commands()`

Closes #4510
2021-10-14 17:00:39 -04:00
Noorhteen Raja NJ
20ef5a033c
Ap/trace (#4453)
* feat: use argparser-alias for trace

* test: add test for trace cli

* fix: qs

* fix: update import path

* docs:
2021-10-13 10:04:59 -04: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
Gil Forsyth
1780ba63e3
Fix for fromdircolors crash on Windows (#4502) 2021-10-12 09:45:38 -04:00
Gabriele N. Tornetta
0a2ba6ca89
perf(readers): use mutable buffers (#4498)
This change uses the mutable bytearray to append bytes
from a queue for better performance.
2021-10-07 11:31:51 -04:00
Gabriele N. Tornetta
096926d6c8
perf: cache suggested commands (#4497)
Calls to `suggest_commands` would result in repeated calls to
the Levenshtein distance routine, which whilst optimally
implemented is still expensive. The change proposes to cache the
result instead.
2021-10-07 11:22:51 -04:00
Shanmukha Vishnu
18261c3ace
Fix #4467 (#4500)
* Fix #4467

Fix for Crash with FileNotFoundError when current working directory is deleted

* Fix #4467

Fix for Crash with FileNotFoundError when current working directory is deleted

* Fix #4467

FIx #4467

* Fix #4467

* Fix #4467

* Fix #4467
2021-10-05 10:08:56 -04:00
Noorhteen Raja NJ
e9688e013d
fix: not enough space for completions (#4477)
* fix: not enough space for completions

* discussion update

* docs:
2021-10-05 09:58:29 -04:00
Alexander Sosedkin
c0a2673541
feat: style gitstatus separator (#4492) 2021-09-30 11:15:27 -04:00
Noorhteen Raja NJ
33a5689db2
feat: improve pip completer (#4476)
* feat: improve pip completer

* refactor: optimize imports

* fix: update tests for other completers

* fix: failing tests

* test: fix failing tests

* refactor: make error message clear

exception like KeyError will be more clear now

* qs import

* fix: failing tests on windows

* fix: failing tests on windows

* fix: failing tests on windows

* refactor: optimize imports
2021-09-26 11:33:09 -04:00
Noorhteen Raja NJ
50a1c92004
chore: enable flake8 for tests (#4482) 2021-09-26 11:32:24 -04:00
Noorhteen Raja NJ
1c2be53040
refactor: remove redundant code (#4478) 2021-09-21 16:55:10 -04:00
Noorhteen Raja NJ
fd5911f1a1
feat: add new environment variable to customize tracing (#4300)
* feat: add new environment variable to customize tracing

* fix: failing integration tests

trace variable set from runner

* refactor: rename the variable to XONSH_TRACE_SUBPROC_FUNC

* Update xonsh/procs/specs.py

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

Co-authored-by: Gil Forsyth <gforsyth@users.noreply.github.com>
2021-09-17 09:55:59 -04:00
Daniel Shimon
7ce53f1844
Always capture aliases (#4445)
* specs: Make sure sub-specs are always captured regardless of $XONSH_CAPTURE_ALWAYS

* procs: Ensure env is used in functional aliases

* news: Add always-capture-aliases

* tests: procs: Skip known issues

* tests: Restore all builtins in the 'xonsh_builtins' fixture

* tests: vc: Use monkeypatch to mock CommandsCache functions

* tests: main: Don't use the local machine's xonshrc
2021-09-15 15:14:28 -04:00
FranzAtGithub
9c4a95d055
Fix typo in xpip command for updating xonsh (#4468) 2021-09-14 12:55:19 -04:00
Michael Ramsey
c04a0997ed
Fix: EnvPath.add() not maintain uniqueness with Path objects on replace (#4461)
* Fix: EnvPath.add() not maintain uniqueness with Path objects on replace

* Update tools.py

Removed commented out code left in originally

* Add tests for EnvPath.add() function

* Add test for EnvPath.add() function with pathlib path

* Update tests for EnvPath.add() function to support winblows paths

* Fix xontribs meta page so github links clickable and one minor typo

* Update xonsh/xontribs_meta.py

updated as requested

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

Co-authored-by: Gil Forsyth <gforsyth@users.noreply.github.com>
2021-09-14 12:54:18 -04:00
Daniel Shimon
438c66dfc0
Env swap thread safety (#4465)
* environ: Implement InternalEnvironDict for thread-local overrides

* environ: Make `swap` thread-safe without leaks

Use thread-local storage to override the changes.
This way the changes can't leak to other threads.

* environ: Implement 'get/set_swapped_values' to pass to threads

* procs: Use swapped values in threaded subprocs

This is so the thread will use the same swapped values as the origin one.

* news: Add env-swap-thread-safety
2021-09-13 11:06:55 -04:00
Daniel Shimon
6df8a24fc9
Path completion in python code (#4457)
* completions: path: Fix completing a single-arg python code segment

* tests: completions: path: Test completing python code

* news: Add path-completion-in-python-code
2021-09-07 01:23:49 +03:00
Noorhteen Raja NJ
89f54ee10a
Ap/history (#4454)
* feat: use ArgParserAlias for history command

* feat: cli-utils: support parsing unknown args

* feat: use _unparsed for getting history slices

* fix: use show cmd as default

* fix: update history-diff to allow new format

* fix: make sure that history files are flushed

* fix: remove unused imports

* docs:

* fix: annotation error in older py versions

* refactor: split dispatch function
so that one can intervene before final call

* fix: py3.6-7 has no mock.call_args.kwargs properties

* fix: update _dispatch_func signature

* test: update tests for history-show parser

* fix: amalgam different import path

* fix: cli_utils not amalgamated

when importing as `from xonsh.cli_utils import ...` it is not lazy
loading
2021-09-06 21:38:37 +03:00
Noorhteen Raja NJ
9db8cc4591
Lab/lazy shell attrs (#4429)
* feat: async-prompt lazy load styles

around 0.15sec is offloaded to threads

* docs:

* fix: optimize imports
2021-09-05 23:39:23 +03:00
Samuel Dion-Girardeau
8c228ef061
Improve setup metadata (#4458)
* Add relevant Trove classifiers

From full list: https://pypi.org/classifiers/

* Add all project URLs

* Add keywords

Copied from the repo's tags, minus "hacktoberfest"

* Add news entry for the change

* Use more explicit key for repo URL
2021-09-05 10:45:00 +03:00
Noorhteen Raja NJ
48f1262d9b
refactor: remove unused code (#4459) 2021-09-04 20:11:16 +03:00
Noorhteen Raja NJ
d701ea7282
test: improve ptk_shell tests (#4448)
* test: improve ptk_shell tests

* Update tests

* fix: failing tests
2021-09-03 10:56:05 -04:00
Noorhteen Raja NJ
aec4860625
Ap/dirstack (#4446)
* feat: use ArgparserAlias for dirs command

* refactor: update fn names

* docs:

* docs:
2021-09-02 22:44:00 +03:00
Noorhteen Raja NJ
0a4720b71a
feat: use ArgparserAlias for xontrib (#4441)
* feat: use ArgparserAlias for xontrib

* test: add test for xontrib-name-completer

* fix: bashisms tests should unload module after tests

* test: make assertion failure message obvious

* fix: failing tests because autovox is already loaded in some py versions
2021-09-02 22:17:45 +03:00
Noorhteen Raja NJ
e25ab34e32
Add test for readline shell (#4447)
* fix: ReadlineShell pass stdin/out to Cmd's constructor

* test: add test for readline shell

* chore: increase required coverage

* test:

* fix: failing ci pipeline

* fix: failing ci test
2021-09-02 22:15:20 +03:00
Noorhteen Raja NJ
9d9c071927
chore: combine coverage reports from all platforms supported (#4449)
also upgrade codecov-action version
2021-09-02 18:12:36 +03:00
Noorhteen Raja NJ
80cf91a719
Jnoortheen patch 1 (#4451)
* add codecov badge

* Update README.rst
2021-08-30 21:12:08 +03:00
Noorhteen Raja NJ
6c22b84f80
Ap/disown (#4442)
* feat: use ArgParserAlias for disown command

* feat: add rich-completer

* docs: add news item

* fix: mypy error

* test: add disown completer tests
2021-08-28 19:38:05 +03:00
Noorhteen Raja NJ
076098899a
feat: use argparserAlias for xexec (#4440)
* feat: use argparserAlias for xexec

* docs: news item

* docs: add todo

* fix: failing tests

* fix: failing tests

* fix: update xexec--help test

* feat: add epilog if available to argparse

* feat: implement epilog section for xexec

* docs:
2021-08-28 17:23:20 +03:00
Noorhteen Raja NJ
c4b54e06a1
ArgparserAlias - xonfig2 (#4436)
* feat: use ArgparserAlias for xonfig

* test: update test for xonfig completions

* refactor: update docs

* refactor: use function based completer

* fix: remove old import

* docs:

* fix: merge issues

* test: move xsh_with_aliases to root conftest.py

* docs:

* feat: set subparser's prog from func-name
2021-08-28 14:09:59 +03:00
Noorhteen Raja NJ
31146604fa
feat: use cli_utils to scaffold run-tests (#4434) 2021-08-28 13:40:26 +03:00
Noorhteen Raja NJ
2759b80545
refactor: remove unused code (#4439)
maybe the witch is dead here
2021-08-27 16:26:47 -04:00
Anthony Scopatz
4bdc8822fa
More fixes for when Env is none in commands cache. (#4438)
* Env is not None

* allow env to be none in commands cache for xo
2021-08-27 17:28:25 +02:00
Noorhteen Raja NJ
54f5ae7bb2
Argparser/color+completion (#4391)
* feat: add colored help formatter and alias builder

closes #4284

* feat: add auto-completion support to argparser

* test: update test for completer

* fix: getting doc from params that have annotation

* refactor: use filter-function for checking alias completions

* doc: add discussion abount check for alias having parser

see discussion on
https://github.com/xonsh/xonsh/pull/4267

* type fix

* refactor: use function based completer

* test: fix failing argparser test

* docs: update news item

* update completion for argparser sub-commands to append_space

from comment on
https://github.com/xonsh/xonsh/pull/4267#discussion_r676044508

* docs: update docstring typo

* refactor: move inspect import to top

* feat: support option strings before positionals

and add env setting for showing completions for options by default

* test: update tests after adding new $ALIAS_COMPLETIONS_OPTIONS_BY_DEFAULT

* add suggested completion_context_parse fixture

* docs: add suggested doc for dispatch function

* refactor: use try/except for import of typing.annotated

* refactor: move complete_argparser_aliases to completers/aliases.py

* refactor: move argparser completer to its own module

* style:

* refactor: rename completer to not clash with argparse

* fix: expand option's descriptions

* fix: add completer/argparser to amalgam
2021-08-26 01:32:13 +03:00
Noorhteen Raja NJ
abc98c1bb3
Lab/pretty print test (#4425)
* feat: py2 handling is no longer needed

* feat: add pretty printer tests

* fix: failing tests
2021-08-24 09:29:39 +03:00
Daniel Shimon
9837bd139f
completions: Trace correct completions with $XONSH_TRACE_COMPLETIONS (#4431) 2021-08-24 09:26:51 +03:00
Gil Forsyth
3c79334218
Restore _repr_pretty_ for ${...} Env class (#4427)
* Restore _repr_pretty_ for ${...} Env class

* Indent and use a format-string
2021-08-23 21:43:14 +03:00
cmidkiff87
10778ecaa5
fix check for app execution alias (#4428)
* fix check for app execution alias
issues #3752 and #4426

* added fallback check for pre 3.8

* added news item

* fix file formatting

* Forgot that os.stat() throws OSError for <= 3.7

* fix file formatting
2021-08-21 15:18:13 +02:00
Noorhteen Raja NJ
d7dbfa9011
Lab/py control file (#4420)
* feat: use python's compile for rc.py

* docs: add news item

* docs: update news item

* test: add tests for py-control files

* fix: rst news item

* docs: update news item

* docs: add sample rc.py
2021-08-19 12:40:22 -04:00
Gordon Ball
e59ac28d7d
Support --rc DIR (#4422)
* args: accept --rc dir to load dir/*.xsh

* test_main: add a test for --rc dir

* args: drop unused --config-path, not read anywhere

* news: add entry for rcdir changes
2021-08-19 12:14:20 -04:00
Gordon Ball
14c2c3ce62
Don't modify XONSHRC and XONSHRC_DIR during startup (#4408)
* xonshrc_context: return loaded instead of context, don't touch env

This function returned the context, but the return value is not used by
the sole call site (and would inconsistently be either the env or ctx
depending on other arguments). Redefine the function to return what was
loaded.

The function will also no longer touch the environment variables
XONSHRC, XONSHRC_DIR or LOADED_RC_FILES.

* XonshSession: add rc_files list, and set in start_services

* LOADED_RC_FILES: drop completely

* xonfig: add RC files

* test_main: update tests for changes to XONSHRC{,_DIR}

* news: add entry for xonshrc changes
2021-08-17 11:01:41 -04:00
Noorhteen Raja NJ
1919b7dc80
fix: ptk completer renders new line as ^J (#4419)
* fix: ptk completer renders new line as ^J

* docs: add news item

* fix: failing tests

* style:
2021-08-16 22:14:11 +03:00
Ali Uneri
e955591bcb
Use full paths when launching processes on Windows (#4077)
* Use full paths when launching processes on Windows

Addresses issue #3763.

* Add news item

* Suppress stderr from "which"

* Replace xonsh.xoreutils.which with shutil.which

* Use existing resolved binary location

* Ensure PATHEXT mock is not overwritten

* Add tests for running excutables on windows

* Ensure we don't set overwrite command when binary_loc is none

* tweak tests

* Revert "Ensure PATHEXT mock is not overwritten"

This reverts commit ce5d6ac091.

* Use monkeypatch for chdir

Co-authored-by: Morten Lund <melund@gmail.com>
2021-08-16 22:02:12 +03:00
Daniel Shimon
5c2938c77c
Improve import completions (#4396)
* completers: Add 'import' completion functions from ipython

* completers: Add 'import' completions cache

* completers: Use ipython logic for 'import' completions

* completers: Use ipython logic in completing imported objects

* news: Add improve-import-completions

* tests: completers: Update 'import' completions tests

* completers: Apply lint to new 'import' completions

* completers: Check objects from __all__ are modules when needed

* tests: completers: Add multiple imports tests
2021-08-16 12:01:50 -04:00
Daniel Shimon
201b24235e
docs: Remove highlight shortcuts 'beta' tag (#4403) 2021-08-16 11:42:34 -04:00
Gyuri Horak
7cd840b2a5
Added xontrib-pyrtn to xontrib list (#4413)
* Added `xontrib-pyrtn` to xontrib list

* IPython typo fix
2021-08-16 13:45:10 +03:00
Noorhteen Raja NJ
bb0cf18f7b
refactor: flaky test_xexec. (#4415)
when run alone will fail
2021-08-16 09:25:27 +03:00
Daniel Shimon
bc87ef1df3
completer: Update 'add' documentation (#4418) 2021-08-16 09:17:59 +03:00
Noorhteen Raja NJ
3457e2772d
refactor: pass the file argument to ptk_print (#4416) 2021-08-13 10:57:21 +03:00