fix: add standardized SPDX license headers to all Python source files#607
Open
fix: add standardized SPDX license headers to all Python source files#607
Conversation
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #56 (file headers / copyright information).
What changed
License headers (all .py files in edisgo/ + setup.py + doc/conf.py)
#-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).#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.__copyright__,__license__,__url__, and__author__module-level dunder attributes fromedisgo/tools/config.py(the only file that had them).edisgo/io/pypsa_io.py) are kept; only project-info boilerplate"""..."""strings were removed.Pre-commit hook
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.pyfiles (excludingtests/) and inserts it automatically if missing..license-header.txtfor 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 variablesv_b_load/v_b_feed(F841).edisgo/io/generators_import.py: wrapped two over-long comments (E501).edisgo/io/mviews_filters.py: SQLAlchemy== Nonecomparisons kept intentionally (generatesIS NULLin SQL); suppressed with# noqa: E711.edisgo/io/mviews_replacement.py: wrapped long docstring examples (E501), removed unusedbase_prefixlocal variable (F841), removed duplicateschemaassignment.edisgo/io/powermodels_io.py: replacedtype(x) == str/dictwithisinstance()(E721).edisgo/tools/voltage_over_distance.py: removed unused importsOptional,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.
Checklist:
pre-commithooks