Commit Graph

124 Commits

Author SHA1 Message Date
d617dc6869 modules: rename qt.py -> _qt.py
Since it's an implementation detail, and shouldn't be exposed. This also
helps give better error messages when a user writes `import('qt')`,
since otherwise you get an error about `qt doesn't have an initialize
method`, and now you get `qt module doesn't exist`.
2024-04-09 12:27:39 -07:00
2b37101998 meson format command 2024-04-08 10:43:57 -07:00
65ee397f34 cuda module: fully type annotate
Special notes:
- _nvcc_arch_flags is always called with exact arguments, no need for
  default values
- min_driver_version has its args annotation loosened because it has to
  fit the constraints of the module interface?
2024-02-12 23:51:35 -05:00
7d0d610045 ast/introspection: make mypy clean 2024-01-08 19:33:05 -05:00
25fa0e9721 ast: mark visitor and preprocessor as mypy safe
They already are warning free
2024-01-08 19:33:05 -05:00
5cd1147354 ast/printer: fix mypy issues
Other than one case that I think cannot be actually hit (or it would
fail).
2024-01-08 19:33:05 -05:00
78e23e48f2 backends: correct nonebackend return annotation and check in run_mypy
The only backend that can return values in generate() is ninja, so this
was useless cruft.
2023-12-11 21:13:20 +02:00
cf64e062bb run_mypy: avoid type-checking tools against every possible python version 2023-11-26 17:12:52 -05:00
8490eaa29d Add simd.py to run_mypy.py 2023-10-09 17:25:05 -04:00
1ed619d196 run_mypy: add option to run once for each supported version of python
This allows verifying that meson is type-safe under older versions of
Python, which it currently is. Different versions of Python sometimes
have different supported types for an API.

Verify this in CI.

(We flush output to ensure CI prints lines in the right order.)
2023-08-18 15:38:13 -04:00
9ae6e38e90 mypy: add templates to checked modules 2023-07-25 15:50:21 -04:00
a53c6687b6 fully type mconf.py 2023-06-25 10:08:15 -04:00
b411be5edc fully type mdist.py 2023-06-25 10:08:15 -04:00
b01ae087f5 cargo: Add a builder module to the cargo package
This is a helper, currently only used by cargo. It could be moved later
if there are other users.
2023-06-07 19:20:30 -07:00
2d26c272c3 run_mypy: accept the path to an alternative mypy executable
mypy might be installed with a different python than the one run_mypy.py
is using.
2023-03-02 15:52:45 -05:00
3946f1eb17 Revert "target python 3.10 as the mypy language version"
This reverts commit 0b7d935a84.

The issue is fixed in mypy 1.0.0 now.
2023-03-02 15:51:27 -05:00
6c3b0973c4 run_mypy: passthrough unknown options to mypy itself
Useful for running as a thin wrapper in other contexts that expect the
ability to run mypy itself with arbitrary arguments.
2023-03-02 15:33:19 -05:00
2d0c9ce5f2 properly type utils/core.py and add it to mypy
EnvironmentVariables was always broken, it used MutableMapping because
everyone <3 abstract interfaces, especially when they are broken and
don't actually do what you want.

This needs a dict interface, exposing `.copy()`. We either use a dict or
os._Environ, and the latter also supports that.

Also fix a broken import, and the fallout from forgetting to update the
signature of self.envvars in commit b926374205.
2023-01-16 15:30:12 -05:00
6ed6c8cdba modules: fully type the Qt* modules
The base module is fully typed, but the numbered version are not, though
it's pretty trivial to do so.
2023-01-10 09:53:22 -08:00
e8a88f5320 modules: add type annotations to the __init__ module 2023-01-10 09:53:22 -08:00
0b7d935a84 target python 3.10 as the mypy language version
mypy has a bug when running on/for 3.11 which results in incorrect
analysis of the codebase, specifically due to enum.Enum's self.name

See:

https://github.com/python/typeshed/issues/7564
https://github.com/python/mypy/issues/12483
2022-11-06 12:20:36 -05:00
4e374d5cef run_mypy: add extra logging and permit specifying files to check
If those files are not yet known to be typed, skip them. This makes it
possible to trivially check a shortlist of files that were just changed
and see if they regress our mypy coverage. Ideal for use in a git
pre-commit hook.
2022-10-24 00:37:51 -04:00
2dfd952eb9 Move classes used by scripts to their own module
Those classes are used by wrapper scripts and we should not have to
import the rest of mesonlib, build.py, and all their dependencies for
that.

