alphavantage.dates   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 26
rs 10
c 0
b 0
f 0
wmc 3

3 Functions

Rating   Name   Duplication   Size   Complexity  
A parse_date() 0 2 1
A convert_to_utc() 0 7 1
A parse_datetime() 0 2 1
1
from datetime import datetime
0 ignored issues
show
Coding Style introduced by
This module should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
2
from functools import lru_cache
3
4
import pytz
5
6
# Date formats
7
DATE_FORMAT = '%Y-%m-%d'
8
DATETIME_FORMAT = '%Y-%m-%d %H:%M:%S'
9
10
11
@lru_cache(8192)
12
def convert_to_utc(dt: datetime, timezone: str) -> datetime:
13
    """Convert naive datetime with timezone label to UTC."""
14
15
    zone = pytz.timezone(timezone)
16
17
    return zone.localize(dt).astimezone(pytz.UTC)
18
19
20
def parse_datetime(d, formatter=DATETIME_FORMAT):
0 ignored issues
show
Coding Style Naming introduced by
Argument name "d" doesn't conform to '[a-z_][a-z0-9_]1,30$' pattern ('[a-z_][a-z0-9_]1,30$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
21
    return datetime.strptime(d, formatter)
22
23
24
def parse_date(d):
0 ignored issues
show
Coding Style Naming introduced by
Argument name "d" doesn't conform to '[a-z_][a-z0-9_]1,30$' pattern ('[a-z_][a-z0-9_]1,30$' pattern)

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
25
    return parse_datetime(d, formatter=DATE_FORMAT).date()
26