Commit Graph

83 Commits

Author SHA1 Message Date
Celeste Wouters c5148d8c73 rewriter: create {add,rm}_extra_files commands
Add ability to mutate a target's `extra_files` list through the
rewriter.

The logic is copied from sources add/rm, but changes the `extra_files`
kwarg instead of the sources positional argument.
Has additional logic to handle creating the `extra_files` list if it
doesn't exist.
2021-12-15 21:21:29 +01:00
Dylan Baker 4d7031437c pylint: turn on superflous-parens
We have a lot of these. Some of them are harmless, if unidiomatic, such
as `if (condition)`, others are potentially dangerous `assert(...)`, as
`assert(condtion)` works as expected, but `assert(condition, message)`
will result in an assertion that never triggers, as what you're actually
asserting is `bool(tuple[2])`, which will always be true.
2021-08-31 16:28:54 -04:00
Dylan Baker 06fdb29daa pylint: turn on superfluous parens warning
Which is really useful for catching parens used with keywords like
assert. Don't use parens with assert, it's bad.
2021-08-31 16:28:54 -04:00
Daniel Mensinger 3e396b3782
fix: Always explicitly set encoding for text files (fixes #8263) 2021-06-29 11:28:08 +02:00
Eli Schwartz 6a0fabc647
mass rewrite of string formatting to use f-strings everywhere
performed by running "pyupgrade --py36-plus" and committing the results
2021-03-04 17:16:11 -05:00
Eli Schwartz 4340bf34fa
various python neatness cleanups
All changes were created by running

"pyupgrade --py3-only --keep-percent-format"

and committing the results. I have not touched string formatting for
now.

- use set literals
- simplify .format() parameter naming
- remove __future__
- remove default "r" mode for open()
- use OSError rather than compatibility aliases
- remove stray parentheses in function(generator) scopes
2021-03-04 17:11:26 -05:00
Luke Elliott 9efcdba0d5 Allow '//' as project function id due to git bash path conversion.
See https://stackoverflow.com/questions/54258996/git-bash-string-parameter-with-at-start-is-being-expanded-to-a-file-path
2021-01-12 17:42:57 +00:00
Dylan Baker e81acbd606 Use a single coredata dictionary for options
This patches takes the options work to it's logical conclusion: A single
flat dictionary of OptionKey: UserOptions. This allows us to simplify a
large number of cases, as we don't need to check if an option is in this
dict or that one (or any of 5 or 6, actually).
2021-01-04 12:20:58 -08:00
Dylan Baker 71db6b04a3 use OptionKey for builtin and base options
I would have prefered to do these seperatately, but they are combined in
some cases, so it was much easier to convert them together.

this eliminates the builtins_per_machine dict, as it's duplicated with
the OptionKey's machine parameter.
2021-01-04 12:20:40 -08:00
Dylan Baker fe973d9fc4 use OptionKey for compiler_options 2021-01-04 12:20:39 -08:00
Dylan Baker 7142c92285 use OptionKey for backend_options 2021-01-04 12:15:41 -08:00
Dylan Baker e2ef6930ff use OptionKey for coredata.user_options 2021-01-04 12:15:41 -08:00
Marc-André Lureau be2c1a4300 rewrite: fix modified member spelling 2020-11-05 21:22:14 +02:00
Marc-André Lureau 7ba7ea0897 rewrite: fix function spelling 2020-11-05 21:22:14 +02:00
John Ericson 278c294aa4 Compiler options per lang
A current rather untyped storage of options is one of the things that
contributes to the options code being so complex. This takes a small
step in synching down by storing the compiler options in dicts per
language.

Future work might be replacing the langauge strings with an enum, and
defaultdict with a custom struct, just like `PerMachine` and
`MachineChoice`.
2020-04-20 23:23:15 +03:00
Daniel Mensinger ab988198c7
review: Initial fixup 2020-03-02 10:47:20 +01:00
Daniel Mensinger c48b0dea27
types: Annotate ast/interpreter.py 2020-03-02 10:34:55 +01:00
Daniel Mensinger a75255bc4c
types: Annotate the AST visitors 2020-03-02 10:34:55 +01:00
Daniel Mensinger c14aea2812
types: Annotate mparser.py
This also fixes that the keys in ArgumentNode.kwargs are
all of the type BaseNode now. Before this commit, it was
possible that both strings and Nodes where used as keys.
2020-03-02 10:34:55 +01:00
Jon Turney c8f8d58273
Rename 'subdir' -> 'filename' in location objects 2020-02-28 11:54:08 +00:00
Jon Turney d1bd4ccf6e
Update rewriter for filename in node location 2020-02-28 11:54:05 +00:00
Daniel Mensinger 09b53c534f types: import typing as T (fixes #6333) 2020-01-08 15:28:17 +01:00
Daniel Mensinger b5cec1c632 lgtm: ignore all safe `__init__ method calls overridden method` warnings 2019-12-05 00:22:10 +02:00
Daniel Mensinger fa4de71faf lgtm: Fix unused variable 2019-12-05 00:22:10 +02:00
Wolfgang Stöggl f037e7ef45 Fix typos found by codespell
- Typos were found by codespell v1.16.0
2019-11-06 09:55:30 -05:00
John Ericson af2d7af998 Per machine do 'build.' and '' option prefixes
See the docs/ changes for details.
2019-06-05 23:05:34 -04:00
Daniel Mensinger 94c6da33a7 rewriter: Fix that default_options would not set the correct id
Currently default_options uses "" for the kwarks id, however this
is incorect and it must be "/". Additionally, this error won't be
ignored in the future with "--skip" (this is why the tests were
passing and this wasn't detected earlier).
2019-06-05 22:27:32 +03:00
Dylan Baker 8e1670cc60 rewriter: optimize the list_to_dict function
This uses an iterator instead of walking a list, which is roughly twice
as fast. This also does away with the pre-check on whether the list is
valid for converting to a dict, and instead handles the case of an
uneven number by catching another exception. This is preferable since
it's a fatal error anyway, so avoiding it in the non-fatal case is
preferable.
2019-04-25 12:28:51 -07:00
Daniel Mensinger bffd28d4b2 rewriter: fix error message 2019-04-21 22:15:27 +03:00
Daniel Mensinger 5f6b94ccb9
rewriter: Renamed _src -> _sources 2019-03-04 13:00:31 +01:00
Daniel Mensinger 617445ea72
rewriter: Make sure variable names are valid 2019-03-04 13:00:31 +01:00
Daniel Mensinger 594bf678c7
rewriter: Require '/' for the project ID 2019-03-04 13:00:30 +01:00
Daniel Mensinger 609a21ff9f
rewriter: Abort on error by default 2019-03-04 13:00:30 +01:00
Daniel Mensinger c957a2aa94
rewriter: Changed line sort key 2019-03-04 13:00:30 +01:00
Daniel Mensinger 5d2f14fce7
rewriter: Quiet logging by default 2019-03-04 13:00:30 +01:00
Daniel Mensinger 06695fec60
rewriter: type definition code fix 2019-03-04 13:00:29 +01:00
Daniel Mensinger e724fd5438
rewriter: Handle duplicate target 2019-03-04 13:00:29 +01:00
Daniel Mensinger b55dbf0fae
rewriter: Dump JSON to stderr instead of stdout 2019-03-04 13:00:07 +01:00
Daniel Mensinger 90b557e38a
rewriter: Remove command alias 2019-03-04 13:00:07 +01:00
Daniel Mensinger 1290330894
rewriter: Renamed tgt_{add,rm} --> target_{add,rm} 2019-03-04 13:00:06 +01:00
Daniel Mensinger eabc35340d
rewriter: Enforce an empty project ID string 2019-03-04 13:00:06 +01:00
Daniel Mensinger 8fad06e8c8
rewriter: Removed python 3.7 feature required=False 2019-03-04 13:00:06 +01:00
Daniel Mensinger 740f6b8f06
rewriter: Implemented a CLI 2019-03-04 13:00:05 +01:00
Daniel Mensinger e72f535fc8
rewriter: Removed debug printing 2019-03-04 13:00:05 +01:00
Daniel Mensinger 0fd4dce906
rewriter: Type annotation cleanup 2019-03-04 13:00:05 +01:00
Daniel Mensinger 2582f311b0
rewriter: Make sure target sources are relative 2019-03-04 13:00:05 +01:00
Daniel Mensinger 760d1bff9c rewriter: Sort source files (#5010)
* rewriter: Sort source files

* rewriter: Natural sorting

* rewriter: Fix flake8

* rewriter: Fixed sorting

* rewriter: Make sorting key more readable

* rewriter: Even simpler key
2019-03-04 13:58:35 +02:00
Daniel Mensinger f9b41d5ecb
mintro: Dependencies from source 2019-03-03 23:19:03 +01:00
Daniel Mensinger 5a22bb7901 rewriter: Use mparser to detect the end of some nodes 2019-03-03 13:57:25 +02:00
Daniel Mensinger 7199cd2095 rewriter: Avoid duplicates 2019-03-02 17:05:10 +02:00