Skip to content

Commit

Permalink
Add Ruff (#380)
Browse files Browse the repository at this point in the history
* Replace black with Ruff

* Fix duplicate test name
  • Loading branch information
dc-almeida authored Sep 11, 2024
1 parent 65f005c commit 6a6e7de
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 105 deletions.
10 changes: 0 additions & 10 deletions .github/workflows/black.yml

This file was deleted.

8 changes: 8 additions & 0 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: Ruff
on: [ push, pull_request ]
jobs:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: chartboost/ruff-action@v1
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ the [LICENSE](LICENSE) for details.
[![license](https://img.shields.io/badge/License-Apache%202.0-black)](https://github.com/IAMconsortium/nomenclature/blob/main/LICENSE)
[![DOI](https://zenodo.org/badge/375724610.svg)](https://zenodo.org/badge/latestdoi/375724610)
[![python](https://img.shields.io/badge/python-≥3.10,<3.13-blue?logo=python&logoColor=white)](https://github.com/IAMconsortium/nomenclature)
[![Code style:
black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Code style: ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![pytest](https://img.shields.io/github/actions/workflow/status/iamconsortium/nomenclature/pytest.yml?logo=GitHub&label=pytest)](https://github.com/IAMconsortium/nomenclature/actions/workflows/pytest.yml)
[![ReadTheDocs](https://readthedocs.org/projects/nomenclature-iamc/badge)](https://nomenclature-iamc.readthedocs.io)

Expand Down
6 changes: 3 additions & 3 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

Release v\ |version|.

|license| |doi| |python| |black| |pytest| |rtd|
|license| |doi| |python| |ruff| |pytest| |rtd|

.. |license| image:: https://img.shields.io/badge/License-Apache%202.0-black
:target: https://github.com/IAMconsortium/nomenclature/blob/main/LICENSE
Expand All @@ -16,8 +16,8 @@ Release v\ |version|.
.. |python| image:: https://img.shields.io/badge/python-≥3.10,<3.13-blue?logo=python&logoColor=white
:target: https://github.com/IAMconsortium/nomenclature

.. |black| image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/psf/black
.. |ruff| image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json
:target: https://github.com/astral-sh/ruff

.. |pytest| image:: https://img.shields.io/github/actions/workflow/status/iamconsortium/nomenclature/pytest.yml
:target: https://github.com/IAMconsortium/nomenclature/actions/workflows/pytest.yml
Expand Down
102 changes: 28 additions & 74 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ gitpython = "^3.1.40"
numpy = "^1.23.0"

[tool.poetry.group.dev.dependencies]
black = "^23.12.0"
ruff = "^0.6.2"
mypy = "^1.7.1"
flake8 = "^6.1.0"
pytest = "^7.4.3"
Expand Down
16 changes: 1 addition & 15 deletions tests/test_codelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def test_simple_codelist():

assert "Some Variable" in codelist
assert codelist["Some Variable"].unit == "" # this is a dimensionless variable
assert type(codelist["Some Variable"].bool) == bool # this is a boolean
assert type(codelist["Some Variable"].bool) is bool # this is a boolean


def test_codelist_adding_duplicate_raises():
Expand Down Expand Up @@ -396,20 +396,6 @@ def test_multiple_external_repos():
for repo in nomenclature_config.repositories.values()
)
assert len(variable_code_list) > 2000
finally:
clean_up_external_repos(nomenclature_config.repositories)


def test_multiple_external_repos():
nomenclature_config = NomenclatureConfig.from_file(
TEST_DATA_DIR / "nomenclature_configs" / "multiple_repos_per_dimension.yaml"
)
try:
variable_code_list = VariableCodeList.from_directory(
"variable",
TEST_DATA_DIR / "nomenclature_configs" / "variable",
nomenclature_config,
)
assert variable_code_list["Final Energy"].repository == "common-definitions"
assert variable_code_list["Employment"].repository == "legacy-definitions"
finally:
Expand Down

0 comments on commit 6a6e7de

Please sign in to comment.