Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 27 additions & 27 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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
5 changes: 2 additions & 3 deletions rust/src/filesystem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions rust/src/graph/hierarchy_queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand All @@ -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()
Expand All @@ -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::<Vec<_>>();
for child in descendants.clone() {
descendants.extend(self.get_module_descendants(child.token).collect::<Vec<_>>())
Expand All @@ -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
Expand Down
5 changes: 2 additions & 3 deletions rust/src/import_scanning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -151,7 +151,6 @@ fn scan_for_imports_no_py_single_module(
line_contents: imported_object.line_contents,
});
}
}
}
}
}
Expand Down
Loading