Skip to content

Commit

Permalink
Merge pull request #123 from palewire/ruff
Browse files Browse the repository at this point in the history
Switch to Ruff formatting and linting
  • Loading branch information
palewire authored Sep 1, 2024
2 parents f27c6f6 + 89be0ba commit b3bba46
Show file tree
Hide file tree
Showing 16 changed files with 166 additions and 261 deletions.
23 changes: 5 additions & 18 deletions .github/workflows/continuous-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,13 @@ jobs:
name: Lint Python code
runs-on: ubuntu-latest
steps:
- name: Checkout
- id: checkout
name: Checkout
uses: actions/checkout@v4

- id: install-python
name: Install Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pipenv'

- name: Install pipenv
run: curl https://raw.githubusercontent.com/pypa/pipenv/master/get-pipenv.py | python

- id: install-python-dependencies
name: Install Python dependencies
run: pipenv install --dev --python `which python`

- id: lint
name: Lint Python code
run: pipenv run flake8 ./ --verbose
- id: ruff
name: Ruff
uses: chartboost/ruff-action@v1

test-python:
strategy:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ build
*.*#
.ipynb_checkpoints
todo
.ruff-cache
23 changes: 6 additions & 17 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,20 @@ repos:
- id: check-ast
- id: check-merge-conflict

- repo: https://github.com/psf/black
rev: 23.3.0
- repo: 'https://github.com/astral-sh/ruff-pre-commit'
rev: v0.6.3
hooks:
- id: black
- id: ruff
args:
- '--fix'
- id: ruff-format

- repo: https://github.com/asottile/blacken-docs
rev: 1.16.0
hooks:
- id: blacken-docs
additional_dependencies: [black]

- repo: https://github.com/timothycrosley/isort
rev: 5.12.0
hooks:
- id: isort
args: ["--profile", "black", "--filter-files"]

- repo: https://github.com/pycqa/flake8
rev: 6.1.0
hooks:
- id: flake8
additional_dependencies:
- flake8-bugbear
# - flake8-docstrings

- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
hooks:
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
### Links

* Docs: [palewi.re/docs/cpi/](https://palewi.re/docs/cpi/)
* Code: [github.com/datadesk/cpi](https://github.com/datadesk/cpi/)
* Issues: [github.com/datadesk/cpi/issues](https://github.com/datadesk/cpi/issues)
* Code: [github.com/palewire/cpi](https://github.com/palewire/cpi/)
* Issues: [github.com/palewire/cpi/issues](https://github.com/palewire/cpi/issues)
* Packaging: [pypi.python.org/pypi/cpi](https://pypi.python.org/pypi/cpi)
* Testing: [github.com/datadesk/cpi/actions](https://github.com/datadesk/cpi/actions)
* Testing: [github.com/palewire/cpi/actions](https://github.com/palewire/cpi/actions)
1 change: 1 addition & 0 deletions cpi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
Quickly adjust U.S. dollars for inflation using the Consumer Price Index (CPI)
"""

import logging
import numbers
import warnings
Expand Down
1 change: 1 addition & 0 deletions cpi/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
Command-line interface.
"""

import click
from dateutil.parser import parse as dateparse

Expand Down
1 change: 1 addition & 0 deletions cpi/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
Default values.
"""

DEFAULT_SERIES_ID = "CUUR0000SA0"
DEFAULTS_SERIES_ATTRS = {
"survey": "All urban consumers",
Expand Down
1 change: 1 addition & 0 deletions cpi/download.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Download the latest annual Consumer Price Index (CPI) dataset."""

import io
import logging
import sqlite3
Expand Down
1 change: 1 addition & 0 deletions cpi/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Python objects for modeling Consumer Price Index (CPI) data structures."""

from __future__ import annotations

import logging
Expand Down
1 change: 1 addition & 0 deletions cpi/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
Parse and prepare the Consumer Price Index (CPI) dataset.
"""

import logging
import os
import sqlite3
Expand Down
6 changes: 4 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""Configure Sphinx configuration."""

import os
import sys
from typing import Any
from datetime import datetime

# Insert the parent directory into the path
Expand All @@ -21,8 +23,8 @@
exclude_patterns = ["_build"]

html_theme = "palewire"
html_sidebars = {}
html_theme_options = {
html_sidebars: dict[Any, Any] = {}
html_theme_options: dict[str, Any] = {
"canonical_url": f"https://palewi.re/docs/{project}/",
"nosidebar": True,
}
16 changes: 11 additions & 5 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,19 @@ cpi.inflate(100, date(1950, 1, 1), to=date(2018, 1, 1))

You can adjust values using any of the other series published by the BLS as part of its "All Urban Consumers (CU)" survey. They offer more precise measures for different regions and items.

Submit one of the 60 areas tracked by the agency to inflate dollars in that region. You can find a complete list in [the repository](https://github.com/palewire/cpi/blob/main/data/areas.csv).
Submit one of the 60 areas tracked by the agency to inflate dollars in that region.

```python
cpi.inflate(100, 1950, area="Los Angeles-Long Beach-Anaheim, CA")
1081.054852320675
```

You can find a complete list in [the repository](https://github.com/palewire/cpi/blob/main/data/areas.csv) or by running the following command:

```python
cpi.areas.all()
```

You can do the same to inflate the price of 400 specific items lumped into the basket of goods that make up the overall index. You can find a complete list in [the repository](https://github.com/palewire/cpi/blob/main/data/items.csv).

```python
Expand Down Expand Up @@ -177,7 +183,7 @@ Options:

The lists of CPI series and each's index values can be converted to a DataFrame using the `to_dataframe` method.

Here's how to get the series list:
Here's how to get the list of series you've loaded thus far:

```python
series_df = cpi.series.to_dataframe()
Expand Down Expand Up @@ -206,7 +212,7 @@ cpi.update()

## Other resources

* Code: [github.com/datadesk/cpi](https://github.com/datadesk/cpi/)
* Issues: [github.com/datadesk/cpi/issues](https://github.com/datadesk/cpi/issues)
* Code: [github.com/palewire/cpi](https://github.com/palewire/cpi/)
* Issues: [github.com/palewire/cpi/issues](https://github.com/palewire/cpi/issues)
* Packaging: [pypi.python.org/pypi/cpi](https://pypi.python.org/pypi/cpi)
* Testing: [github.com/datadesk/cpi/actions](https://github.com/datadesk/cpi/actions)
* Testing: [github.com/palewire/cpi/actions](https://github.com/palewire/cpi/actions)
Loading

0 comments on commit b3bba46

Please sign in to comment.