Skip to content

Commit 6785945

Browse files
committed
replace black with ruff-format
1 parent 1e40844 commit 6785945

File tree

8 files changed

+87
-133
lines changed

8 files changed

+87
-133
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
repos:
2-
- repo: 'https://github.com/pre-commit/pre-commit-hooks'
3-
rev: v4.4.0
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v5.0.0
44
hooks:
55
- id: trailing-whitespace
66
- id: end-of-file-fixer
77
- id: check-yaml
88
- id: check-added-large-files
99
- repo: https://github.com/astral-sh/ruff-pre-commit
10-
rev: v0.0.287
10+
rev: v0.8.4
1111
hooks:
1212
- id: ruff
1313
args: [--fix, --exit-non-zero-on-fix]
14-
- repo: 'https://github.com/psf/black'
15-
rev: 23.7.0
16-
hooks:
17-
- id: black
14+
- id: ruff-format

casparser/cli.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from rich.prompt import Prompt
1414
from rich.table import Table
1515

16-
from . import read_cas_pdf, __version__
16+
from . import __version__, read_cas_pdf
1717
from .analysis.gains import CapitalGainsReport
1818
from .enums import CASFileType
1919
from .exceptions import GainsError, IncompleteCASError, ParserException
@@ -146,8 +146,9 @@ def print_summary(parsed_data: CASData, output_filename=None, include_zero_folio
146146
console_row = {
147147
"scheme": scheme_name,
148148
"open": scheme["open"],
149-
"close": format_number(scheme_close) if is_summary
150-
else f"{format_number(scheme_close)}\n/\n{calc_close}",
149+
"close": format_number(scheme_close)
150+
if is_summary
151+
else f"{format_number(scheme_close)}\n/\n{calc_close}",
151152
"value": f"{formatINR(valuation['value'])}\n@\n{formatINR(valuation['nav'])}",
152153
"txns": len(scheme["transactions"]),
153154
"status": status,
@@ -384,4 +385,4 @@ def cli(output, summary, password, include_all, gains, gains_112a, force_pdfmine
384385

385386

386387
if __name__ == "__main__":
387-
cli(prog_name="casparser")
388+
cli(prog_name="casparser")

casparser/process/cas_detailed.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@
2323
DESCRIPTION_TAIL_RE,
2424
DETAILED_DATE_RE,
2525
DIVIDEND_RE,
26-
FOLIO_RE,
2726
FOLIO_KV_RE,
27+
FOLIO_RE,
2828
NAV_RE,
2929
NOMINEE_RE,
3030
OPEN_UNITS_RE,
3131
REGISTRAR_RE,
32-
SCHEME_RE,
3332
SCHEME_KV_RE,
33+
SCHEME_RE,
3434
TRANSACTION_RE1,
3535
TRANSACTION_RE2,
3636
TRANSACTION_RE3,

poetry.lock

Lines changed: 19 additions & 87 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ python = "^3.10"
2121
casparser-isin = ">=2024.5.12"
2222
click = ">=7.0,<9.0"
2323
colorama = "^0.4.6"
24-
"pdfminer.six" = "20221105"
24+
"pdfminer.six" = "20240706"
2525
python-dateutil = "^2.8.2"
2626
rich = "^13.5.2"
2727
pydantic = "^2.3.0"
@@ -32,18 +32,15 @@ mupdf = ["PyMuPDF"]
3232
fast = ["PyMuPDF"]
3333

3434
[tool.poetry.dev-dependencies]
35-
coverage = {version = "^7.1", extras=["toml"]}
36-
ipython = "^8.1.0"
37-
pytest = "^7.4.0"
38-
pytest-cov = "^4.1.0"
35+
coverage = {version = "^7.6", extras=["toml"]}
36+
ipython = "^8.31.0"
37+
pytest = "~8.3.0"
38+
pytest-cov = "~6.0.0"
3939
pre-commit = "^4.0.0"
4040

4141
[tool.poetry.scripts]
4242
casparser = 'casparser.cli:cli'
4343

44-
[tool.poetry.group.dev.dependencies]
45-
black = "^23.3.0"
46-
4744
[build-system]
4845
requires = ["poetry-core>=1.0.0"]
4946
build-backend = "poetry.core.masonry.api"
@@ -69,10 +66,16 @@ omit = [
6966
[tool.poetry-version-plugin]
7067
source = "init"
7168

72-
[tool.black]
73-
line-length = 100
74-
target-version = ['py38']
75-
7669
[tool.ruff]
7770
line-length = 100
7871
target-version = "py38"
72+
73+
74+
[tool.ruff.lint]
75+
select = ["E", "F", "I"]
76+
77+
[tool.ruff.format]
78+
quote-style = "double"
79+
indent-style = "space"
80+
skip-magic-trailing-comma = false
81+
line-ending = "auto"

tests/test_mupdf.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import re
22

33
import fitz
4-
from click.testing import CliRunner
54
import pytest
5+
from click.testing import CliRunner
66

7-
from casparser.exceptions import CASParseError
87
from casparser.enums import FileType
8+
from casparser.exceptions import CASParseError
9+
910
from .base import BaseTestClass
1011

1112

tests/test_pdfminer.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
from pdfminer.layout import LTTextBoxHorizontal
21
import pytest
2+
from pdfminer.layout import LTTextBoxHorizontal
33

44
from casparser.exceptions import CASParseError
5+
56
from .base import BaseTestClass
67

78

tests/test_process.py

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@
22

33
import pytest
44

5+
from casparser.enums import TransactionType
56
from casparser.exceptions import CASParseError, HeaderParseError
67
from casparser.process import process_cas_text
7-
from casparser.process.cas_detailed import parse_header, get_transaction_type, get_parsed_scheme_name
8-
from casparser.process.cas_detailed import ParsedTransaction, parse_transaction
8+
from casparser.process.cas_detailed import (
9+
ParsedTransaction,
10+
get_parsed_scheme_name,
11+
get_transaction_type,
12+
parse_header,
13+
parse_transaction,
14+
)
915
from casparser.process.cas_summary import parse_header as parse_summary_header
1016
from casparser.process.utils import isin_search
11-
from casparser.enums import TransactionType
1217

1318

1419
class TestProcessClass:
@@ -95,21 +100,35 @@ def test_dividend_transactions(self):
95100
)
96101

97102
def test_parsed_scheme_name(self):
98-
assert get_parsed_scheme_name(
99-
"Axis Long Term Equity Fund - Direct Growth") == "Axis Long Term Equity Fund - Direct Growth"
100-
assert get_parsed_scheme_name(
101-
"Axis Bluechip Fund - Regular Growth ") == "Axis Bluechip Fund - Regular Growth"
102-
assert get_parsed_scheme_name(
103-
"HSBC Corporate Bond Fund - Regular Growth (Formerly known as L&T Triple Ace Bond Fund - Growth)") == \
104-
"HSBC Corporate Bond Fund - Regular Growth"
105-
assert get_parsed_scheme_name(
106-
"Bandhan ELSS Tax saver Fund-Growth-(Regular Plan)"
107-
"(erstwhile Bandhan Tax Advantage ELSS Fund-Growth-Regular Plan)") == \
108-
"Bandhan ELSS Tax saver Fund-Growth-(Regular Plan)"
109-
assert get_parsed_scheme_name(
110-
"Bandhan Liquid Fund-Growth-(Regular Plan) (erstwhile IDFC Cash Fund-Growth-Regular Plan) (Non-Demat) ") == \
111-
"Bandhan Liquid Fund-Growth-(Regular Plan)"
112-
103+
assert (
104+
get_parsed_scheme_name("Axis Long Term Equity Fund - Direct Growth")
105+
== "Axis Long Term Equity Fund - Direct Growth"
106+
)
107+
assert (
108+
get_parsed_scheme_name("Axis Bluechip Fund - Regular Growth ")
109+
== "Axis Bluechip Fund - Regular Growth"
110+
)
111+
assert (
112+
get_parsed_scheme_name(
113+
"HSBC Corporate Bond Fund - Regular Growth "
114+
"(Formerly known as L&T Triple Ace Bond Fund - Growth)"
115+
)
116+
== "HSBC Corporate Bond Fund - Regular Growth"
117+
)
118+
assert (
119+
get_parsed_scheme_name(
120+
"Bandhan ELSS Tax saver Fund-Growth-(Regular Plan)"
121+
"(erstwhile Bandhan Tax Advantage ELSS Fund-Growth-Regular Plan)"
122+
)
123+
== "Bandhan ELSS Tax saver Fund-Growth-(Regular Plan)"
124+
)
125+
assert (
126+
get_parsed_scheme_name(
127+
"Bandhan Liquid Fund-Growth-(Regular Plan) "
128+
"(erstwhile IDFC Cash Fund-Growth-Regular Plan) (Non-Demat) "
129+
)
130+
== "Bandhan Liquid Fund-Growth-(Regular Plan)"
131+
)
113132

114133
def test_isin_search(self):
115134
isin, amfi, scheme_type = isin_search(

0 commit comments

Comments
 (0)