Skip to content

Commit

Permalink
spelling mistakes and better .pre-commit hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
tschm committed Jan 1, 2025
1 parent 61b026c commit 6ed99db
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 28 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ jobs:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.12"]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
Expand Down
32 changes: 24 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,45 @@ repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-yaml
- id: check-toml
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: black
#- repo: https://github.com/psf/black
# rev: 24.10.0
# hooks:
# - id: black

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.8.1'
rev: 'v0.8.4'
hooks:
- id: ruff
args: [ --fix, --exit-non-zero-on-fix ]

# this will result in massive changes, let's delay
## Run the formatter
#- id: ruff-format


- repo: https://github.com/asottile/pyupgrade
rev: v3.19.0
rev: v3.19.1
hooks:
- id: pyupgrade

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.30.0
hooks:
- id: check-dependabot
args: ["--verbose"]
- id: check-github-workflows
args: ["--verbose"]

- repo: https://github.com/rhysd/actionlint
rev: v1.7.5
hooks:
- id: actionlint
args: [-ignore, SC]

- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.23
hooks:
- id: validate-pyproject
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ install: ## Install a virtual environment with all extras
@curl -LsSf https://astral.sh/uv/install.sh | sh
@uv venv
@uv sync -vv --all-extras
@echo "Virtual environment created with all extras. Activate with:"
@echo "source .venv/bin/activate"


.PHONY: fmt
fmt: ## Run autoformatting and linting
fmt: install ## Run autoformatting and linting
@uv pip install pre-commit
@uv run pre-commit install
@uv run pre-commit run --all-files
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ while to set up, but it lets you try out the cookbook recipes without having to

_Note: macOS users will need to install [Command Line Tools](https://osxdaily.com/2014/02/12/install-command-line-tools-mac-os-x/)._

_Note: if you are on windows, you first need to installl C++. ([download](https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=BuildTools&rel=16), [install instructions](https://drive.google.com/file/d/0B4GsMXCRaSSIOWpYQkstajlYZ0tPVkNQSElmTWh1dXFaYkJr/view))_
_Note: if you are on windows, you first need to install C++. ([download](https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=BuildTools&rel=16), [install instructions](https://drive.google.com/file/d/0B4GsMXCRaSSIOWpYQkstajlYZ0tPVkNQSElmTWh1dXFaYkJr/view))_

This project is available on PyPI, meaning that you can just:

Expand Down Expand Up @@ -211,7 +211,7 @@ Discrete allocation: {'GOOG': 1, 'AAPL': 4, 'FB': 12, 'BABA': 4, 'BBY': 2,
Funds remaining: $11.89
```

_Disclaimer: nothing about this project constitues investment advice, and the author bears no responsibiltiy for your subsequent investment decisions. Please refer to the [license](https://github.com/robertmartin8/PyPortfolioOpt/blob/master/LICENSE.txt) for more information._
_Disclaimer: nothing about this project constitutes investment advice, and the author bears no responsibiltiy for your subsequent investment decisions. Please refer to the [license](https://github.com/robertmartin8/PyPortfolioOpt/blob/master/LICENSE.txt) for more information._

## An overview of classical portfolio optimization methods

Expand Down
2 changes: 1 addition & 1 deletion docs/Roadmap.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Minor bug fixes
- Grouped sector constraints
- Improved error tracebacks
- Adding new cookbook for examples (in progress).
- Packaging: added bettter instructions for windows, added docker support.
- Packaging: added better instructions for windows, added docker support.

1.2.1
-----
Expand Down
2 changes: 1 addition & 1 deletion pypfopt/efficient_frontier/efficient_frontier.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def _validate_returns(self, returns):
def _make_weight_sum_constraint(self, is_market_neutral):
"""
Helper method to make the weight sum constraint. If market neutral,
validate the weights proided in the constructor.
validate the weights provided in the constructor.
"""
if is_market_neutral:
#  Check and fix bounds
Expand Down
14 changes: 7 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,15 @@ dev = [
#optionals = ["scikit-learn", "matplotlib", "cvxopt"]

[tool.ruff]
[lint]
select = ["E", "F", "I"]
exclude = ["*__init__.py", "tests/test_imports.py"]

line-length = 120
target-version = "py310"
#exclude = [
# "*__init__.py", "tests/test_imports.py"
#]
exclude = [
"*__init__.py", "tests/test_imports.py"
]

[tool.ruff.lint]
select = ["E", "F", "I"]


[build-system]
requires = ["hatchling"]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_efficient_cdar.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def test_min_cdar_tx_costs():
cd.min_cdar()
w1 = cd.weights

# Pretend we were initally equal weight
# Pretend we were initially equal weight
cd = setup_efficient_cdar()
prev_w = np.array([1 / cd.n_assets] * cd.n_assets)
cd.add_objective(objective_functions.transaction_cost, w_prev=prev_w)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_efficient_cvar.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def test_min_cvar_tx_costs():
cv.min_cvar()
w1 = cv.weights

# Pretend we were initally equal weight
# Pretend we were initially equal weight
cv = setup_efficient_cvar()
prev_w = np.array([1 / cv.n_assets] * cv.n_assets)
cv.add_objective(objective_functions.transaction_cost, w_prev=prev_w)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_efficient_frontier.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def test_min_volatility_tx_costs():
ef.min_volatility()
w1 = ef.weights

# Pretend we were initally equal weight
# Pretend we were initially equal weight
ef = setup_efficient_frontier()
prev_w = np.array([1 / ef.n_assets] * ef.n_assets)
ef.add_objective(objective_functions.transaction_cost, w_prev=prev_w)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_efficient_semivariance.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def test_min_semivariance_tx_costs():
es.min_semivariance()
w1 = es.weights

# Pretend we were initally equal weight
# Pretend we were initially equal weight
es = setup_efficient_semivariance()
prev_w = np.array([1 / es.n_assets] * es.n_assets)
es.add_objective(objective_functions.transaction_cost, w_prev=prev_w)
Expand Down

0 comments on commit 6ed99db

Please sign in to comment.