Skip to content

Commit

Permalink
Merge pull request #1227 from PokestarFan/add-types-snake
Browse files Browse the repository at this point in the history
(#1164) Add types to util/snake.py
  • Loading branch information
bboe committed Dec 29, 2019
2 parents 923cebd + 468187a commit 009c38a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions praw/util/snake.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
"""Contains functions dealing with snake case conversions."""

import re
from typing import Any, Dict

_re_camel_to_snake = re.compile(r"([a-z0-9](?=[A-Z])|[A-Z](?=[A-Z][a-z]))")


def camel_to_snake(name):
def camel_to_snake(name: str) -> str:
"""Convert `name` from camelCase to snake_case."""
return _re_camel_to_snake.sub(r"\1_", name).lower()


def snake_case_keys(dictionary):
def snake_case_keys(dictionary: Dict[str, Any]) -> Dict[str, Any]:
"""Return a new dictionary with keys converted to snake_case.
:param dictionary: The dict to be corrected.
Expand Down

0 comments on commit 009c38a

Please sign in to comment.