This is required to publish script_bindings, since all files used during
codegen need to be there.
It might also be possible to generate the bindings ahead of time and
vendor them in-tree, but this seems painful to setup from a CI
perspective.
Since there don't seem to be any other users in-tree we can just vendor
into the script-bindings directory.
`ply` is licensed under the BSD 3 clause, and WebIDL under MPL-2.0, with
the licenses available in our cargo package. Both tools won't end up in
`servo` since they are build-time dependencies, so I believe we don't
need to adjust the crate license, or configure `about.toml`.
Testing: Should be covered by existing tests. We don't test if this
allows vendored builds or published builds.
Fixes: Partial fix for #43145
---------
Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
This should prevent recurring issues with exported WPT changes being
prevented from merging due to failing linting checks upstream.
Testing: Can't test WPT linting integration at this point in time.
Fixes: #40662
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This enables type checking for Python files under etc/ci by adding
etc/ci/*.py to pyrefly's project-includes in pyproject.toml.
Enabling these checks surfaced a few type issues, which are addressed
here :
a) Use text=True in subprocess usage to avoid bytes/str mismatches
b) Remove unnecessary encode/decode calls
c) Guard against None stdout in chaos_monkey_test.py
d) Suppress unresolved optional imports in upload_nightly.py
(runtime dependencies declared via uv script metadata)
After these changes, ./mach test-tidy passes successfully locally.
Fixes: #42653
Signed-off-by: Keerti Gupta <24bsm032@iiitdmj.ac.in>
Instead of attempting to manage the virtual environment ourselves, use
`uv` to manage the installation of dependencies.
Since we still have dependencies coming from upstream wpt, we use
`[tool.setuptool]` in our pyproject.toml to ensure that `uv` dynamically
installs our dependencies according to the requirements.txt files.
Additionally, this PR also reverts `--no-project` usage. `--no-project`
was added as a temporary workaround in
https://github.com/servo/servo/pull/37741.
It's not 100% clear to me what exactly the issue was, but
[apparently](https://github.com/servo/servo/pull/37741#pullrequestreview-2985666234)
the issue caused the build to break.
Removing the arg seems to work fine, except that we get a warning about
a missing `requiress-python` value in `pyproject.toml`.
Apparently it is good practice to specify the requirement as `>=` in th
pyroject, and lock the exact version via `uv pin` (which writes to
`.python_version`, where we already pin 3.11.
Testing: Should be covered by existing tests, which compile code on all
platforms.
---------
Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
We have been consolidating all of our Python configuration in
`pyproject.toml`, so we can move our one `uv` specific setting there as
well.
Testing: There is no easy way to write an automated test for this but I
confirmed it work by running `uv run --show-settings`.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This will complete the type annotation on `codegen.py` so we can safely
remove the ignore from `pyproject` configurataion
---------
Signed-off-by: Jerens Lensun <jerensslensun@gmail.com>
Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
`uv` logs a warning if the pyproject.toml does not contain a project
table.
There is not really much point in adding the table, but no downsides
either,
so lets just add the table to make `uv` happy.
Testing: Manual run of `RUST_LOG=warn ./mach run`
Fixes: #38761
Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
This is part of introducing the Ruff rule [flake8-annotations
(ANN)](https://docs.astral.sh/ruff/rules/#flake8-annotations-ann) into
the script_bindings folder.
Since `codegen.py` has 10k lines of code, the strategy is to introduce
the rule first while ignoring the `ANN` Ruff rule for `codegen.py`. We
will then gradually add type annotations slice by slice to ensure no new
errors occur outside of `ANN`.
Testing: `./mach test-wpt webidl`
---------
Signed-off-by: Jerens Lensun <jerensslensun@gmail.com>
This part of function strictly typed in python by adding ANN rule in
ruff, similiar to #38531.
Testing: `./mach test-tidy`
Fixes: Not related to any issues
---------
Signed-off-by: Jerens Lensun <jerensslensun@gmail.com>
This changes will introduce [flake8-annotations
(ANN)](https://docs.astral.sh/ruff/rules/#flake8-annotations-ann) for
python type annotation, this will make all thing related to function
strictly typed in python
This rule will start to affected this directory from now:
- /python -> Root directory
- /python/tidy
- /python/wpt
Testing: `./mach test-tidy`
Fixes: Not related to any issues
---------
Signed-off-by: Jerens Lensun <jerensslensun@gmail.com>
Introduce type checking with Pyrefly in `components/script_bindings`
This commit adds Pyrefly-based type checking to the
`components/script_bindings` directory. The primary goal is to catch
type inconsistencies early and reduce the likelihood of unexpected
runtime errors.
This change affects the `webidl` component, as these script bindings are
responsible for connecting WebIDL specifications to the Rust codebase.
Testing: `./mach test-wpt webidl`
Fixes: *Link to an issue this pull requests fixes or remove this line if
there is no issue*
---------
Signed-off-by: Jerens Lensun <jerensslensun@gmail.com>
This is the first stage of adopting Pyrefly. It introduces the Python
folder and focuses on fixing issues around it.
Testing: *Describe how this pull request is tested or why it doesn't
require tests*
Fixes: *Link to an issue this pull requests fixes or remove this line if
there is no issue*
---------
Signed-off-by: Jerens Lensun <jerensslensun@gmail.com>