mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-19 11:22:06 +08:00
ENH: Coerce user input with API method decorator
Previously we have capitalized input strings at different levels in our code: in the user-facing API methods and in the asset finder. This commit moves input string capitalization exclusively to the API method to which the string was supplied. Specifically, the string is capitalized by a preprocess API method decorator. The preprocess decorator passes the input string to the newly defined ensure_upper_case() method, which returns a TypeError if the argument supplied is not a string. ensure_upper_case() is defined in a new file, zipline/utils/input_validation.py. The existing expect_types() method is also moved there. Various tests in tests/test_assets.py are modified to account for the fact that the asset finder method lookup_symol() no longer capitalizes its supplied argument.
This commit is contained in:
@@ -5,7 +5,8 @@ from types import FunctionType
|
||||
from unittest import TestCase
|
||||
from nose_parameterized import parameterized
|
||||
|
||||
from zipline.utils.preprocess import call, expect_types, preprocess, optional
|
||||
from zipline.utils.preprocess import call, preprocess
|
||||
from zipline.utils.input_validation import expect_types, optional
|
||||
|
||||
|
||||
def noop(func, argname, argvalue):
|
||||
|
||||
Reference in New Issue
Block a user