Commit Graph

26 Commits

Author SHA1 Message Date
Xavier Claessens 273605f859 Fix since annotation for str "in" operator 2022-11-08 20:48:32 +02:00
Xavier Claessens a6db624aad Implement `in` operator on string 2022-11-06 17:22:00 +02:00
Eli Schwartz 14b2457627 flake8: fix warnings for unused imports
This is supposed to expose all primitives together, but to do that we
need to actually "use" each variable in `__all__`, which we... didn't.
Sorry about that.
2022-08-29 23:32:43 +03:00
Eli Schwartz e19e9ce6f1
interpreter: add a special class to track the lifecycle of get_option() strings 2022-08-22 11:46:34 -04:00
Eli Schwartz 462b35e4b1 flake8: fix various whitespace nits 2022-06-13 13:34:39 +03:00
Eli Schwartz 1c52ac4e15
move various imports into TYPE_CHECKING blocks for neatness 2022-05-23 16:44:08 -04:00
Eli Schwartz df3f064c81
dependencies: move DependencyVariableString handling to declare_dependency
This allows tracking which subproject it came from at the time of
definition, rather than the time of use. As a result, it is no longer
possible for one subproject which knows that another subproject installs
some data files, to expose those data files via its own
declare_dependency.
2022-04-13 17:28:01 -04:00
Eli Schwartz 0e3ed2f655
dependencies: allow get_variable to expose files from subprojects
There are somewhat common, reasonable and legitimate use cases for a
dependency to provide data files installed to /usr which are used as
command inputs. When getting a dependency from a subproject, however,
the attempt to directly construct an input file from a subproject
results in a sandbox violation. This means not all dependencies can be
wrapped as a subproject.

One example is wayland-protocols XML files which get scanned and used to
produce C source files.

Teach Meson to recognize when a string path is the result of fetching a
dep.get_variable(), and special case this to be exempt from subproject
violations.

A requirement of this is that the file must be installed by
install_data() or install_subdir() because otherwise it is not actually
representative of what a pkg-config dependency would provide.
2022-04-13 17:28:01 -04:00
Eli Schwartz c231c4bd2a
move a bunch of imports into TYPE_CHECKING blocks
These are only used for type checking, so don't bother importing them at
runtime.

Generally add future annotations at the same time, to make sure that
existing uses of these imports don't need to be quoted.
2022-03-07 19:09:50 -05:00
Eli Schwartz 0d6972887f
flake8: do not use bare exceptions
In one case, we actually specifically want to catch IndexError only. In
the other case, excepting Exception rather than BaseException is quite
fine.
2022-02-16 23:00:31 -05:00
Eli Schwartz c0b8e02d9f
FeatureNew: add mypy type annotations for subproject arg
Use a derived type when passing `subproject` around, so that mypy knows
it's actually a SubProject, not a str. This means that passing anything
other than a handle to the interpreter state's subproject attribute
becomes a type violation, specifically when the order of the *four*
different str arguments is typoed.
2022-02-14 20:40:41 -05:00
Eli Schwartz d9f55d774c
add location data to various Feature checks 2022-01-27 22:11:48 -05:00
Eli Schwartz cf3a1d31f8 fix some flake8 violations for unused imports
And one undefined T.cast name in a file that isn't yet mypy-ready
anyway.
2022-01-27 10:48:01 -08:00
Eli Schwartz 558f9fed9e
fix regression that broke string.format with list objects
String formatting should validly assume that printing a list means
printing the list itself. Instead, something like this broke:

'one is: @0@ and two is: @1@'.format(['foo',  'bar'], ['baz'])

which would evaluate as:

'one is: foo and two is: bar'

or:

'the value of array option foobar is: @0@'.format(get_option('foobar'))

which should evaluate with '-Dfoobar=[]' as

'the value of array option foobar is: []'

But instead produced:

meson.build:7:0: ERROR: Format placeholder @0@ out of range.

Fixes #9530
2021-11-04 18:57:14 -04:00
Eli Schwartz 8947352889 fix various flake8 whitespace errors 2021-10-27 09:51:52 -04:00
Daniel Mensinger 0fea9965ad interpreter: Revert old path joining behavior (fixes #9450) 2021-10-26 15:16:11 -04:00
Daniel Mensinger 2d8da3cb11 interpreter: Fix missing featuer check (fixes #9425) 2021-10-24 09:58:20 -04:00
Eli Schwartz ba432c87a4 Revert "interpreter: Add FeatureNew check"
This reverts commit c0efa7ab22.

This was a nice idea, or a beautiful hack depending on your perspective.
Unfortunately, it turns out to be a lot harder than we originally
thought. By operating on bare nodes, we end up triggering a FeatureNew
on anything that isn't a string literal, rather than anything that
isn't a string.

Since no one else has come up with a better idea for implementing a
FeatureNew, let's just revert it. Better to not have a warning, than
have it trigger way too often.
2021-10-10 16:59:18 +02:00
Daniel Mensinger dfec4385a7 interpreter: Move RangeHolder out of interpreterbase to interpreter 2021-10-06 22:37:18 +02:00
Daniel Mensinger af0587cb49 interpreter: Holderify arrays and dicts
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-06 22:37:18 +02:00
Eli Schwartz 4ab70c5512
fix extra whitespace
discovered via flake8 --select E303
2021-10-04 16:29:31 -04:00
Daniel Mensinger c0efa7ab22 interpreter: Add FeatureNew check 2021-09-25 12:44:11 +02:00
Daniel Mensinger 6b00c7dc81 Remove helpers.check_stringlist() 2021-09-25 12:44:11 +02:00
Daniel Mensinger d93d01b6c5 interpreter: Introduce StringHolder
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-25 12:44:11 +02:00
Daniel Mensinger 43302d3296 interpreter: Introduce BooleanHolder for the bool primitive 2021-09-01 19:17:01 +02:00
Daniel Mensinger 8d92e6d865 interpreter: Add IntegerHolder 2021-08-31 23:01:21 +02:00