From 21a773ec5fa1ca83ed51fb7bb19c7d975bfd8548 Mon Sep 17 00:00:00 2001 From: Kira <117554978+kiraware@users.noreply.github.com> Date: Sun, 15 Sep 2024 16:17:37 +0800 Subject: [PATCH 1/4] Change release environment and remove prettier * update contributing guide to add description for version number when release * change `production` environment to `release` environment in github release workflow * remove prettier from pre-commit --- .github/workflows/release.yml | 2 +- .pre-commit-config.yaml | 8 -------- docs/how-to-guides.md | 5 +++-- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 63521dc..45c40a5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,7 +11,7 @@ jobs: contents: read id-token: write runs-on: ubuntu-latest - environment: production + environment: release steps: - name: Checkout source code uses: actions/checkout@v4 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b73e109..09af989 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -49,14 +49,6 @@ repos: types: [python] pass_filenames: false - # prettier - formatting Markdown - - repo: https://github.com/pre-commit/mirrors-prettier - rev: v4.0.0-alpha.8 - hooks: - - id: prettier - types: [text, markdown] - exclude: ^poetry.lock - # mkdocs - build the documentation - repo: local hooks: diff --git a/docs/how-to-guides.md b/docs/how-to-guides.md index 9734e98..6e3045b 100644 --- a/docs/how-to-guides.md +++ b/docs/how-to-guides.md @@ -132,6 +132,7 @@ poetry run mkdocs serve We use the GitHub workflow to automatically release to PyPI when we release to GitHub. The special environment for people who have access -to the workflow is in the GitHub environment with the name `production`. +to the workflow is in the GitHub environment with the name `release`. Each release tag must be the same as `version` in `pyproject.toml` in -the `tool.poetry` section. +the `tool.poetry` section with prefix `v`, for example `v1.0.0`. Also +we follow Semantic Versioning with version number MAJOR.MINOR.PATCH. From f72fac771363f5c835bd4802d8bbead1df44c9d2 Mon Sep 17 00:00:00 2001 From: Kira <117554978+kiraware@users.noreply.github.com> Date: Wed, 18 Sep 2024 13:48:08 +0800 Subject: [PATCH 2/4] add lint rule --- .pre-commit-config.yaml | 9 +++++++++ pyproject.toml | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fbb5fc3..3874426 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,6 +9,7 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.6.0 hooks: + - id: check-toml - id: check-yaml args: [--allow-multiple-documents] - id: end-of-file-fixer @@ -49,6 +50,14 @@ repos: types: [python] pass_filenames: false + # prettier - formatting Markdown + - repo: https://github.com/pre-commit/mirrors-prettier + rev: v4.0.0-alpha.8 + hooks: + - id: prettier + types: [text, markdown] + exclude: ^poetry.lock + # mkdocs - build the documentation - repo: local hooks: diff --git a/pyproject.toml b/pyproject.toml index e0b0cb0..9ff2361 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -85,8 +85,8 @@ target-version = "py311" src = ["src", "tests"] [tool.ruff.lint] -select = ["E", "F", "W", "I"] -ignore = [] +select = ["F", "E", "W", "C90", "I", "B"] +ignore = ["E501", "C901"] [tool.ruff.format] docstring-code-format = true From cd972ade1dd8b349ce16d1b0cad2adc4863c1032 Mon Sep 17 00:00:00 2001 From: Kira <117554978+kiraware@users.noreply.github.com> Date: Wed, 18 Sep 2024 15:17:10 +0800 Subject: [PATCH 3/4] update docs and code to match new rule --- src/bmkg/parsers/parse_weather_forecast_data.py | 1 + tests/test_parsers/test_parse_datetime_element.py | 2 +- tests/test_parsers/test_parse_humidity_element.py | 4 ++-- tests/test_parsers/test_parse_temperature_element.py | 4 ++-- tests/test_parsers/test_parse_weather_element.py | 4 ++-- tests/test_parsers/test_parse_wind_direction_element.py | 4 ++-- tests/test_parsers/test_parse_wind_speed_element.py | 4 ++-- 7 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/bmkg/parsers/parse_weather_forecast_data.py b/src/bmkg/parsers/parse_weather_forecast_data.py index 21cb440..d04e61d 100644 --- a/src/bmkg/parsers/parse_weather_forecast_data.py +++ b/src/bmkg/parsers/parse_weather_forecast_data.py @@ -121,6 +121,7 @@ def parse_weather_forecast_data(weather_forecast_data: str | bytes) -> WeatherFo ), parameters["wd"], parameters["ws"], + strict=False, ) ) diff --git a/tests/test_parsers/test_parse_datetime_element.py b/tests/test_parsers/test_parse_datetime_element.py index fb27c15..1ca5911 100644 --- a/tests/test_parsers/test_parse_datetime_element.py +++ b/tests/test_parsers/test_parse_datetime_element.py @@ -15,5 +15,5 @@ def test_parse_element_with_invalid_attribute(): with pytest.raises( WeatherForecastParseError, match="datetime attribute in timerange tag not found" ): - for dt in parse_datetime_element(element): + for _dt in parse_datetime_element(element): pass diff --git a/tests/test_parsers/test_parse_humidity_element.py b/tests/test_parsers/test_parse_humidity_element.py index b02fa2b..91108d4 100644 --- a/tests/test_parsers/test_parse_humidity_element.py +++ b/tests/test_parsers/test_parse_humidity_element.py @@ -15,7 +15,7 @@ def test_parse_element_with_invalid_attribute(): with pytest.raises( WeatherForecastParseError, match="value tag in timerange tag not found" ): - for humidity in parse_humidity_element(element): + for _humidity in parse_humidity_element(element): pass @@ -31,5 +31,5 @@ def test_parse_element_with_invalid_humidity_text(): with pytest.raises( WeatherForecastParseError, match="value tag in timerange tag has no text" ): - for humidity in parse_humidity_element(element): + for _humidity in parse_humidity_element(element): pass diff --git a/tests/test_parsers/test_parse_temperature_element.py b/tests/test_parsers/test_parse_temperature_element.py index fd770aa..b0efc99 100644 --- a/tests/test_parsers/test_parse_temperature_element.py +++ b/tests/test_parsers/test_parse_temperature_element.py @@ -19,7 +19,7 @@ def test_parse_element_with_invalid_attribute(): WeatherForecastParseError, match="one or more value tag in timerange tag not found", ): - for temperature in parse_temperature_element(element): + for _temperature in parse_temperature_element(element): pass @@ -49,5 +49,5 @@ def test_parse_element_with_invalid_value_elements_text(index, err_msg): WeatherForecastParseError, match=err_msg, ): - for temperature in parse_temperature_element(element): + for _temperature in parse_temperature_element(element): pass diff --git a/tests/test_parsers/test_parse_weather_element.py b/tests/test_parsers/test_parse_weather_element.py index 9dacd43..4bef1fb 100644 --- a/tests/test_parsers/test_parse_weather_element.py +++ b/tests/test_parsers/test_parse_weather_element.py @@ -15,7 +15,7 @@ def test_parse_element_with_invalid_attribute(): with pytest.raises( WeatherForecastParseError, match="value tag in timerange tag not found" ): - for weather in parse_weather_element(element): + for _weather in parse_weather_element(element): pass @@ -31,5 +31,5 @@ def test_parse_element_with_invalid_weather_text(): with pytest.raises( WeatherForecastParseError, match="value tag in timerange tag has no text" ): - for weather in parse_weather_element(element): + for _weather in parse_weather_element(element): pass diff --git a/tests/test_parsers/test_parse_wind_direction_element.py b/tests/test_parsers/test_parse_wind_direction_element.py index b451630..80dca62 100644 --- a/tests/test_parsers/test_parse_wind_direction_element.py +++ b/tests/test_parsers/test_parse_wind_direction_element.py @@ -19,7 +19,7 @@ def test_parse_element_with_invalid_attribute(): WeatherForecastParseError, match="one or more value tag in timerange tag not found", ): - for wind_direction in parse_wind_direction_element(element): + for _wind_direction in parse_wind_direction_element(element): pass @@ -50,5 +50,5 @@ def test_parse_element_with_invalid_value_elements_text(index, err_msg): WeatherForecastParseError, match=err_msg, ): - for wind_direction in parse_wind_direction_element(element): + for _wind_direction in parse_wind_direction_element(element): pass diff --git a/tests/test_parsers/test_parse_wind_speed_element.py b/tests/test_parsers/test_parse_wind_speed_element.py index 8c5ff3d..cff6580 100644 --- a/tests/test_parsers/test_parse_wind_speed_element.py +++ b/tests/test_parsers/test_parse_wind_speed_element.py @@ -19,7 +19,7 @@ def test_parse_element_with_invalid_attribute(): WeatherForecastParseError, match="one or more value tag in timerange tag not found", ): - for wind_speed in parse_wind_speed_element(element): + for _wind_speed in parse_wind_speed_element(element): pass @@ -51,5 +51,5 @@ def test_parse_element_with_invalid_value_elements_text(index, err_msg): WeatherForecastParseError, match=err_msg, ): - for wind_speed in parse_wind_speed_element(element): + for _wind_speed in parse_wind_speed_element(element): pass From b523fc64b7a0f0780aff8e1d6ba5a70173b8e565 Mon Sep 17 00:00:00 2001 From: Kira <117554978+kiraware@users.noreply.github.com> Date: Wed, 18 Sep 2024 15:23:14 +0800 Subject: [PATCH 4/4] update docs --- docs/how-to-guides.md | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/docs/how-to-guides.md b/docs/how-to-guides.md index 243c5d4..cd917ab 100644 --- a/docs/how-to-guides.md +++ b/docs/how-to-guides.md @@ -149,26 +149,6 @@ We really pay attention to testing coverage, therefore to contribute we are expected to make tests and if possible increase the code coverage. -To carry out testing, you need to prepare environment variables. -For example, environment variables are found in the `.env.example` -file. You can change the value according to what you have and save -it in the root of the project directory with the file name `.env`. - -To set up environment variables we need `PASTEBIN_API_DEV_KEY`, -`PASTEBIN_USERNAME`, and `PASTEBIN_PASSWORD`. `PASTEBIN_API_DEV_KEY` -belongs to `PASTEBIN_USERNAME`. Then we also need `PASTEBIN_API_USER_KEY`, -to get it we can make a login() API call. Please remember that -`PASTEBIN_API_USER_KEY` MUST NOT belong to `PASTEBIN_USERNAME`, -so simply we have to have two pastebin accounts. - -We have a doctest in src that we don't run it by default because -it's for testing code examples in the docstring. The code example -uses real API calls without mocks, it can cause the test to reach -the API call rate limit. To run doctest, just open the `pyproject.toml` -file and look at the `tool.pytest.ini_options` section in the -`testpaths` configuration there is only a `tests` folder, you can -add the `src` folder and run the test normally to run doctest in src. - ### Documenting We use [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/)