Skip to content

Conversation

@sparxastronomy
Copy link

This PR introduces several updates to the project's configuration and code style management, modernizes dependency handling, and improves code formatting and consistency across Jupyter notebooks. The PEP rule set is selected from Google's public projects, but some can be dropped if it's too much.

The most significant changes are the migration to PEP 621-compliant pyproject.toml, switching to Ruff for linting and formatting, and general code cleanup in notebooks for improved readability and consistency.

Configuration and Dependency Management Updates:

  • Migrated from Poetry to PEP 621-compliant pyproject.toml, updating the [project] section and refactoring dependencies and development dependencies into [dependency-groups]. The build backend is now hatchling, and requires-python is set to >=3.11.
  • Added and configured Ruff for linting and formatting in both pyproject.toml and .pre-commit-config.yaml, replacing previous hooks for Black, Flake8, and Isort. Ruff is now the primary tool for code style enforcement. [1] [2] [3]

Code Style and Formatting Improvements:

  • Updated imports and formatting in src/scida/__init__.py to use explicit as imports for clarity and consistency.
  • Cleaned up and standardized code formatting in Jupyter notebooks, including consistent use of double quotes, improved import ordering, and better chunking for readability. [1] [2] [3] [4] [5]

Notebook Kernel and Version Updates:

  • Updated notebook kernelspecs to use .venv and python3 instead of custom kernel names, and bumped Python version metadata to 3.13.1 for compatibility with updated dependencies. [1] [2] [3]

Minor Code Cleanups:

  • Refactored dictionary comprehensions and print statements for conciseness and style consistency in src/scida/config.py. [1] [2]
  • Added missing blank lines and reordered imports for improved readability in several notebooks. [1] [2] [3] [4] [5] [6]

References: [1] [2] [3] [4] [5]

NOTE: The large diffs are just formatting changes apparently.

All the test cases still seem to work and pass -- at-least on vera.

  • Might be useful to also use UV in the Github's CI

sparxastronomy and others added 7 commits March 4, 2025 15:08
! Do not turn on linting yet
+ Updates imports to use explicit aliases for clarity
+ Improves error handling with f-strings for better readability
+ Refactors to adopt Python 3.10+ type hinting and modern syntax
+ Removes unused imports and redundant code for maintainability
+ Adjusts pre-commit configuration and `.gitignore` for notebooks
+ Updates dependencies and metadata in Jupyter notebooks
PR to merge with upstream scida
@cbyrohl
Copy link
Owner

cbyrohl commented Sep 5, 2025

Thanks Bipra,

it would be cool to move to uv and ruff over poetry and black if straight forward. As you say, there's lots of code reformatting, leading to huge diffs across the code base. I would greatly appreciate if you could give it another try separating out the different changes:

  • uv migration
  • ruff migration

Particularly without adjusting the code base yet with a pre-commit hook that leads to such verbose code changes. The commits should only contain said changes, bumping e.g. the python version should be treated separately (won't bump yet; e.g. see #193)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants