Commit Graph

83 Commits

Author SHA1 Message Date
Dylan Baker ce04a279ae ast/introspection: Fix typing violation due to untyped functions
When we add type annotations to this in compilers this will break,
unless we've already filtered out the non-string arguments.
2020-09-24 12:14:13 -07:00
Dylan Baker 4c2d0eb9bc
Merge pull request #7657 from mensinda/moreTyping
typing: Strict type annotations
2020-09-09 10:31:52 -07:00
Jussi Pakkanen 8d54b7bda3
Merge pull request #7428 from jon-turney/introspector-add-languages
Handle add_languages(native:) in introspector
2020-09-09 19:51:28 +03:00
Jon Turney d712c86a62
Implement add_languages(native:) in introspector 2020-09-09 13:38:59 +01:00
Daniel Mensinger 057c77f7d0
typing: fixup for #7708 2020-09-08 20:46:11 +02:00
Daniel Mensinger 1743f636fd
typing: fix LGTM bot error 2020-09-08 20:15:59 +02:00
Daniel Mensinger e681235e5f
typing: fix code review 2020-09-08 20:15:58 +02:00
Daniel Mensinger 23818fc5a3
typing: more fixes 2020-09-08 20:15:58 +02:00
Daniel Mensinger 3489442848
typing: completely type ast 2020-09-08 20:15:55 +02:00
Daniel Mensinger 9c1e72202d
typing: refactor dict handling 2020-09-08 20:15:55 +02:00
Paolo Bonzini 4ed5c3acbf IntrospectInterpreter: allow dictionaries with nonconstant keys
Something like {a: foo} currently stymies the IntrospectionInterpreter and
breaks introspection of the source directory.  The fix is just to walk the keys
and return a dummy dictionary.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2020-09-08 19:56:20 +02:00
Jon Turney f94e1eed97
Factor out an _add_languages() function in introspector
Factor out an _add_languages() function in introspector, rather than
calling func_add_languages() with arguments crafted to fake an
interpreter call.
2020-09-08 18:01:41 +01:00
Dylan Baker 591e6e94b9 Put machine file and cmd line parsing in Environment
This creates a full set of option in environment that mirror those in
coredata, this mirroring of the coredata structure is convenient because
lookups int env (such as when initializing compilers) becomes a straight
dict lookup, with no list iteration. It also means that all of the
command line and machine files are read and stored in the correct order
before they're ever accessed, simplifying the logic of using them.
2020-08-01 22:00:06 -07:00
Daniel Mensinger 54511b4a0f
ast: Handle NotNode 2020-05-23 18:13:25 +02:00
Daniel Mensinger 96eeef62ea
ast: Add AST JSON printer 2020-05-23 18:13:16 +02:00
Xavier Claessens 4d6faf6a13 interpreterbase: Add warning when built-in object method has no kwargs 2020-03-19 23:01:58 +02:00
Jussi Pakkanen 44ff3e6c7d
Merge pull request #6736 from dcbaker/mesonlib-type-annotations
Mesonlib type annotations
2020-03-08 14:49:23 +02:00
Daniel Mensinger 213d2f18fc ast: Implement dummy evaluate_notstatement 2020-03-06 19:47:33 +01:00
Xavier Claessens b78db74ed5 ast: Do not resolve dict keys
Fixes: #6748
2020-03-06 11:50:22 -05:00
Dylan Baker 1a82880730 mesonbuild/mesonlib: Add type annotations 2020-03-05 09:31:29 -08:00
Daniel Mensinger d67888bf9b
types: Remove redundant __init__() -> None annotation 2020-03-02 10:52:59 +01:00
Daniel Mensinger 0302a697b8
types: Use import typing as T 2020-03-02 10:51:07 +01:00
Daniel Mensinger ab988198c7
review: Initial fixup 2020-03-02 10:47:20 +01:00
Daniel Mensinger ad5df1b9c3
types: Annotate ast/introspection.py 2020-03-02 10:44:01 +01:00
Daniel Mensinger 5a89a6f804
types: (partially) annotate interpreterbase.py
This commit annotates most of interpreterbase.py. However,
there are stil the @wraps missing, since I am unsure what
the types are supposed to be here.
2020-03-02 10:42:43 +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 346b5c4be7
Store filename in node location
Warnings have a location node object (with subdir and lineno
attributes), which is passed as a location: kwarg to mlog.warning() and
formatted in _log_error().

