Skip to content

fix: add standardized SPDX license headers to all Python source files#607

Open
joda9 wants to merge 2 commits intodevfrom
feature/#56-add-header-to-all-files
Open

fix: add standardized SPDX license headers to all Python source files#607
joda9 wants to merge 2 commits intodevfrom
feature/#56-add-header-to-all-files

Conversation

@joda9
Copy link
Copy Markdown
Collaborator

@joda9 joda9 commented Mar 18, 2026

Closes #56 (file headers / copyright information).

What changed

License headers (all .py files in edisgo/ + setup.py + doc/conf.py)

  • Added a uniform #-style copyright and license header to every Python file in the project. Previously most files had no header at all; a few used """...""" module-level docstrings for project info, which caused those strings to appear as module documentation in the auto-generated API reference (sphinx-autoapi renders module docstrings).
  • The new header uses # comments so it is invisible to Sphinx, follows the SPDX convention (SPDX-License-Identifier: AGPL-3.0-or-later), and references the git history for contributor attribution instead of hard-coding author names.
  • Removed __copyright__, __license__, __url__, and __author__ module-level dunder attributes from edisgo/tools/config.py (the only file that had them).
  • Existing genuine module docstrings (e.g. edisgo/io/pypsa_io.py) are kept; only project-info boilerplate """...""" strings were removed.

Pre-commit hook

  • Added Lucas-C/pre-commit-hooks (insert-license) to .pre-commit-config.yaml. The hook checks on every commit that the license header is present in all .py files (excluding tests/) and inserts it automatically if missing.
  • License text lives in .license-header.txt for easy central updates.

Flake8 fixes (unrelated to headers, found during the same pass)

  • edisgo/edisgo.py: wrapped two over-long string literals (E501), removed two unused local variables v_b_load / v_b_feed (F841).
  • edisgo/io/generators_import.py: wrapped two over-long comments (E501).
  • edisgo/io/mviews_filters.py: SQLAlchemy == None comparisons kept intentionally (generates IS NULL in SQL); suppressed with # noqa: E711.
  • edisgo/io/mviews_replacement.py: wrapped long docstring examples (E501), removed unused base_prefix local variable (F841), removed duplicate schema assignment.
  • edisgo/io/powermodels_io.py: replaced type(x) == str/dict with isinstance() (E721).
  • edisgo/tools/voltage_over_distance.py: removed unused imports Optional, Tuple, get_path_length_to_station (F401); wrapped over-long string literals (E501).

Please include a summary of the change and which issue is fixed.

Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • New and adjusted code is formatted using the pre-commit hooks
  • New and adjusted code includes type hinting now
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • The Read the Docs documentation is compiling correctly
  • If new packages are needed, I added them the setup.py, and if needed the rtd_requirements.txt, the eDisGo_env.yml and the eDisGo_env_dev.yml.
  • I have added new features to the corresponding whatsnew file

Closes #603 (file headers / copyright information).

## What changed

### License headers (all .py files in edisgo/ + setup.py + doc/conf.py)
- Added a uniform `#`-style copyright and license header to every Python
  file in the project. Previously most files had no header at all; a few
  used `"""..."""` module-level docstrings for project info, which caused
  those strings to appear as module documentation in the auto-generated
  API reference (sphinx-autoapi renders module docstrings).
- The new header uses `#` comments so it is invisible to Sphinx, follows
  the SPDX convention (`SPDX-License-Identifier: AGPL-3.0-or-later`), and
  references the git history for contributor attribution instead of
  hard-coding author names.
- Removed `__copyright__`, `__license__`, `__url__`, and `__author__`
  module-level dunder attributes from `edisgo/tools/config.py` (the only
  file that had them).
- Existing genuine module docstrings (e.g. `edisgo/io/pypsa_io.py`) are
  kept; only project-info boilerplate `"""..."""` strings were removed.

### Pre-commit hook
- Added `Lucas-C/pre-commit-hooks` (`insert-license`) to
  `.pre-commit-config.yaml`. The hook checks on every commit that the
  license header is present in all `.py` files (excluding `tests/`) and
  inserts it automatically if missing.
- License text lives in `.license-header.txt` for easy central updates.

### Flake8 fixes (unrelated to headers, found during the same pass)
- `edisgo/edisgo.py`: wrapped two over-long string literals (E501),
  removed two unused local variables `v_b_load` / `v_b_feed` (F841).
- `edisgo/io/generators_import.py`: wrapped two over-long comments (E501).
- `edisgo/io/mviews_filters.py`: SQLAlchemy `== None` comparisons kept
  intentionally (generates `IS NULL` in SQL); suppressed with
  `# noqa: E711`.
- `edisgo/io/mviews_replacement.py`: wrapped long docstring examples
  (E501), removed unused `base_prefix` local variable (F841), removed
  duplicate `schema` assignment.
- `edisgo/io/powermodels_io.py`: replaced `type(x) == str/dict` with
  `isinstance()` (E721).
- `edisgo/tools/voltage_over_distance.py`: removed unused imports
  `Optional`, `Tuple`, `get_path_length_to_station` (F401); wrapped
  over-long string literals (E501).
@joda9 joda9 linked an issue Mar 18, 2026 that may be closed by this pull request
@joda9 joda9 requested a review from MoritzSchloesser March 19, 2026 11:28
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.

add header to all files

1 participant