Skip to content

Commit

Permalink
Add pre-commit ci (#9)
Browse files Browse the repository at this point in the history
* Add pre-commit ci

* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci

* Add pre-commit badge

* Fix lint error

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
kaushiksk and pre-commit-ci[bot] authored Jun 27, 2021
1 parent 14bb6ef commit 825d422
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 8 deletions.
10 changes: 10 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
ci:
autofix_commit_msg: |
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
autofix_prs: true
autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate'
autoupdate_schedule: weekly
skip: []
submodules: false

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
[![code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![GitHub](https://img.shields.io/github/license/kaushiksk/pyportfolio)](https://github.com/kaushiksk/pyportfolio/blob/main/LICENSE)
[![Python package](https://github.com/kaushiksk/pyportfolio/actions/workflows/python-package.yml/badge.svg)](https://github.com/kaushiksk/pyportfolio/actions/workflows/python-package.yml)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/kaushiksk/pyportfolio/main.svg)](https://results.pre-commit.ci/latest/github/kaushiksk/pyportfolio/main)

Python package with a CLI to consolidate and analyze your investments (currently only supports mutual funds).

Expand Down
12 changes: 7 additions & 5 deletions pyportfolio/mfhelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
SCHEME_API_URL = "https://api.mfapi.in/mf/{code}"
session = requests.Session()


def get_scheme_details(amfi_id):
"""
gets the scheme info for a given scheme code
Expand All @@ -13,14 +14,15 @@ def get_scheme_details(amfi_id):
code = str(amfi_id)
url = SCHEME_API_URL.format(code=code)
response = session.get(url).json()
scheme_info = response['meta']

scheme_info = response["meta"]
if scheme_info:
scheme_info['nav'] = response['data'][0]["nav"]
scheme_info["nav"] = response["data"][0]["nav"]
return scheme_info

return None


if __name__ == "__main__":
print(get_scheme_details(119551))
print(get_scheme_details(111))
print(get_scheme_details(111))
7 changes: 5 additions & 2 deletions pyportfolio/utils.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import logging

logging.basicConfig()
logger = logging.getLogger('pyportfolio')
logger = logging.getLogger("pyportfolio")
logger.setLevel(logging.INFO)


# Filter Utils
def and_filter(filters):
return lambda x: all(f(x) for f in filters)


def or_filter(filters):
return lambda x: any(f(x) for f in filters)


def filter_dict(mydict, keys):
return {key: mydict[key] for key in keys }
return {key: mydict[key] for key in keys}
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import setuptools

if __name__ == "__main__":
setuptools.setup()
setuptools.setup()

0 comments on commit 825d422

Please sign in to comment.