Commit graph

315 commits

Author SHA1 Message Date
Peter Ye
5a525e3789
feat: allow square brackets in command arguments (#5326)
Allow square brackets in command arguments
2024-04-09 22:33:43 +05:30
pre-commit-ci[bot]
66c0490d37
[pre-commit.ci] pre-commit autoupdate (#5271)
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/psf/black: 23.12.1 → 24.1.1](https://github.com/psf/black/compare/23.12.1...24.1.1)

* [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>
2024-01-30 12:23:50 +01:00
Noorhteen Raja NJ
769dfbe6aa
Py 312 pre-liminary support (#5156)
* refactor: project requires 3.9+

changed as per NEP-29
https://numpy.org/neps/nep-0029-deprecation_policy.html

* test: nose type tests are deprecated in pytest now

* fix: deprecation of ast.Str and ast.Bytes and .s attribute access

* fix: deprecation of ast.Num,ast.NameConstant,ast.Ellipsis

* refactor: upgrade code to be py39+ using ruff

the changes are auto-generated

* refactor: remove typing.Annotated compatibility code

* fix: temporarily disable having xonsh syntax inside f-strings

* test: skip failing tests

there is no workaround for this version. It might get solved in the
final release though

* refactor: make XonshSession.completer lazily populated

this speedsup the tests as cmd_cache would not be actively populated
when used in default_completers function

* refactor: make presence of walrus operator default
2023-07-04 22:18:37 +05:30
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
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
Noortheen Raja
f2b7d4ed4f style: sort imports 2022-03-24 19:49:30 +05:30
Noortheen Raja
81b65556a5 chore: update tests 2022-03-24 19:49:30 +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
Noortheen Raja
78091a22f3 style: isort imports
fix #4584
2022-01-31 11:16:51 -05:00
Noorhteen Raja NJ
7c4e207abd
update test xsh usage (#4581)
* todo

* test: remove usage of DummyEnv and setting .env attribute on xession fixture

one step closer to making too much of tweaking to xession during tests

* test: fix tests vox and gitstatus-prompt

* docs: update test-fixture usage

* fix: import flake8 error

* test: remove direct access to XSH in tests

* test: remove usage of XSH in test files

* todo

* test: use tmp-dir to create stubs

* refactor: use fixture factory to mock out XonshSession

* refactor: remove direct access of XSH from functions

* refactor: remove direct access of XSH from functions

* fix: qa checks

* refactor: rename variables to match their values

* test: update failing tests because it had no PATH set previously

* fix: remove builtins usage from pyghooks.py

* style:

* refactor: update tests to use fixtures

* fix: env varialbe is setup per function

some tests accidentally update the env variables and that is leaking
into next tests

* fix: failing vox tests

* test: set commands_cache per test

* test: fix failing tests

* fix: failing tests on linux

ptk-highlight

* fix: failing tests on Windows

cwd-prompt

* test: copy env as to not affect original object

* fix: lazily evaluate cmds-cache in pyghooks

* test: fix failing tests

* fix: qa errors import

* test: set commands-cache per test

while caching path results

* test: speedup test_thread_local_swap

* fix: failing tests on windows

* refactor: Execer doesn't control session

* refactor: XSH.unload will take care of reversing builtins attrs set

* test: use env.update over monkeypatch

* Revert "test: use env.update over monkeypatch"

This reverts commit 010a5022247a098f1741966b8af1bf758663480e.
2022-01-07 17:33:22 -05:00
Peter Ye
b6c61e3343
Fix unpacking of dictionaries inside a dictionary (#4624) 2022-01-07 04:51:06 +05:30
Noorhteen Raja NJ
c2d25ac251
pre-commit hook for pyupgrade (#4583)
* chore: add pyupgrade

* refactor: upgrade code to py3.7+

ran `pre-commit run pyupgrade -a` while excluding changes to ply

* fix: flake errors
2021-12-06 14:42:26 -05:00
Noorhteen Raja NJ
50a1c92004
chore: enable flake8 for tests (#4482) 2021-09-26 11:32:24 -04:00
Noorhteen Raja NJ
a52c364569
refactor: remove unused argument to parser (#4344) 2021-07-01 15:17:45 +03:00
Peter Ye
715fb867b4
Fix parser for subprocess command with leading whitespace (#4331)
* Fix parser for subprocess command with leading whitespace

* Add tests for subprocess leading space

* Add news

* Parameterize parser tests
2021-06-22 18:42:01 +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
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
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
Anthony Scopatz
8fada74d64 get_repo_url() test 2020-10-13 16:33:53 -05:00
David Strobach
6461d9ec73 Add subproc from envvar test 2020-09-16 14:56:45 +02:00
David Strobach
607d649497 Fix environment variable assignment grammar ambiguity 2020-09-16 14:41:38 +02:00
David Strobach
76cd2ea43e Add test for leading variable initialization 2020-09-04 21:55:12 +02:00
David Strobach
f9f485f25d Add tests for args non-default following default 2020-08-28 17:55:05 +02:00
David Strobach
2eb5271fa0 Add PEP 570 pos-only parameters to lambda varargs 2020-08-27 03:28:44 +02:00
David Strobach
79eccc488c Fix pos-only parameters not requiring comma before slash
This fixes `def foo(x /, y):` being accepted as valid syntax.
2020-08-27 03:28:44 +02:00
David Strobach
b5575947ad Fix positional-only args test 2020-08-27 03:28:44 +02:00
David Strobach
af9c5b59bd Add support for PEP 570 positional-only arguments 2020-08-27 03:28:37 +02:00
David Strobach
5d64139b8f Add support for Python 3.8 star expressions in yield statement 2020-08-26 20:37:19 +02:00
David Strobach
fb664b3456 Fix starred return test 2020-08-26 20:32:53 +02:00
David Strobach
c9d45de556 Add support for Python 3.8 star expressions in return statement 2020-08-26 19:14:45 +02:00
Anthony Scopatz
f048b295d6 black updates to tests and docs 2020-08-26 10:10:59 -05:00
David Strobach
b0336dfbe5 Fix list comprehensions with multiple if clauses 2020-08-25 01:34:59 +02:00
David Strobach
5edd851feb Fix literal whitespace being deleted from f-strings
Fixes an issue with
 f"$HOME       = {$HOME}"
resulting in
 "$HOME= /home/foobar"
2020-08-20 05:41:28 +02:00
David Strobach
c3a354781b Finalize f-string handler transition
- Moves the f-string handler into a separate FStringAdaptor class.
- Removes helper dictionary mapping int ID to f-string field.
  The f-string fields are now rather patched early directly into the
  AST as an argument to eval_fstring_field. This solves the problems
  with f-string fields lifespan management.
2020-08-17 13:41:11 +02:00
David Strobach
9879fce927 Support Python 3.8 self-documenting f-string expressions 2020-08-17 04:57:39 +02:00
David Strobach
12c8990e53 Fix f-string tests 2020-08-17 04:57:39 +02:00
David Strobach
40436e3a97 Add walrus tests 2020-08-11 18:26:40 +02:00
Matthias Bussonnier
784c5286ef
Remove most of Python 3.5 compatibility code. (#3654)
There  now should not be any remaining  3,5 conditinal code.
We now directly use inspect's getouterframes, so remove it from
inspector

The 3.5 parser get merged into 3.6 and a number of global vaiable
referring to 3.5/3.6 are now gone.

The only remaining mention is appveyor test, which are anyway failing
but not being seen as so by GitHub, so I'll leave them alone.
2020-08-05 10:29:31 -04:00
Bob Hyman
dd82c5ffd8 Clean up ignorable warnings in clean pytest run 2020-05-08 15:41:06 -04:00
Bob Hyman
26475146e2
Flake8 1 (#3550)
* flake8 fixes -- tests only

* fix ci failure

* integrate fix from is_3551 so tests will pass.

* Update tests/test_builtins.py

Co-authored-by: Gil Forsyth <gforsyth@users.noreply.github.com>
2020-05-05 06:42:28 -04:00
David Strobach
940713f7f8 Add @$() tests 2020-04-08 18:34:47 +02:00
Gil Forsyth
3b011dcfd1
Merge pull request #3107 from laloch/noexpand-raw-string
Do not attempt to expand raw strings in subprocess mode
2019-05-15 15:11:49 -04:00
Anthony Scopatz
f1127ed916 Revert "updated setup.py for Python 3.4 (revert of 91ec14bb6d)"
This reverts commit 002a317951.
2019-05-14 17:41:35 -04:00
Anthony Scopatz
002a317951 updated setup.py for Python 3.4 (revert of 91ec14bb6d) 2019-05-14 17:32:31 -04:00
David Strobach
450a25f4b0 Test parsing of raw string literals in subprocess mode 2019-05-09 19:34:30 +02:00
Rodrigo Oliveira
91ec14bb6d Drop support for Python 3.4
Minimal required Python version is now 3.5.
2019-05-06 16:51:32 -03:00
Gil Forsyth
8a3c8a6832 Add tests for parser and lexer for pf-strings 2018-12-25 17:40:04 -05:00
Anthony Scopatz
41aa65ac1d make AnnAssign Py 3.6+ 2018-11-02 19:18:37 -04:00
Anthony Scopatz
dc1f02c232 added prelim support for annotation assignement 2018-11-02 19:12:06 -04:00
David Strobach
352d105095 test_parser: test import group statement 2018-11-02 20:39:51 +01:00