Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add InvestStatmentLine as possible return from parse_record to fix typing check errors. #263

Open
wants to merge 41 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
d75b085
Add InvestStatmentLine as possible reutrn to fix typing check errors.
jaik03 Jan 14, 2024
498485b
Return pkg_resources namespaces back
kedder Jan 17, 2024
f7af059
Merge pull request #264 from kedder/pkg-resources-ns
kedder Jan 21, 2024
1e2abea
Bump pytest from 7.4.4 to 8.0.0
dependabot[bot] Feb 3, 2024
214bb9c
Use union instead of pipe for older python versions
jaik03 Feb 4, 2024
d506798
Ignore type checking due to ambiguous declaration
jaik03 Feb 4, 2024
8dc6085
Fix formatting via black
jaik03 Feb 4, 2024
0942bbd
Merge pull request #266 from kedder/dependabot/pip/pytest-8.0.0
kedder Feb 10, 2024
c581777
Bump pytest from 8.0.0 to 8.0.1
dependabot[bot] Feb 17, 2024
f8b4275
Merge pull request #269 from kedder/dependabot/pip/pytest-8.0.1
kedder Feb 22, 2024
ac317a7
Switch metadata to pyproject.toml
kedder Feb 22, 2024
a852d23
Install type hints for appdirs
kedder Feb 22, 2024
777f662
Reformat with newer black
kedder Feb 22, 2024
338a9f6
Drop support for 3.8, add 3.12
kedder Feb 22, 2024
280bc40
Install zipp for older pythons
kedder Feb 22, 2024
54db7c4
Merge pull request #270 from kedder/pyproject
kedder Feb 24, 2024
8f8008d
Don't add a blank security to the list
edwagner Feb 18, 2024
1944606
Decrease precision of total to 2 decimal places
edwagner Feb 18, 2024
05e2699
Add cap gain income types
edwagner Feb 18, 2024
86560e7
Bump zipp from 3.8 to 3.17.0
dependabot[bot] Mar 2, 2024
cfd9002
Bump pytest from 8.0.1 to 8.0.2
dependabot[bot] Mar 2, 2024
78cba7e
Handle INVBANKTRAN
edwagner Mar 4, 2024
8c1112c
Handle TRANSFER type
edwagner Mar 4, 2024
15f8c23
Merge pull request #273 from edwagner/invest-statement-enhancements
kedder Mar 5, 2024
c659d45
Fix plugin loading
edwagner Mar 6, 2024
273ca39
Merge pull request #274 from edwagner/fix-plugin-loading
kedder Mar 6, 2024
f7e5b1f
Bump mypy from 1.8.0 to 1.9.0
dependabot[bot] Mar 9, 2024
fd8f502
Bump black from 24.2.0 to 24.3.0
dependabot[bot] Mar 16, 2024
5de9b51
Bump zipp from 3.17.0 to 3.18.1
dependabot[bot] Mar 16, 2024
f0dd25c
Bump pytest from 8.0.2 to 8.1.1
dependabot[bot] Mar 16, 2024
4e4e716
Bump types-mock from 5.1.0.20240106 to 5.1.0.20240311
dependabot[bot] Mar 16, 2024
44a0c18
break out parse_invest_record that returns an InvestStatementLine object
jaik03 Mar 30, 2024
6d93bcf
Add InvestStatmentLine as possible reutrn to fix typing check errors.
jaik03 Jan 14, 2024
0be6f56
Use union instead of pipe for older python versions
jaik03 Feb 4, 2024
651fce2
Ignore type checking due to ambiguous declaration
jaik03 Feb 4, 2024
0bdfa59
Fix formatting via black
jaik03 Feb 4, 2024
831f6e9
break out parse_invest_record that returns an InvestStatementLine object
jaik03 Mar 30, 2024
cb9f7d9
Merge branch 'AddInvestStatementLineType' of ssh://kvmhost.home.arpa/…
jaik03 Mar 31, 2024
6a6cf3d
fix this back to original structure
jaik03 Mar 31, 2024
3b6e19c
add parse_invest_record line
jaik03 Mar 31, 2024
9688f8f
black run
jaik03 Mar 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/ofxstatement/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from decimal import Decimal, Decimal as D
from datetime import datetime

from ofxstatement.statement import Statement, StatementLine
from ofxstatement.statement import Statement, StatementLine, InvestStatementLine

LT = TypeVar("LT")

Expand Down Expand Up @@ -53,7 +53,7 @@ def split_records(self) -> Iterable[LT]: # pragma: no cover
"""Return iterable object consisting of a line per transaction"""
raise NotImplementedError

def parse_record(self, line: LT) -> Optional[StatementLine]: # pragma: no cover
def parse_record(self, line: LT) -> Optional[StatementLine|InvestStatementLine]: # pragma: no cover
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I somehow missed the moment when this InvestStatementLine was introduced (found it now in #129), but I'm not a big fan of these ambiguous return type.

What typing check errors are you trying to address with this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error: Return type "InvestStatementLine | None" of "parse_record" incompatible with return type "StatementLine | None" in supertype "StatementParser" [override]

I'm building a plugin to parse a JSON file filled with investment information, and mypy is throwing an override error due to the fact that my declaration says I'm returning an InvestStatementLine.

I neglected to notice that the | syntax was introduced in 3.10, and I think I used it incorrectly anyways. I can fix the PR, but do you want to approach this a different way? I can always have it ignore that specific type check in my parser code, but I thought it was better to address

"""Parse given transaction line and return StatementLine object"""
raise NotImplementedError

Expand Down
Loading