diff --git a/.cruft.json b/.cruft.json index 0736c56..88f13ad 100644 --- a/.cruft.json +++ b/.cruft.json @@ -1,21 +1,20 @@ { "template": "https://github.com/Ouranosinc/cookiecutter-pypackage.git", - "commit": "760bcbb2540bd973d57ea1aa1f1b24759f6d0955", + "commit": "66708e5e15f00caaaaf1748bf0a7e041bc5c6243", "checkout": null, "context": { "cookiecutter": { "full_name": "Abel Aoun", "email": "aoun.abel@gmail.com", "github_username": "xarray-contrib", + "orcid_id": "0000-0003-2289-2890", "project_name": "xncml", "project_slug": "xncml", "project_short_description": "Tools for manipulating NcML (NetCDF Markup Language) files with/for xarray", "pypi_username": "bzah", "version": "0.5.1", "use_pytest": "y", - "use_black": "n", "use_conda": "n", - "add_pyup_badge": "n", "make_docs": "y", "add_translations": "n", "command_line_interface": "No command-line interface", @@ -24,7 +23,7 @@ "generated_with_cruft": "y", "__gh_slug": "https://github.com/xarray-contrib/xncml", "_template": "https://github.com/Ouranosinc/cookiecutter-pypackage.git", - "_commit": "760bcbb2540bd973d57ea1aa1f1b24759f6d0955" + "_commit": "66708e5e15f00caaaaf1748bf0a7e041bc5c6243" } }, "directory": null diff --git a/.flake8 b/.flake8 index 2112ec1..e5e221c 100644 --- a/.flake8 +++ b/.flake8 @@ -10,6 +10,7 @@ ignore = D, E, F, + RST210, W503 per-file-ignores = rst-roles = diff --git a/.github/dependabot.yml b/.github/dependabot.yml index dbeb479..eb2c7f1 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -6,7 +6,7 @@ updates: - package-ecosystem: github-actions directory: /.github/workflows schedule: - interval: monthly + interval: "quarterly" groups: actions: patterns: @@ -15,7 +15,7 @@ updates: - package-ecosystem: pip directory: / schedule: - interval: monthly + interval: "quarterly" groups: ci: patterns: diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index b3ab1e5..38cdfbd 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -65,7 +65,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@3599b3baa15b485a2e49ef411a7a4bb2452e7f93 # v3.29.5 + uses: github/codeql-action/init@0499de31b99561a6d14a36a5f662c2a54f91beee # v3.29.5 with: languages: ${{ matrix.language }} build-mode: ${{ matrix.build-mode }} @@ -94,6 +94,6 @@ jobs: exit 1 - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@3599b3baa15b485a2e49ef411a7a4bb2452e7f93 # v3.29.5 + uses: github/codeql-action/analyze@0499de31b99561a6d14a36a5f662c2a54f91beee # v3.29.5 with: category: "/language:${{matrix.language}}" diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml index 6273bca..debb846 100644 --- a/.github/workflows/dependency-review.yml +++ b/.github/workflows/dependency-review.yml @@ -32,4 +32,4 @@ jobs: persist-credentials: false - name: Dependency Review - uses: actions/dependency-review-action@56339e523c0409420f6c2c9a2f4292bbb3c07dd3 # v4.8.0 + uses: actions/dependency-review-action@40c09b7dc99638e5ddb0bfd91c1673effc064d8a # v4.8.1 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 61f17c3..4adbb7b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -24,8 +24,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: - - "3.x" + python-version: [ "3.13" ] steps: - name: Harden Runner uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1 @@ -61,11 +60,7 @@ jobs: strategy: matrix: os: [ 'ubuntu-latest' ] - python-version: - - "3.10" - - "3.11" - - "3.12" - - "3.13" + python-version: [ "3.10", "3.11", "3.12", "3.13" ] steps: - name: Harden Runner uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1 diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml index ab88a3b..011e333 100644 --- a/.github/workflows/publish-pypi.yml +++ b/.github/workflows/publish-pypi.yml @@ -16,6 +16,9 @@ jobs: permissions: # IMPORTANT: this permission is mandatory for trusted publishing id-token: write + strategy: + matrix: + python: [ "3.13" ] steps: - name: Harden Runner uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1 @@ -28,19 +31,24 @@ jobs: pypi.org:443 ruf-repo-cdn.sigstore.dev:443 upload.pypi.org:443 + - name: Checkout Repository uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: persist-credentials: false + - name: Set up Python3 uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0 with: - python-version: "3.x" + python-version: ${{ matrix.python }} + - name: Install CI libraries run: | python -m pip install --require-hashes -r CI/requirements_ci.txt + - name: Build a binary wheel and a source tarball run: | python -m flit build + - name: Publish distribution 📦 to PyPI uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0 diff --git a/.github/workflows/tag-testpypi.yml b/.github/workflows/tag-testpypi.yml index 9675c88..59acebb 100644 --- a/.github/workflows/tag-testpypi.yml +++ b/.github/workflows/tag-testpypi.yml @@ -19,13 +19,20 @@ jobs: - name: Harden Runner uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1 with: - egress-policy: audit + egress-policy: block + allowed-endpoints: > + files.pythonhosted.org:443 + github.com:443 + pypi.org:443 + test.pypi.org:443 + - name: Checkout Repository uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: persist-credentials: false + - name: Create Release - uses: softprops/action-gh-release@6cbd405e2c4e67a21c47fa9e383d020e4e28b836 # 2.3.3 + uses: softprops/action-gh-release@6da8fa9354ddfdc4aeace5fc48d7f679b5214090 # 2.4.1 env: # This token is provided by Actions, you do not need to create your own token GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -42,6 +49,9 @@ jobs: permissions: # IMPORTANT: this permission is mandatory for trusted publishing id-token: write + strategy: + matrix: + python: [ "3.13" ] steps: - name: Harden Runner uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1 @@ -54,20 +64,25 @@ jobs: pypi.org:443 ruf-repo-cdn.sigstore.dev:443 test.pypi.org:443 + - name: Checkout Repository uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: persist-credentials: false + - name: Set up Python3 uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0 with: - python-version: "3.x" + python-version: ${{ matrix.python }} + - name: Install CI libraries run: | python -m pip install --require-hashes -r CI/requirements_ci.txt + - name: Build a binary wheel and a source tarball run: | python -m flit build + - name: Publish distribution 📦 to Test PyPI uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0 with: diff --git a/.github/workflows/workflow-warning.yml b/.github/workflows/workflow-warning.yml index 128b3a5..810ad64 100644 --- a/.github/workflows/workflow-warning.yml +++ b/.github/workflows/workflow-warning.yml @@ -31,6 +31,7 @@ jobs: egress-policy: block allowed-endpoints: > api.github.com:443 + - name: Find Warning Comment uses: peter-evans/find-comment@b30e6a3c0ed37e7c023ccd3f1db5c6c0b0c23aad # v4.0.0 id: fc_warning @@ -39,12 +40,13 @@ jobs: comment-author: 'github-actions[bot]' body-includes: | This Pull Request modifies GitHub workflows and is coming from a fork. + - name: Create Warning Comment if: | (steps.fc_warning.outputs.comment-id == '') && (!contains(github.event.pull_request.labels.*.name, 'approved')) && (github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name) - uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0 + uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0 with: comment-id: ${{ steps.fc_warning.outputs.comment-id }} issue-number: ${{ github.event.pull_request.number }} @@ -53,6 +55,7 @@ jobs: > This Pull Request modifies GitHub Workflows and is coming from a fork. **It is very important for the reviewer to ensure that the workflow changes are appropriate.** edit-mode: replace + - name: Find Note Comment uses: peter-evans/find-comment@b30e6a3c0ed37e7c023ccd3f1db5c6c0b0c23aad # v4.0.0 id: fc_note @@ -60,10 +63,11 @@ jobs: issue-number: ${{ github.event.pull_request.number }} comment-author: 'github-actions[bot]' body-includes: Workflow changes in this Pull Request have been approved! + - name: Update Comment if: | contains(github.event.pull_request.labels.*.name, 'approved') - uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0 + uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0 with: comment-id: ${{ steps.fc_note.outputs.comment-id }} issue-number: ${{ github.event.pull_request.number }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 36bc606..a983494 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,10 +11,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v6.0.0 hooks: - - id: trailing-whitespace - - id: end-of-file-fixer - exclude: '.ipynb' - - id: fix-byte-order-marker - id: name-tests-test args: [ '--pytest-test-first' ] - id: no-commit-to-branch @@ -22,13 +18,19 @@ repos: - id: check-docstring-first - id: check-merge-conflict - id: check-json + - id: pretty-format-json + args: [ '--autofix', '--no-ensure-ascii', '--no-sort-keys' ] + exclude: '.ipynb' - id: check-toml - id: check-yaml args: [ '--allow-multiple-documents' ] - id: debug-statements - - id: pretty-format-json - args: [ '--autofix', '--no-ensure-ascii', '--no-sort-keys' ] + - id: end-of-file-fixer exclude: '.ipynb' + - id: fix-byte-order-marker + - id: name-tests-test + args: [ '--pytest-test-first' ] + - id: trailing-whitespace - repo: https://github.com/pappasam/toml-sort rev: v0.24.3 hooks: @@ -52,8 +54,8 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.13.3 hooks: - - id: ruff - args: [ '--fix' ] + - id: ruff-check + args: [ '--fix', '--show-fixes' ] - id: ruff-format - repo: https://github.com/pycqa/flake8 rev: 7.3.0 @@ -66,7 +68,7 @@ repos: hooks: - id: vulture # - repo: https://github.com/pre-commit/mirrors-mypy -# rev: v1.14.1 +# rev: v1.18.2 # hooks: # - id: mypy - repo: https://github.com/codespell-project/codespell @@ -76,7 +78,7 @@ repos: additional_dependencies: [ 'tomli' ] args: [ '--toml=pyproject.toml' ] # - repo: https://github.com/numpy/numpydoc -# rev: v1.8.0 +# rev: v1.9.0 # hooks: # - id: numpydoc-validation # exclude: ^docs/|^tests/ diff --git a/CI/requirements_ci.in b/CI/requirements_ci.in index faf34a6..fc8485f 100644 --- a/CI/requirements_ci.in +++ b/CI/requirements_ci.in @@ -3,5 +3,6 @@ deptry==0.23.1 flit==3.12.0 pip==25.2 pylint==3.3.8 +tomli==2.1.1 tox-gh==1.5.0 tox==4.30.2 diff --git a/CI/requirements_ci.txt b/CI/requirements_ci.txt index 0934372..f060af7 100644 --- a/CI/requirements_ci.txt +++ b/CI/requirements_ci.txt @@ -1,5 +1,5 @@ # -# This file is autogenerated by pip-compile with Python 3.9 +# This file is autogenerated by pip-compile with Python 3.10 # by the following command: # # pip-compile --generate-hashes --output-file=CI/requirements_ci.txt CI/requirements_ci.in @@ -369,9 +369,9 @@ questionary==2.0.1 \ --hash=sha256:8ab9a01d0b91b68444dff7f6652c1e754105533f083cbe27597c8110ecc230a2 \ --hash=sha256:bcce898bf3dbb446ff62830c86c5c6fb9a22a54146f0f5597d3da43b10d8fc8b # via bump-my-version -requests==2.32.3 \ - --hash=sha256:55365417734eb18255590a9ff9eb97e9e1da868d4ccd6402399eaf68af20a760 \ - --hash=sha256:70761cfe03c773ceb22aa2f671b4757976145175cdfca038c02654d061d6dcc6 +requests==2.32.4 \ + --hash=sha256:27babd3cda2a6d50b30443204ee89830707d396671944c998b5975b031ac2b2c \ + --hash=sha256:27d0316682c8a29834d3264820024b62a36942083d52caf2f14c0591336d3422 # via flit requirements-parser==0.11.0 \ --hash=sha256:35f36dc969d14830bf459803da84f314dc3d17c802592e9e970f63d0359e5920 \ @@ -425,6 +425,7 @@ tomli==2.2.1 \ --hash=sha256:ece47d672db52ac607a3d9599a9d48dcb2f2f735c6c2d1f34130085bb12b112a \ --hash=sha256:f4039b9cbc3048b2416cc57ab3bda989a6fcf9b36cf8937f01a6e731b64f80d7 # via + # -r CI/requirements_ci.in # deptry # pylint # pyproject-api diff --git a/CITATION.cff b/CITATION.cff new file mode 100644 index 0000000..65fbd1c --- /dev/null +++ b/CITATION.cff @@ -0,0 +1,23 @@ +# This CITATION.cff file was generated with cffinit and templated with cookiecutter. +# Visit https://bit.ly/cffinit to generate yours today! + +cff-version: "1.2.0" +title: "xncml" +message: >- + If you use this software, please cite it using the + metadata from this file. +type: "software" +authors: + - given-names: 'Abel' + family-names: 'Aoun' + email: 'aoun.abel@gmail.com' + orcid: "https://orcid.org/0000-0003-2289-2890" +contact: + - given-names: 'Abel' + family-names: 'Aoun' + email: 'aoun.abel@gmail.com' + orcid: "https://orcid.org/0000-0003-2289-2890" +repository-code: "https://github.com/xarray-contrib/xncml" +abstract: "Tools for manipulating NcML (NetCDF Markup Language) files with/for xarray" +license: "Apache-2.0" +version: "0.5.1" diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 894a602..3452ef1 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,133 +1,90 @@ -# Contributor Covenant Code of Conduct +# Contributor Covenant 3.0 Code of Conduct ## Our Pledge -We as members, contributors, and leaders pledge to make participation in our -community a harassment-free experience for everyone, regardless of age, body -size, visible or invisible disability, ethnicity, sex characteristics, gender -identity and expression, level of experience, education, socio-economic status, -nationality, personal appearance, race, caste, color, religion, or sexual -identity and orientation. +We pledge to make our community welcoming, safe, and equitable for all. -We pledge to act and interact in ways that contribute to an open, welcoming, -diverse, inclusive, and healthy community. +We are committed to fostering an environment that respects and promotes the dignity, rights, and contributions of all individuals, regardless of characteristics including race, ethnicity, caste, color, age, physical characteristics, neurodiversity, disability, sex or gender, gender identity or expression, sexual orientation, language, philosophy or religion, national or social origin, socio-economic position, level of education, or other status. The same privileges of participation are extended to everyone who participates in good faith and in accordance with this Covenant. -## Our Standards -Examples of behavior that contributes to a positive environment for our -community include: +## Encouraged Behaviors -* Demonstrating empathy and kindness toward other people -* Being respectful of differing opinions, viewpoints, and experiences -* Giving and gracefully accepting constructive feedback -* Accepting responsibility and apologizing to those affected by our mistakes, - and learning from the experience -* Focusing on what is best not just for us as individuals, but for the overall - community +While acknowledging differences in social norms, we all strive to meet our community's expectations for positive behavior. We also understand that our words and actions may be interpreted differently than we intend based on culture, background, or native language. -Examples of unacceptable behavior include: +With these considerations in mind, we agree to behave mindfully toward each other and act in ways that center our shared values, including: -* The use of sexualized language or imagery, and sexual attention or advances of - any kind -* Trolling, insulting or derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or email address, - without their explicit permission -* Other conduct which could reasonably be considered inappropriate in a - professional setting +1. Respecting the **purpose of our community**, our activities, and our ways of gathering. +2. Engaging **kindly and honestly** with others. +3. Respecting **different viewpoints** and experiences. +4. **Taking responsibility** for our actions and contributions. +5. Gracefully giving and accepting **constructive feedback**. +6. Committing to **repairing harm** when it occurs. +7. Behaving in other ways that promote and sustain the **well-being of our community**. -## Enforcement Responsibilities -Community leaders are responsible for clarifying and enforcing our standards of -acceptable behavior and will take appropriate and fair corrective action in -response to any behavior that they deem inappropriate, threatening, offensive, -or harmful. +## Restricted Behaviors -Community leaders have the right and responsibility to remove, edit, or reject -comments, commits, code, wiki edits, issues, and other contributions that are -not aligned to this Code of Conduct, and will communicate reasons for moderation -decisions when appropriate. +We agree to restrict the following behaviors in our community. Instances, threats, and promotion of these behaviors are violations of this Code of Conduct. -## Scope - -This Code of Conduct applies within all community spaces, and also applies when -an individual is officially representing the community in public spaces. -Examples of representing our community include using an official email address, -posting via an official social media account, or acting as an appointed -representative at an online or offline event. - -## Enforcement +1. **Harassment.** Violating explicitly expressed boundaries or engaging in unnecessary personal attention after any clear request to stop. +2. **Character attacks.** Making insulting, demeaning, or pejorative comments directed at a community member or group of people. +3. **Stereotyping or discrimination.** Characterizing anyone’s personality or behavior on the basis of immutable identities or traits. +4. **Sexualization.** Behaving in a way that would generally be considered inappropriately intimate in the context or purpose of the community. +5. **Violating confidentiality**. Sharing or acting on someone's personal or private information without their permission. +6. **Endangerment.** Causing, encouraging, or threatening violence or other harm toward any person or group. +7. Behaving in other ways that **threaten the well-being** of our community. -Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported to the community leaders responsible for enforcement at -[xarray-core-team@googlegroups.com](mailto:xarray-core-team@googlegroups.com). -All complaints will be reviewed and investigated promptly and fairly. +### Other Restrictions -All community leaders are obligated to respect the privacy and security of the -reporter of any incident. +1. **Misleading identity.** Impersonating someone else for any reason, or pretending to be someone else to evade enforcement actions. +2. **Failing to credit sources.** Not properly crediting the sources of content you contribute. +3. **Promotional materials**. Sharing marketing or other commercial content in a way that is outside the norms of the community. +4. **Irresponsible communication.** Failing to responsibly present content which includes, links or describes any other restricted behaviors. -## Enforcement Guidelines -Community leaders will follow these Community Impact Guidelines in determining -the consequences for any action they deem in violation of this Code of Conduct: +## Reporting an Issue -### 1. Correction +Tensions can occur between community members even when they are trying their best to collaborate. Not every conflict represents a code of conduct violation, and this Code of Conduct reinforces encouraged behaviors and norms that can help avoid conflicts and minimize harm. -**Community Impact**: Use of inappropriate language or other behavior deemed -unprofessional or unwelcome in the community. +When an incident does occur, it is important to report it promptly. To report a possible violation, email [xarray-core-team@googlegroups.com](mailto:xarray-core-team@googlegroups.com). -**Consequence**: A private, written warning from community leaders, providing -clarity around the nature of the violation and an explanation of why the -behavior was inappropriate. A public apology may be requested. +Community Moderators take reports of violations seriously and will make every effort to respond in a timely manner. They will investigate all reports of code of conduct violations, reviewing messages, logs, and recordings, or interviewing witnesses and other participants. Community Moderators will keep investigation and enforcement actions as transparent as possible while prioritizing safety and confidentiality. In order to honor these values, enforcement actions are carried out in private with the involved parties, but communicating to the whole community may be part of a mutually agreed upon resolution. -### 2. Warning -**Community Impact**: A violation through a single incident or series of -actions. +## Addressing and Repairing Harm -**Consequence**: A warning with consequences for continued behavior. No -interaction with the people involved, including unsolicited interaction with -those enforcing the Code of Conduct, for a specified period of time. This -includes avoiding interactions in community spaces as well as external channels -like social media. Violating these terms may lead to a temporary or permanent -ban. +If an investigation by the Community Moderators finds that this Code of Conduct has been violated, the following enforcement ladder may be used to determine how best to repair harm, based on the incident's impact on the individuals involved and the community as a whole. Depending on the severity of a violation, lower rungs on the ladder may be skipped. -### 3. Temporary Ban +1) Warning + 1) Event: A violation involving a single incident or series of incidents. + 2) Consequence: A private, written warning from the Community Moderators. + 3) Repair: Examples of repair include a private written apology, acknowledgement of responsibility, and seeking clarification on expectations. +2) Temporarily Limited Activities + 1) Event: A repeated incidence of a violation that previously resulted in a warning, or the first incidence of a more serious violation. + 2) Consequence: A private, written warning with a time-limited cooldown period designed to underscore the seriousness of the situation and give the community members involved time to process the incident. The cooldown period may be limited to particular communication channels or interactions with particular community members. + 3) Repair: Examples of repair may include making an apology, using the cooldown period to reflect on actions and impact, and being thoughtful about re-entering community spaces after the period is over. +3) Temporary Suspension + 1) Event: A pattern of repeated violation which the Community Moderators have tried to address with warnings, or a single serious violation. + 2) Consequence: A private written warning with conditions for return from suspension. In general, temporary suspensions give the person being suspended time to reflect upon their behavior and possible corrective actions. + 3) Repair: Examples of repair include respecting the spirit of the suspension, meeting the specified conditions for return, and being thoughtful about how to reintegrate with the community when the suspension is lifted. +4) Permanent Ban + 1) Event: A pattern of repeated code of conduct violations that other steps on the ladder have failed to resolve, or a violation so serious that the Community Moderators determine there is no way to keep the community safe with this person as a member. + 2) Consequence: Access to all community spaces, tools, and communication channels is removed. In general, permanent bans should be rarely used, should have strong reasoning behind them, and should only be resorted to if working through other remedies has failed to change the behavior. + 3) Repair: There is no possible repair in cases of this severity. -**Community Impact**: A serious violation of community standards, including -sustained inappropriate behavior. +This enforcement ladder is intended as a guideline. It does not limit the ability of Community Managers to use their discretion and judgment, in keeping with the best interests of our community. -**Consequence**: A temporary ban from any sort of interaction or public -communication with the community for a specified period of time. No public or -private interaction with the people involved, including unsolicited interaction -with those enforcing the Code of Conduct, is allowed during this period. -Violating these terms may lead to a permanent ban. -### 4. Permanent Ban +## Scope -**Community Impact**: Demonstrating a pattern of violation of community -standards, including sustained inappropriate behavior, harassment of an -individual, or aggression toward or disparagement of classes of individuals. +This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public or other spaces. Examples of representing our community include using an official email address, posting via an official social media account, or acting as an appointed representative at an online or offline event. -**Consequence**: A permanent ban from any sort of public interaction within the -community. ## Attribution -This Code of Conduct is adapted from the [Contributor Covenant][homepage], -version 2.1, available at -[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. - -Community Impact Guidelines were inspired by -[Mozilla's code of conduct enforcement ladder][Mozilla CoC]. +This Code of Conduct is adapted from the Contributor Covenant, version 3.0, permanently available at [https://www.contributor-covenant.org/version/3/0/](https://www.contributor-covenant.org/version/3/0/). -For answers to common questions about this code of conduct, see the FAQ at -[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at -[https://www.contributor-covenant.org/translations][translations]. +Contributor Covenant is stewarded by the Organization for Ethical Source and licensed under CC BY-SA 4.0. To view a copy of this license, visit [https://creativecommons.org/licenses/by-sa/4.0/](https://creativecommons.org/licenses/by-sa/4.0/) -[homepage]: https://www.contributor-covenant.org -[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html -[Mozilla CoC]: https://github.com/mozilla/diversity -[FAQ]: https://www.contributor-covenant.org/faq -[translations]: https://www.contributor-covenant.org/translations +For answers to common questions about Contributor Covenant, see the FAQ at [https://www.contributor-covenant.org/faq](https://www.contributor-covenant.org/faq). Translations are provided at [https://www.contributor-covenant.org/translations](https://www.contributor-covenant.org/translations). Additional enforcement and community guideline resources can be found at [https://www.contributor-covenant.org/resources](https://www.contributor-covenant.org/resources). The enforcement ladder was inspired by the work of [Mozilla’s code of conduct team](https://github.com/mozilla/inclusion). diff --git a/README.rst b/README.rst index acd048d..99d4e99 100644 --- a/README.rst +++ b/README.rst @@ -2,7 +2,9 @@ xncml ===== +----------------------------+-----------------------------------------------------+ -| Documentation and Support | |docs| | +| Versions | |pypi| | ++----------------------------+-----------------------------------------------------+ +| Documentation and Support | |docs| |versions| | +----------------------------+-----------------------------------------------------+ | Open Source | |license| | +----------------------------+-----------------------------------------------------+ @@ -115,3 +117,7 @@ Once you have a copy of the source, you can install it with: .. |status| image:: https://www.repostatus.org/badges/latest/active.svg :target: https://www.repostatus.org/#active :alt: Project Status: Active – The project has reached a stable, usable state and is being actively developed. + +.. |versions| image:: https://img.shields.io/pypi/pyversions/xncml.svg + :target: https://pypi.python.org/pypi/xncml + :alt: Supported Python Versions diff --git a/pyproject.toml b/pyproject.toml index 131bfbc..b963af1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["flit_core >=3.10.1,<4"] +requires = ["flit_core >=3.11.0,<4"] build-backend = "flit_core.buildapi" [project] @@ -17,12 +17,12 @@ description = "Tools for manipulating and opening NCML (NetCDF Markup) files wit readme = {file = "README.rst", content-type = "text/x-rst"} requires-python = ">=3.10.0" keywords = ["xncml", "xarray", "netcdf", "ncml"] -license = {file = "LICENSE"} +license = "Apache-2.0" +license-files = ["LICENSE"] classifiers = [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "Intended Audience :: Science/Research", - "License :: OSI Approved :: Apache Software License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python :: 3", @@ -31,7 +31,8 @@ classifiers = [ "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", "Programming Language :: Python :: Implementation :: CPython", - "Topic :: Scientific/Engineering :: Atmospheric Science" + "Topic :: Scientific/Engineering :: Atmospheric Science", + "Typing :: Typed" ] dynamic = ["version"] dependencies = [ @@ -47,19 +48,21 @@ dependencies = [ [project.optional-dependencies] dev = [ # Dev tools and testing - "bump-my-version >=0.30.1", + "bump-my-version >=1.2.3", "coverage >=7.5.0", - "flake8 >=7.1.1", - "flake8-rst-docstrings >=0.3.0", - "flit >=3.10.1,<4.0", - "mypy >=1.14.1", - "numpydoc >=1.8.0", - "pip >=25.0", + "deptry >=0.23.1", + "flake8 >=7.3.0", + "flake8-rst-docstrings >=0.3.1", + "flit >=3.12.0,<4.0", + "mypy >=1.18.2", + "numpydoc >=1.9.0", + "pip >=25.2", "pre-commit >=3.5.0", "pytest >=8.3.2", "pytest-cov >=5.0.0", - "ruff >=0.9.0", - "tox >=4.24.1", + "ruff >=0.13.3", + "tox >=4.30.3", + "vulture >=2.14", "watchdog >=4.0.0" ] docs = [ @@ -68,7 +71,7 @@ docs = [ "ipython", "jupyter_client", "nbsphinx >=0.9.5", - "sphinx >=7.0.0", + "sphinx >=7.1.0,<8.2", "sphinx-codeautolink >=0.16.2", "sphinx-copybutton", "sphinx-rtd-theme >=1.0" @@ -122,6 +125,13 @@ replace = """\ --------------------------------------------------------------------------- """ +[[tool.bumpversion.files]] +filename = "CITATION.cff" +include_bumps = ["release"] +search = "^version: \"[0-9]+\\.[0-9]+\\.[0-9]\"" +regex = true +replace = "version: \"{new_version}\"" + [[tool.bumpversion.files]] filename = "src/xncml/__init__.py" search = "__version__ = \"{current_version}\"" @@ -154,6 +164,10 @@ omit = ["tests/*.py"] relative_files = true source = ["xncml"] +[tool.deptry] +extend_exclude = ["docs"] +pep621_dev_dependency_groups = ["all", "dev", "docs"] + [tool.flit.sdist] include = [ ".zenodo.json", @@ -195,7 +209,7 @@ exclude = [ [tool.mypy] files = "." -python_version = 3.10 +python_version = "3.10" show_error_codes = true strict = true warn_no_return = true @@ -234,11 +248,14 @@ override_SS05 = [ [tool.pytest.ini_options] addopts = [ - "--verbose", - "--color=yes" + "-ra", + "--color=yes", + "--verbose" ] filterwarnings = ["ignore::UserWarning"] -testpaths = "tests" +testpaths = [ + "tests" +] [tool.ruff] src = ["xncml"] @@ -253,10 +270,15 @@ exclude = [ [tool.ruff.format] # Enable reformatting of code snippets in docstrings. docstring-code-format = true +docstring-code-line-length = "dynamic" +indent-style = "space" +quote-style = "double" +skip-magic-trailing-comma = false line-ending = "auto" [tool.ruff.lint] extend-select = [ + "D213", # multi-line-summary-second-line "RUF022" # unsorted-dunder-all ] ignore = [ @@ -278,12 +300,15 @@ ignore = [ "UP007" # Use `X | Y` for type annotations ] select = [ + "B", # bugbear "BLE", # blind-except "C90", # mccabe-complexity "D", # docstrings "E", # pycodestyle errors + "F", # pyflakes "FLY002", # static-join-to-fstring "G", # logging-format + "I", # imports "N", # naming conventions "PERF", # iterator performance "PTH", # pathlib @@ -297,6 +322,13 @@ select = [ [tool.ruff.lint.flake8-bandit] check-typed-exception = true +[tool.ruff.lint.isort] +known-first-party = ["xncml"] +case-sensitive = true +detect-same-package = false +lines-after-imports = 2 +no-lines-before = ["future", "standard-library"] + [tool.ruff.lint.mccabe] max-complexity = 15 diff --git a/src/xncml/__init__.py b/src/xncml/__init__.py index 854c9c8..f4988f5 100644 --- a/src/xncml/__init__.py +++ b/src/xncml/__init__.py @@ -21,4 +21,5 @@ from .core import Dataset from .parser import open_ncml + __version__ = "0.5.1" diff --git a/src/xncml/core.py b/src/xncml/core.py index 63e7ce6..5146e09 100644 --- a/src/xncml/core.py +++ b/src/xncml/core.py @@ -14,7 +14,8 @@ class Dataset: - """A class for reading and manipulating NcML file. + """ + A class for reading and manipulating NcML file. Note that NcML documents are used for two distinct purposes: - an XML description of NetCDF structure and metadata; @@ -24,7 +25,8 @@ class Dataset: """ def __init__(self, filepath: str = None, location: str = None): - """Create a Dataset. + """ + Create a Dataset. Parameters ---------- @@ -71,7 +73,8 @@ def __repr__(self) -> str: # Aggregations and scans def add_aggregation(self, dim_name: str, type_: str, recheck_every: str = None, time_units_change: bool = None): - """Add aggregation. + """ + Add aggregation. Parameters ---------- @@ -105,7 +108,8 @@ def add_aggregation(self, dim_name: str, type_: str, recheck_every: str = None, self.ncroot["netcdf"]["aggregation"] = aggregations def add_variable_agg(self, dim_name: str, name: str): - """Add variable aggregation. + """ + Add variable aggregation. Parameters ---------- @@ -186,7 +190,8 @@ def add_scan( # Variable def add_variable_attribute(self, variable, key, value, type_="String"): - """Add variable attribute. + """ + Add variable attribute. Parameters ---------- @@ -233,7 +238,8 @@ def remove_variable_attribute(self, variable, key): self.ncroot["netcdf"]["variable"] = variables def rename_variable(self, variable, new_name): - """Rename variable attribute + """ + Rename variable attribute Parameters ---------- @@ -256,7 +262,8 @@ def rename_variable(self, variable, new_name): self.ncroot["netcdf"]["variable"] = variables def remove_variable(self, variable): - """Remove dataset variable. + """ + Remove dataset variable. Parameters ---------- @@ -271,7 +278,8 @@ def remove_variable(self, variable): self.ncroot["netcdf"]["remove"] = removes def rename_variable_attribute(self, variable, old_name, new_name): - """Rename variable attribute. + """ + Rename variable attribute. Parameters ---------- @@ -304,7 +312,8 @@ def rename_variable_attribute(self, variable, old_name, new_name): # Dimensions def rename_dimension(self, dimension, new_name): - """Rename dimension. + """ + Rename dimension. Parameters ---------- @@ -328,7 +337,8 @@ def rename_dimension(self, dimension, new_name): # Dataset def add_dataset_attribute(self, key, value, type_="String"): - """Add dataset attribute + """ + Add dataset attribute Parameters ---------- @@ -352,7 +362,8 @@ def add_dataset_attribute(self, key, value, type_="String"): self.ncroot["netcdf"]["attribute"] = attributes def remove_dataset_attribute(self, key): - """Remove dataset attribute. + """ + Remove dataset attribute. Parameters ---------- @@ -371,7 +382,8 @@ def remove_dataset_attribute(self, key): self.ncroot["netcdf"]["remove"] = [item] def rename_dataset_attribute(self, old_name, new_name): - """Rename dataset attribute. + """ + Rename dataset attribute. Parameters ---------- @@ -399,7 +411,8 @@ def rename_dataset_attribute(self, old_name, new_name): self.ncroot["netcdf"]["attribute"] = item def to_ncml(self, path=None): - """Write NcML file to disk. + """ + Write NcML file to disk. Parameters ---------- @@ -417,7 +430,8 @@ def to_ncml(self, path=None): fd.write(xml_output) def to_cf_dict(self): - """Convert internal representation to a CF-JSON dictionary. + """ + Convert internal representation to a CF-JSON dictionary. The CF-JSON specification includes `data` for variables, but if the data is not within the NcML, it cannot be included in the JSON representation. @@ -480,13 +494,14 @@ def _attributes_to_json(attrs: list) -> dict: try: out[attr["@name"]] = _cast(attr) except ValueError as exc: - warn(f"Could not cast {attr['@name']}:\n{exc}") + warn(f"Could not cast {attr['@name']}:\n{exc}", stacklevel=2) return {"attributes": out} def _variables_to_json(variables: list) -> dict: - """The variables definition object has variable id:object as its key:value members. + """ + The variables definition object has variable id:object as its key:value members. Each variable object MUST include shape, attributes and data objects. The shape field is an array of dimension IDs which correspond to the array ordering of the variable data. diff --git a/src/xncml/generated/__init__.py b/src/xncml/generated/__init__.py index ce1d11f..4e75924 100644 --- a/src/xncml/generated/__init__.py +++ b/src/xncml/generated/__init__.py @@ -18,6 +18,7 @@ Variable, ) + __all__ = [ "Aggregation", "AggregationType", diff --git a/src/xncml/generated/_ncml_2_2.py b/src/xncml/generated/_ncml_2_2.py index 2c89b3f..34e3c33 100644 --- a/src/xncml/generated/_ncml_2_2.py +++ b/src/xncml/generated/_ncml_2_2.py @@ -1,9 +1,9 @@ from __future__ import annotations - from dataclasses import dataclass, field from enum import Enum from typing import Type + __NAMESPACE__ = "http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2" diff --git a/src/xncml/parser.py b/src/xncml/parser.py index f1c8cf2..85bab64 100644 --- a/src/xncml/parser.py +++ b/src/xncml/parser.py @@ -31,7 +31,6 @@ """ from __future__ import annotations - import datetime as dt from functools import partial from pathlib import Path @@ -57,6 +56,7 @@ Variable, ) + if TYPE_CHECKING: from collections.abc import Iterator @@ -180,7 +180,8 @@ def read_aggregation(target: xr.Dataset, obj: Aggregation, ncml: Path) -> xr.Dat names = [v.name for v in filter_by_class(obj.choice, Aggregation.VariableAgg)] for attr in obj.promote_global_attribute: - raise NotImplementedError + msg = f"{attr} in not implemented yet." + raise NotImplementedError(msg) # Create list of datasets to aggregate. datasets = [] @@ -189,7 +190,7 @@ def read_aggregation(target: xr.Dataset, obj: Aggregation, ncml: Path) -> xr.Dat for item in obj.netcdf: # Open dataset defined in 's `location` attribute tar = read_netcdf(xr.Dataset(), ref=xr.Dataset(), obj=item, ncml=ncml, group=ROOT_GROUP) - closers.append(getattr(tar, "_close")) + closers.append(tar._close) # Select variables if names: @@ -206,7 +207,7 @@ def read_aggregation(target: xr.Dataset, obj: Aggregation, ncml: Path) -> xr.Dat for item in obj.scan: dss = read_scan(item, ncml) datasets.extend([ds.chunk() for ds in dss]) - closers.extend([getattr(ds, "_close") for ds in dss]) + closers.extend([ds._close for ds in dss]) # Need to decode time variable if obj.time_units_change: @@ -584,7 +585,8 @@ def read_variable( def read_values(var_name: str, expected_size: int, values_tag: Values) -> list: - """Read values for element. + """ + Read values for element. Parameters ---------- @@ -624,7 +626,8 @@ def read_values(var_name: str, expected_size: int, values_tag: Values) -> list: def build_scalar_variable(var_name: str, values_tag: Values, var_type: str) -> xr.Variable: - """Build an xr.Variable for scalar variables. + """ + Build an xr.Variable for scalar variables. Parameters ---------- @@ -650,7 +653,8 @@ def build_scalar_variable(var_name: str, values_tag: Values, var_type: str) -> x warn( f"The scalar variable {var_name} has no values set within" f" . A default value of {default_value} is set" - " to preserve the type." + " to preserve the type.", + stacklevel=2, ) return xr.Variable(data=default_value, dims=()) values_content = read_values(var_name, expected_size=1, values_tag=values_tag) @@ -662,7 +666,8 @@ def build_scalar_variable(var_name: str, values_tag: Values, var_type: str) -> x def read_remove(target: xr.Dataset | xr.Variable, obj: Remove) -> xr.Dataset: - """Remove item from dataset. + """ + Remove item from dataset. Parameters ---------- @@ -687,7 +692,8 @@ def read_remove(target: xr.Dataset | xr.Variable, obj: Remove) -> xr.Dataset: def read_attribute(target: xr.Dataset | xr.Variable, obj: Attribute, ref: xr.Dataset = None): - """Update target dataset in place with new or modified attribute. + """ + Update target dataset in place with new or modified attribute. Parameters ---------- diff --git a/tests/test_core.py b/tests/test_core.py index 846ebdb..d8b7fa5 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -7,6 +7,7 @@ import xncml + here = os.path.abspath(os.path.dirname(__file__)) input_file = Path(here) / "data" / "exercise1.ncml" diff --git a/tests/test_parser.py b/tests/test_parser.py index e9d8a16..0528656 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -7,6 +7,7 @@ import xncml + # Notes # This is not testing absolute paths. @@ -17,7 +18,8 @@ class CheckClose: - """Check that files are closed after the test. + """ + Check that files are closed after the test. Note that `close` has to be explicitly called within the context manager for this to work. """ diff --git a/tox.ini b/tox.ini index 7a88382..9b81f9c 100644 --- a/tox.ini +++ b/tox.ini @@ -2,17 +2,16 @@ min_version = 4.23.2 envlist = lint - py{3.9,3.10,3.11,3.12,3.13} + py{3.10,3.11,3.12,3.13} docs requires = - flit >= 3.10.1,<4.0.0 - pip >= 25.1 + flit >= 3.11.0,<4.0 + pip >= 25.2 opts = --verbose [gh] python = - 3.9 = py39-coverage 3.10 = py310-coverage 3.11 = py311-coverage 3.12 = py312-coverage @@ -21,10 +20,10 @@ python = [testenv:lint] skip_install = True deps = - flake8 >=7.1.1 - flake8-rst-docstrings >=0.3.0 - ruff >=0.9.0 - numpydoc >=1.8.0 + flake8 >=7.3.0 + flake8-rst-docstrings >=0.3.1 + ruff >=0.13.3 + numpydoc >=1.9.0 commands = make lint allowlist_externals =