This renames mesonlib/ directory to utils/ and add a mesonlib.py module
that imports everything from utils/ to not have to change `import
mesonlib` everywhere. It allows to import utils.core without importing
the rest of mesonlib.
2022-09-28 19:36:13 -04:00
4135925b60 run_mypy: Add modules/pkgconfig to the list of checked modules 2022-08-18 21:57:36 -04:00
a78992dd81 interpreter: move handling of module stability to interpreter
Thanks to `ModuleInfo`, all modules are just named `foo.py` instead of
`unstable_foo.py`, which simplifies the import method a bit. This also
allows for accurate FeatureNew/FeatureDeprecated use, as we know when
the module was added and if/when it was stabilized.
2022-08-17 16:25:36 -04:00
0bf66ff02c modules/wayland: Add full type checking 2022-07-17 12:58:17 -04:00
4acab57d47 modules/icestorm: use type checking 2022-05-23 23:32:47 -04:00
10fc19ecb4 modules: add typing to the modtest module 2022-05-23 23:32:47 -04:00
a6e08e8fa7 use a more sane check instead of run_custom_lint
Unfortunately, checking for strings without context is exceedingly prone
to false positives, while missing anything that indirectly opens a file.

Python 3.10 has a feature to warn about this though -- and it uses a
runtime check which runs at the same time that the code fails to open
files in the broken Windows locale. Set this up automatically when
running the testsuite.

Sadly, Python's builtin feature to change the warning level, e.g. by
setting EncodingWarning to error at startup, is utterly broken if you
want to limit it to only certain modules. This is tracked in order to be
more efficiently ignored at https://bugs.python.org/issue34624 and
https://github.com/python/cpython/pull/9358

It is also very trigger happy and passing stuff around via environment
variable either messes with the testsuite, or with thirdparty programs
which are implemented in python *such as lots of gnome*, or perhaps
both.

Instead, add runtime code to meson itself, to add a hidden "feature".
In the application source code, running the 'warnings' module, you can
actually get the expected behavior that $PYTHONWARNINGS doesn't have. So
check for a magic testsuite variable every time meson starts up, and if
it does, then go ahead and initialize a warnings filter that makes
EncodingWarning fatal, but *only* when triggered via Meson and not
arbitrary subprocess scripts.
2022-03-01 21:42:52 -05:00
57c8e1a780 run_mypy: add sourceset module 2022-02-23 10:18:34 -08:00
9b04257847 run_mypy: add gnome module 2022-01-18 21:58:24 -05:00
fe51450970 depfile: type annotate 2022-01-10 23:06:20 -05:00
69fa37e9ca Merge pull request #9623 from dcbaker/submit/keyval-typeing
Add type annotations and typed_pos_args to the keyval module
2021-11-28 18:34:10 +02:00
b361fc52dd Add typing to msubprojects.py 2021-11-28 07:10:12 -05:00
e38c4defcb run_mypy: add modules/keyval 2021-11-23 13:20:40 -08:00
cc231de08e modules/windows: use typed_kwargs 2021-10-09 21:34:48 -07:00
246d5f34bb run_mypy: Add the external_project_module 2021-10-04 19:33:43 -07:00
ad65a699f9 docs: Initial reference manual generator 2021-10-03 11:46:34 +02:00
bd2fcb268b modules/i18n: Fix remaining mypy spotted issues 2021-09-30 16:09:14 -07:00
92b21a0045 interpreter/mesonmain: Fix remaining typing problems and add to run_mypy 2021-09-24 10:36:05 -07:00
8d92e6d865 interpreter: Add IntegerHolder 2021-08-31 23:01:21 +02:00
be92e37837 Add Java module
The Java module will serve as a source for easing Java development
within Meson. Currently it only supports generating native header files.
2021-08-22 07:57:29 -07:00
a0e2de02bf run_mypy: add backends/backends 2021-08-20 18:57:19 +02:00
8e2890f6c0 run_mypy: add interpreter/compiler.py 2021-08-16 16:21:51 -07:00
5381ec89af run_mypy: Add interpreter/type_checking to the list of checked modules 2021-08-04 19:09:08 -04:00
c0a2025d03 tests: test that we always set encoding 2021-06-29 11:28:08 +02:00
3e396b3782 fix: Always explicitly set encoding for text files (fixes #8263) 2021-06-29 11:28:08 +02:00
0f237b8d1d linkers: move linkers.py into the linkers package 2021-06-25 19:34:48 +02:00
7c757dff71 holders: Fix the remaining code to respect the holder changes 2021-06-18 23:48:33 +02:00
6fb2f86379 Merge pull request #8822 from dcbaker/submit/annotate-and-check-qt-module
Rewrite the Qt module for type safety!
2021-06-16 20:11:46 +03:00