Skip to content

Commit

Permalink
Merge pull request #16 from robcalon/feature/pre-commit
Browse files Browse the repository at this point in the history
Feature/pre commit
  • Loading branch information
robcalon authored Oct 13, 2023
2 parents 9c226f5 + 3ace879 commit 579bfa1
Show file tree
Hide file tree
Showing 53 changed files with 3,002 additions and 5,173 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ dnu/
dist/
*.egg-info
*.log
.env
*.env
*.ruff_cache
84 changes: 84 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# The repos are ordered in the way they are executed.
# This is important because `autoflake` should run before `flake8`, for example

default_stages: [commit, push]
fail_fast: true
minimum_pre_commit_version: 2.15.0
repos:

- repo: local
hooks:

# checks for files that would conflict in case-insensitive filesystems.
- id: check-case-conflict
name: check-case-conflict
entry: check-case-conflict
language: python
types: [ python ]

# checks for files that contain merge conflict strings.
- id: check-merge-conflict
name: check-merge-conflict
entry: check-merge-conflict
language: python
types: [ python ]

# ensures that a file is either empty, or ends with one newline.
- id: end-of-file-fixer
name: end-of-file-fixer
entry: end-of-file-fixer
language: python
types: [ python ]

# removes utf-8 byte order marker.
- id: fix-byte-order-marker
name: fix-byte-order-marker
entry: fix-byte-order-marker
language: python
types: [ python ]

# replaces or checks mixed line ending.
- id: mixed-line-ending
name: mixed-line-ending
entry: mixed-line-ending
language: python
types: [ python ]

# trims trailing whitespace.
- id: trailing-whitespace-fixer
name: trailing-whitespace-fixer
entry: trailing-whitespace-fixer
language: python
types: [ python ]

#
- id: black
name: black
entry: black
files: "^(src|tests)"
language: python
types: [ python ]

- id: ruff
name: ruff
entry: ruff
files: "^(src|tests)"
language: python
types: [ python ]
args: [--fix, --exit-non-zero-on-fix]

#
# - id: pylint
# name: pylint
# entry: pylint
# files: "^(src|tests)"
# language: python
# types: [ python ]

#
- id: mypy
name: mypy
entry: mypy
files: "^(src/pyetm/sessions|src/pyetm/client|src/pyetm/profiles)"
language: python
types: [ python ]
21 changes: 6 additions & 15 deletions examples/introduction.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"from pyetm import Client\n",
"\n",
"# create a new scenario from scratch\n",
"client = Client.from_scenario_parameters(end_year=2050, area_code=\"nl\")\n",
"client = Client.from_scenario_parameters(end_year=2050, area_code=\"nl2019\")\n",
"\n",
"# print scenario_id\n",
"scenario_id = client.scenario_id\n",
Expand Down Expand Up @@ -69,7 +69,7 @@
"outputs": [],
"source": [
"# frst check which parameters can be set in the scenario\n",
"parameters = client.user_parameters\n",
"parameters = client.input_parameters\n",
"parameters.iloc[41:46]"
]
},
Expand All @@ -80,7 +80,7 @@
"outputs": [],
"source": [
"# show parameters that are set by the user\n",
"client.user_values"
"client.get_input_parameters(user_only=True)"
]
},
{
Expand All @@ -98,8 +98,8 @@
"}\n",
"\n",
"# apply the changes to the scenario\n",
"client.user_values = user_values\n",
"client.user_values"
"client.input_parameters = user_values\n",
"client.get_input_parameters(user_only=True)"
]
},
{
Expand Down Expand Up @@ -138,15 +138,6 @@
"outputs": [],
"source": [
"# show if there are custom curves attached in the scenario\n",
"client.get_custom_curve_keys()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"client.get_custom_curve_settings()"
]
},
Expand Down Expand Up @@ -189,7 +180,7 @@
"outputs": [],
"source": [
"# set data as ccurves profiles\n",
"client.custom_curves = ccurves\n",
"# client.set_custom_curves(ccurves\n",
"client.custom_curves.head()"
]
},
Expand Down
39 changes: 31 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ build-backend = "setuptools.build_meta"

[project]
name = "pyetm"
version = "1.2.2"
version = "1.3.0"

description = "Python-ETM Connector"
authors = [{name = "Rob Calon", email = "[email protected]"}]
readme = "README.md"
requires-python = ">=3.9"
license = {file = "LICENSE"}
dependencies = ['requests>=2.26', 'pandas>=2.0']
dependencies = [
'requests>=2.26',
'pandas>=2.0',
]
keywords = ["ETM", "Energy Transition Model"]
classifiers = [
'Development Status :: 4 - Beta',
Expand All @@ -28,14 +32,33 @@ classifiers = [
'Programming Language :: Python :: 3.11',
]

[project.optional-dependencies]
async = ["aiohttp>=3.8"]
io = ["xlsxwriter>=3.0", "openpyxl>=3.0"]
test = ["pytest", "responses", "aioresponses", "build", "twine"]
all = ["pyetm[async]", "pyetm[io]", "pyetm[test]"]

[project.urls]
repository = "https://github.com/robcalon/pyetm"

# [tool.distutils.bdist_wheel]
# universal = true

[project.optional-dependencies]
async = ["aiohttp>=3.8"]
excel = ["xlsxwriter>=3.0", "openpyxl>=3.0"]
dev = [
"black",
"mypy>=1.4.1",
"pre-commit",
"pre-commit-hooks",
"pyetm[async, excel]",
# "pylint",
"ruff",
"pandas-stubs",
]

[tool.setuptools.package-data]
"pyetm.data" = ["*.csv"]

[tool.pylint]
max-args = 15
max-local = 20

[tool.mypy]
disallow_untypes_defs = true
# disallow_incomplete_defs = true
2 changes: 2 additions & 0 deletions src/pyetm/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
"""init main module"""
from .client import Client

__all__ = ["Client"]
2 changes: 2 additions & 0 deletions src/pyetm/client/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
"""init client module"""
from .client import Client

__all__ = ["Client"]
Loading

0 comments on commit 579bfa1

Please sign in to comment.