From d3aade896c4f8e21663c0f0030430f4838073d28 Mon Sep 17 00:00:00 2001 From: Peter Byfield Date: Fri, 8 Aug 2025 21:47:13 +0200 Subject: [PATCH 1/2] Print versions in CI --- .github/workflows/main.yml | 54 +++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0ecaab7c..0552836a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,9 +15,7 @@ jobs: strategy: matrix: - python-version: [ - "3.9", "3.10", "3.11", "3.12", "3.13-dev" - ] + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13-dev"] os: [ubuntu-latest, macos-latest, windows-latest] steps: @@ -46,6 +44,8 @@ jobs: - uses: actions-rs/toolchain@v1 with: toolchain: stable + - name: Print versions + run: cargo version --verbose && cargo clippy --version - name: Run tests run: cargo test --no-default-features working-directory: ./rust @@ -54,31 +54,31 @@ jobs: working-directory: ./rust benchmarks: - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4 + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 - - name: Install uv - uses: astral-sh/setup-uv@v5 + - name: Install uv + uses: astral-sh/setup-uv@v5 - - name: Setup python - uses: actions/setup-python@v5 - with: - python-version: "3.13" - allow-prereleases: true + - name: Setup python + uses: actions/setup-python@v5 + with: + python-version: "3.13" + allow-prereleases: true - # Temporarily install hardcoded dependencies here. - # Codspeed doesn't work well with tox, as it runs the tox installation process as part of the benchmarking - # process, which is very slow. - - name: Install dependencies - run: | - python -VV - uv venv - uv pip install pytest==7.4.4 pyyaml==6.0.1 pytest-codspeed==3.2.0 Django==5.1.1 /home/runner/work/grimp/grimp + # Temporarily install hardcoded dependencies here. + # Codspeed doesn't work well with tox, as it runs the tox installation process as part of the benchmarking + # process, which is very slow. + - name: Install dependencies + run: | + python -VV + uv venv + uv pip install pytest==7.4.4 pyyaml==6.0.1 pytest-codspeed==3.2.0 Django==5.1.1 /home/runner/work/grimp/grimp - - name: Run benchmarks - uses: CodSpeedHQ/action@v3 - with: - token: ${{ secrets.CODSPEED_TOKEN }} - run: | - uv run pytest tests/benchmarking/ --codspeed + - name: Run benchmarks + uses: CodSpeedHQ/action@v3 + with: + token: ${{ secrets.CODSPEED_TOKEN }} + run: | + uv run pytest tests/benchmarking/ --codspeed From 55dccc8566f727a6ac0f40f35241e854a9c0a7a1 Mon Sep 17 00:00:00 2001 From: Peter Byfield Date: Fri, 8 Aug 2025 21:57:46 +0200 Subject: [PATCH 2/2] Fix clippy issues --- rust/src/filesystem.rs | 5 ++--- rust/src/graph/hierarchy_queries.rs | 8 ++++---- rust/src/import_scanning.rs | 5 ++--- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/rust/src/filesystem.rs b/rust/src/filesystem.rs index a73725b5..f145734b 100644 --- a/rust/src/filesystem.rs +++ b/rust/src/filesystem.rs @@ -87,12 +87,11 @@ impl FileSystem for RealBasicFileSystem { // Coding specification needs to be in the first two lines, or it's ignored. for line in s.lines().take(2) { - if let Some(captures) = encoding_re.captures(line) { - if let Some(encoding_name) = captures.get(1) { + if let Some(captures) = encoding_re.captures(line) + && let Some(encoding_name) = captures.get(1) { detected_encoding = Some(encoding_name.as_str().to_string()); break; } - } } if let Some(enc_name) = detected_encoding { diff --git a/rust/src/graph/hierarchy_queries.rs b/rust/src/graph/hierarchy_queries.rs index 462367d4..08379e44 100644 --- a/rust/src/graph/hierarchy_queries.rs +++ b/rust/src/graph/hierarchy_queries.rs @@ -17,7 +17,7 @@ impl Graph { } // TODO(peter) Guarantee order? - pub fn all_modules(&self) -> impl ModuleIterator { + pub fn all_modules(&self) -> impl ModuleIterator<'_> { self.modules.values() } @@ -28,7 +28,7 @@ impl Graph { } } - pub fn get_module_children(&self, module: ModuleToken) -> impl ModuleIterator { + pub fn get_module_children(&self, module: ModuleToken) -> impl ModuleIterator<'_> { let children = match self.module_children.get(module) { Some(children) => children .iter() @@ -42,7 +42,7 @@ impl Graph { /// Returns an iterator over the passed modules descendants. /// /// Parent modules will be yielded before their child modules. - pub fn get_module_descendants(&self, module: ModuleToken) -> impl ModuleIterator { + pub fn get_module_descendants(&self, module: ModuleToken) -> impl ModuleIterator<'_> { let mut descendants = self.get_module_children(module).collect::>(); for child in descendants.clone() { descendants.extend(self.get_module_descendants(child.token).collect::>()) @@ -53,7 +53,7 @@ impl Graph { pub fn find_matching_modules( &self, expression: &ModuleExpression, - ) -> impl ModuleIterator + use<'_> { + ) -> impl ModuleIterator<'_> + use<'_> { let interner = MODULE_NAMES.read().unwrap(); let modules: FxHashSet<_> = self .modules diff --git a/rust/src/import_scanning.rs b/rust/src/import_scanning.rs index c2d3d141..ddfd683c 100644 --- a/rust/src/import_scanning.rs +++ b/rust/src/import_scanning.rs @@ -140,8 +140,8 @@ fn scan_for_imports_no_py_single_module( } None => { // It's an external import. - if include_external_packages { - if let Some(imported_module) = + if include_external_packages + && let Some(imported_module) = _distill_external_module(&imported_object_name, found_packages) { imports.insert(DirectImport { @@ -151,7 +151,6 @@ fn scan_for_imports_no_py_single_module( line_contents: imported_object.line_contents, }); } - } } } }