aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/interpreterbase
AgeCommit message (Collapse)AuthorFilesLines
2021-10-10Fix typos discovered by codespellChristian Clauss3-7/+7
2021-10-09typed_kwargs: Fix when ContainerTypeInfo is used in a tupleXavier Claessens1-35/+52
info.types could be a tuple like (str, ContainerTypeInfo()). That means we have to check types one by one and only print error if none of them matched. Also fix the case when default value is None for a container type, it should leave the value to None to be able to distinguish between unset and empty list.
2021-10-06interpreter: Move RangeHolder out of interpreterbase to interpreterDaniel Mensinger2-25/+0
2021-10-06interpreter: Holderify arrays and dictsDaniel Mensinger4-419/+131
This is the final refactoring for extracting the bultin object logic out of Interpreterbase. I decided to do both arrays and dicts in one go since splitting it would have been a lot more confusing.
2021-10-04fix extra whitespaceEli Schwartz2-2/+0
discovered via flake8 --select E303
2021-09-30interpreterbase/decorators: KwargIfno validator must take an relaxed typeDylan Baker1-1/+1
I've used any because it needs to be infinitely recursive, something that we simply can't model. But basically until it goes into validator we have no way of knowing what's going on, since one can write code like: ```python KwargInfo[str]('arg', object, validator=_some_very_complex_logic_to_get_specific_string) ``` As such, we can't assume that validator is receiving a type _T, it could be anything.
2021-09-25Remove helpers.check_stringlist()Daniel Mensinger5-22/+24
2021-09-25interpreter: Introduce StringHolderDaniel Mensinger4-127/+19
Another commit in my quest to rid InterpreterBase from all higher level object processing logic. Additionally, there is a a logic change here, since `str.join` now uses varargs and can now accept more than one argument (and supports list flattening).
2021-09-14mark a couple of typing-only imports as noqa, to appease pyflakesEli Schwartz1-1/+3
Since it cannot resolve `import typing as T` in order to figure out that T.* is doing annotation-worthy stuff. Since T.cast('Foo') is not actually using Foo except in an annotation context (due to being a string) it requires extra work to resolve, and the only thing that would currently work is actually using 'typing.cast'. However, we have decided to not use it except as T... Since this import is only imported during mypy it's not so bad to noqa it.
2021-09-01interpreter: Introduce BooleanHolder for the bool primitiveDaniel Mensinger3-66/+68
2021-09-01interpreter: Simplify Disabler logicDaniel Mensinger2-16/+8
2021-09-01interpreter: Remove the AND and OR operator enumsDaniel Mensinger1-2/+0
These operators don't make sens to use in ObjectHolders, since this mechanism wouldn't allow for lazy evaluation.
2021-09-01interpreter: Remove permissive from _unholderDaniel Mensinger2-8/+6
2021-08-31interpreter: Add IntegerHolderDaniel Mensinger5-63/+58
2021-08-31interpreter: Introduce operators support for InterpreterObjectsDaniel Mensinger5-5/+202
2021-08-31interpreter: Make comparisons of different types a hard errorDaniel Mensinger1-4/+8
2021-08-31pylint: turn on superflous-parensDylan Baker2-11/+11
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-30decorators: Make unknown kwarg fatalXavier Claessens1-10/+6
2021-08-30Simplify get_callee_argsXavier Claessens4-87/+34
2021-08-27interpreterbase: ensure that the default vaule to KwargInfo is a valid typeDylan Baker1-0/+4
Because currently you can write something like: ```python KwargInfo('capture', bool) ``` Which proclaims "this must be bool", but the default is then not valid.
2021-08-22use even more informative error message for invoking meson in a subdirEli Schwartz1-1/+4
Follow-up on commit 5a7b8d86d0c455680096d47cb87f0de08c0954ac Sometimes, we find a parent meson.build which is also malformed, and we shouldn't suggest that maybe the user meant to use that, if it isn't a valid project() either. Do a rough and dirty check to see if the very first line is a project() declaration, and if not, don't try to be clever and suggest using it. The "invalid source tree" error suffices here, since we're not absolutely sure meson can be successfully run in that parent directory and actually advising people about the wrong location is a lot more confusing than just saying "please figure this out yourself, here is what to look for". Granted, we miss cases where project() comes after blank lines and/or comments, but doing a full AST parse here is excessively overkill and probably too painful to do, and we don't need to be *that* clever. So let's be content with merely going above and beyond the call of duty.
2021-08-22use a more informative error message for invoking meson in a subdirEli Schwartz1-2/+14
Explicitly mention that the project definition is invalid, and clarify that project is `project()` -- a function. Also try to walk the directory tree upward, and if there are parent meson.build files, just say this isn't the project root, and "maybe you meant to run meson there instead?" This won't catch calls to subdir('foo/bar') but we can't be perfect, only better than before and catch the *majority* of such cases, and hopefully it's a lot more clear if meson protests that the project is "invalid, there is no project() function", where the user should look for a potential solution. Fixes #3426
2021-08-16interperterbase: help type checkers do better type deductionDylan Baker1-1/+5
This assert causes several type checkers (both mypy and pyright) to force `obj` to be a base `HoldableObject` instead of the specialized object. Since the check itself may still be valuable as we don't have fully type annotation coverage it's simply been removed when type checking to aid in type specialization.
2021-08-16interpreter: allow KwargInfo.evolve to change the name as wellDylan Baker1-1/+2
2021-08-16Add unset_variable()Tristan Partin1-1/+1
This should be useful for helping to control variable scope within Meson. CMake has something similar for controlling scope.
2021-08-09interpreter: Fix list contains for Holders (fixes #9020 #9047)Daniel Mensinger1-2/+2
2021-08-04interpreterbase/decorators: fix typed_kwargs return typeDylan Baker1-2/+4
Because of the convertor function we have no guarantee that what we're getting is in fact a `Dict[str, TYPE_var]`, it might well be anything in the values, so we need to do some casting and set the return type to object. This works out fine in practice as our declared `TypeDict` inputs in the actual function signatures will be used instead.
2021-07-21Fix meson.version().version_compare() regression in subprojectXavier Claessens1-1/+1
2021-07-10fix: Fix recursive _unholder permissive kwarg (fixes #8977)Daniel Mensinger1-2/+2
2021-07-05condense linesEli Schwartz1-6/+3
2021-07-05more f-strings too complex to be caught by pyupgradeEli Schwartz1-6/+6
2021-07-02fix: get_variable default variables are not ObjectHolders (fixes #8936)Daniel Mensinger4-6/+11
2021-06-29fix: Always explicitly set encoding for text files (fixes #8263)Daniel Mensinger1-1/+1
2021-06-26refactor: Refactor BothLibraries logicDaniel Mensinger5-4/+26
This commit introduces a new type of `HoldableObject`: The `SecondLevelHolder`. The primary purpose of this class is to handle cases where two (or more) `HoldableObject`s are stored at the same time (with one default object). The best (and currently only) example here is the `BothLibraries` class.
2021-06-23Merge pull request #8884 from dcbaker/submit/type-and-annotate-install-functionsJussi Pakkanen1-0/+41
Add annotations for the various install_* functions
2021-06-22Merge pull request #8905 from mensinda/refactorFixJussi Pakkanen1-9/+22
fix: Fix set_variable not holderifying (fixes #8904)
2021-06-22interpreterbase: Add evolve to KwargInfoDylan Baker1-0/+41
This works just like OptionKey.evolve, pass new keyword arguments to override old ones, otherwise the original versions are copied to the new one.
2021-06-21fix: Ensure that build targets have all methods from ExternalProgramDaniel Mensinger1-1/+1
As a side-effect from #8885 `find_program()` returns now `Executable` objects when `meson.override_find_program` is called with an executable target. To resolve this conflict the missing methods from `ExternalProgram` are added to `BuildTarget`.
2021-06-20fix: dicts and list need _holderify for fallbackDaniel Mensinger1-2/+2
2021-06-20fix: Fix set_variable not holderifying (fixes #8904)Daniel Mensinger1-7/+20
2021-06-18holders: remove unholderDaniel Mensinger1-0/+4
2021-06-18holders: Ensure that InterpreterBase is the sole instance for (un)holderifyingDaniel Mensinger5-44/+164
2021-06-18holders: Introduce HoldableObjectDaniel Mensinger1-11/+23
2021-06-18interpreter: Add FileHolder and remove specical case for FileDaniel Mensinger1-3/+1
2021-06-18interpreter: Meson does not have floats --> remove themDaniel Mensinger2-3/+3
2021-06-18interpreter: Add a new MesonInterpreterObject for non-elementary objectsDaniel Mensinger3-4/+9
2021-06-18interpreter: Refactor interpreter.compiler to use ObjectHolderDaniel Mensinger1-2/+2
2021-06-18interpreter: Refactor ObjectHolder to extend InterpreterObjectDaniel Mensinger1-10/+10
2021-06-18decorators: Add not_set_warning to KwargInfoDaniel Mensinger1-1/+7
2021-06-18decorators: Fix typoDaniel Mensinger1-1/+1