Re-purpose the subdir attribute (path relative to the source root dir,
with an implied filename of 'meson.build'), which is stored into the
node by parser(), to contain a pathname.

(Properly I should rename 'subdir' -> 'file' everywhere, but that's a
lot of churn just to see if this works)

Notes:
The warning location node may also have a colno attribute, which is
currently ignored by _log_error().

We can't currently issue warnings with locations in meson_options.txt
because the filename isn't part of the location (as it's assumed to be
'meson.build).
2020-02-28 11:54:04 +00:00
Jon Turney 534a974da7
Adjust all the other places MesonException file attribute is set
A MesonException has file, lineno and colno attributes, which get
formatted as a location in mlog.exception().

The file attribute got changed from a path relative to the root source
directory to a pathname (absolute or relative to cwd) in one place in
commit b8fbbf59.  Adjust all the other places the file attribute is set
to match.

Also:
Setting MesonException.file seems to be missing in the case where Parser
returned a non-CodeBlockNode object.  Fortunately, that looks like it's
unreachable, but add it just in case.
2020-02-28 11:54:04 +00:00
Daniel Mensinger 09b53c534f types: import typing as T (fixes #6333) 2020-01-08 15:28:17 +01:00
Xavier Claessens 6e865a2330 Add a summary() function for configuration summarization
Based on patch from Dylan Baker.

Fixes #757
2019-12-12 18:30:17 -05:00
Daniel Mensinger fc800a2cb8 mintro: Add version key to --scan-dependencies (fixes #6287) 2019-12-10 20:17:21 +02:00
Xavier Claessens 552e78da4d assert(): Make message argument optional 2019-12-10 18:02:41 +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
Daniel Mensinger bd37147b4b mintro: Fix resolving nodes in kwargs (fixes #5884) 2019-09-04 15:05:41 -07:00
James Hilliard b21fd95f73 Add is_disabler function
This is useful if one needs to check if a variable is a disabler.

Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
2019-08-12 01:05:45 +03:00
Daniel Mensinger b72b5365af mintro: Fix crash related to the sources kwarg (fixes #5741) 2019-07-31 00:30:17 +03:00
Jussi Pakkanen 19cda6b7c9
Merge pull request #5606 from xclaesse/alias_target
Add alias_target() function
2019-07-11 00:34:40 +03:00
Xavier Claessens 12d4031f52 Add alias_target() function 2019-07-10 15:01:18 -04:00
Daniel Mensinger 35b4ae5d61
ast: printer fix index node printing 2019-06-28 13:22:37 +02:00
John Ericson 07777e15d4 Purge `is_cross` and friends without changing user interfaces
In most cases instead pass `for_machine`, the name of the relevant
machines (what compilers target, what targets run on, etc). This allows
us to use the cross code path in the native case, deduplicating the
code.

As one can see, environment got bigger as more information is kept
structured there, while ninjabackend got a smaller. Overall a few amount
of lines were added, but the hope is what's added is a lot simpler than
what's removed.
2019-06-09 13:13:25 -04:00
Daniel Mensinger cacc585b44 ast: fix #5376 2019-05-13 02:48:35 +03:00
Daniel Mensinger 2b5831f94f
Fix flake8-bugbear warnings 2019-04-29 12:22:50 +02:00
Daniel Mensinger e75211d321
Fix builtin variable names 2019-04-29 12:17:40 +02:00
Daniel Mensinger bf98ffca9e
Fix blind exceptions 2019-04-29 12:16:06 +02:00
Dylan Baker 346ab9f0d8 ast/printer: remove useless ternary
The ternary returns True or False from an expression that returns True
or False: i.e. True if bool(value) else False.
2019-04-25 12:28:51 -07:00
Daniel Mensinger 8e587dfeba
ast: Address code review 2019-04-23 09:10:48 +02:00
Daniel Mensinger b7ba98a657
make flake8 happy 2019-04-23 09:10:48 +02:00
Daniel Mensinger 38f2eae681
ast: Make sure to avoid infinite recursions 2019-04-23 09:10:48 +02:00