diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5869834 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +*.egg-info +__pycache__/ +.pytest_cache/ +.mypy_cache/ +.vscode/ \ No newline at end of file diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..dc42c87 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,30 @@ +sudo: required +dist: xenial +language: python +jobs: + include: + - name: Test against Python 3.6 + python: 3.6 + script: pytest + + - name: Test against Python 3.7 + python: 3.7 + script: pytest + + - name: Lint test with black + python: 3.6 + script: black --check django_filters-stubs/ + + - name: Lint test with isort + python: 3.6 + script: isort --check + + - name: Lint test with flake8 + python: 3.6 + script: flake8 + +before_install: + - pip install --upgrade pip + - pip install pipenv +install: + - pipenv install --dev \ No newline at end of file diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..90bd53d --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,7 @@ +Copyright 2020 Davis Raymond Muro. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/Pipfile b/Pipfile new file mode 100644 index 0000000..554eb1f --- /dev/null +++ b/Pipfile @@ -0,0 +1,16 @@ +[[source]] +name = "pypi" +url = "https://pypi.org/simple" +verify_ssl = true + +[dev-packages] +black = "==19.10b0" +flake8 = "*" +isort = "*" +pytest-mypy-plugins = "*" + +[packages] +django-filter-stubs = {editable = true,path = "."} + +[requires] +python_version = "3.7" diff --git a/Pipfile.lock b/Pipfile.lock new file mode 100644 index 0000000..2725b18 --- /dev/null +++ b/Pipfile.lock @@ -0,0 +1,403 @@ +{ + "_meta": { + "hash": { + "sha256": "1975bc6accdda92b002269ef62ca579fa18f0ee57d07fa72ab3f2ad0f337f61c" + }, + "pipfile-spec": 6, + "requires": { + "python_version": "3.7" + }, + "sources": [ + { + "name": "pypi", + "url": "https://pypi.org/simple", + "verify_ssl": true + } + ] + }, + "default": { + "asgiref": { + "hashes": [ + "sha256:7e06d934a7718bf3975acbf87780ba678957b87c7adc056f13b6215d610695a0", + "sha256:ea448f92fc35a0ef4b1508f53a04c4670255a3f33d22a81c8fc9c872036adbe5" + ], + "version": "==3.2.3" + }, + "django": { + "hashes": [ + "sha256:4f2c913303be4f874015993420bf0bd8fd2097a9c88e6b49c6a92f9bdd3fb13a", + "sha256:8c3575f81e11390893860d97e1e0154c47512f180ea55bd84ce8fa69ba8051ca" + ], + "version": "==3.0.2" + }, + "django-filter-stubs": { + "editable": true, + "path": "." + }, + "django-stubs": { + "hashes": [ + "sha256:9a1bd302c42b1132e1537ba2315b94de01e673a1926ac2b3e1523ed7b81411c8", + "sha256:a84860e02d5ada1a96e4c6f6800be4729ea3df354ff1156f0616db647dc2fe9e" + ], + "version": "==1.4.0" + }, + "djangorestframework-stubs": { + "hashes": [ + "sha256:62acdb9da11489565b3ba7d57fc28877325c7aef25a60eaae2363732414e428f", + "sha256:a887daba369b4575d9750b3468530794c5257b1f6733590e37feb96d2e675522" + ], + "version": "==1.1.0" + }, + "mypy": { + "hashes": [ + "sha256:0a9a45157e532da06fe56adcfef8a74629566b607fa2c1ac0122d1ff995c748a", + "sha256:2c35cae79ceb20d47facfad51f952df16c2ae9f45db6cb38405a3da1cf8fc0a7", + "sha256:4b9365ade157794cef9685791032521233729cb00ce76b0ddc78749abea463d2", + "sha256:53ea810ae3f83f9c9b452582261ea859828a9ed666f2e1ca840300b69322c474", + "sha256:634aef60b4ff0f650d3e59d4374626ca6153fcaff96ec075b215b568e6ee3cb0", + "sha256:7e396ce53cacd5596ff6d191b47ab0ea18f8e0ec04e15d69728d530e86d4c217", + "sha256:7eadc91af8270455e0d73565b8964da1642fe226665dd5c9560067cd64d56749", + "sha256:7f672d02fffcbace4db2b05369142e0506cdcde20cea0e07c7c2171c4fd11dd6", + "sha256:85baab8d74ec601e86134afe2bcccd87820f79d2f8d5798c889507d1088287bf", + "sha256:87c556fb85d709dacd4b4cb6167eecc5bbb4f0a9864b69136a0d4640fdc76a36", + "sha256:a6bd44efee4dc8c3324c13785a9dc3519b3ee3a92cada42d2b57762b7053b49b", + "sha256:c6d27bd20c3ba60d5b02f20bd28e20091d6286a699174dfad515636cb09b5a72", + "sha256:e2bb577d10d09a2d8822a042a23b8d62bc3b269667c9eb8e60a6edfa000211b1", + "sha256:f97a605d7c8bc2c6d1172c2f0d5a65b24142e11a58de689046e62c2d632ca8c1" + ], + "version": "==0.761" + }, + "mypy-extensions": { + "hashes": [ + "sha256:090fedd75945a69ae91ce1303b5824f428daf5a028d2f6ab8a299250a846f15d", + "sha256:2d82818f5bb3e369420cb3c4060a7970edba416647068eb4c5343488a6c604a8" + ], + "version": "==0.4.3" + }, + "pytz": { + "hashes": [ + "sha256:1c557d7d0e871de1f5ccd5833f60fb2550652da6be2693c1e02300743d21500d", + "sha256:b02c06db6cf09c12dd25137e563b31700d3b80fcc4ad23abb7a315f2789819be" + ], + "version": "==2019.3" + }, + "sqlparse": { + "hashes": [ + "sha256:40afe6b8d4b1117e7dff5504d7a8ce07d9a1b15aeeade8a2d10f130a834f8177", + "sha256:7c3dca29c022744e95b547e867cee89f4fce4373f3549ccd8797d8eb52cdb873" + ], + "version": "==0.3.0" + }, + "typed-ast": { + "hashes": [ + "sha256:0666aa36131496aed8f7be0410ff974562ab7eeac11ef351def9ea6fa28f6355", + "sha256:0c2c07682d61a629b68433afb159376e24e5b2fd4641d35424e462169c0a7919", + "sha256:249862707802d40f7f29f6e1aad8d84b5aa9e44552d2cc17384b209f091276aa", + "sha256:24995c843eb0ad11a4527b026b4dde3da70e1f2d8806c99b7b4a7cf491612652", + "sha256:269151951236b0f9a6f04015a9004084a5ab0d5f19b57de779f908621e7d8b75", + "sha256:4083861b0aa07990b619bd7ddc365eb7fa4b817e99cf5f8d9cf21a42780f6e01", + "sha256:498b0f36cc7054c1fead3d7fc59d2150f4d5c6c56ba7fb150c013fbc683a8d2d", + "sha256:4e3e5da80ccbebfff202a67bf900d081906c358ccc3d5e3c8aea42fdfdfd51c1", + "sha256:6daac9731f172c2a22ade6ed0c00197ee7cc1221aa84cfdf9c31defeb059a907", + "sha256:715ff2f2df46121071622063fc7543d9b1fd19ebfc4f5c8895af64a77a8c852c", + "sha256:73d785a950fc82dd2a25897d525d003f6378d1cb23ab305578394694202a58c3", + "sha256:8c8aaad94455178e3187ab22c8b01a3837f8ee50e09cf31f1ba129eb293ec30b", + "sha256:8ce678dbaf790dbdb3eba24056d5364fb45944f33553dd5869b7580cdbb83614", + "sha256:aaee9905aee35ba5905cfb3c62f3e83b3bec7b39413f0a7f19be4e547ea01ebb", + "sha256:bcd3b13b56ea479b3650b82cabd6b5343a625b0ced5429e4ccad28a8973f301b", + "sha256:c9e348e02e4d2b4a8b2eedb48210430658df6951fa484e59de33ff773fbd4b41", + "sha256:d205b1b46085271b4e15f670058ce182bd1199e56b317bf2ec004b6a44f911f6", + "sha256:d43943ef777f9a1c42bf4e552ba23ac77a6351de620aa9acf64ad54933ad4d34", + "sha256:d5d33e9e7af3b34a40dc05f498939f0ebf187f07c385fd58d591c533ad8562fe", + "sha256:fc0fea399acb12edbf8a628ba8d2312f583bdbdb3335635db062fa98cf71fca4", + "sha256:fe460b922ec15dd205595c9b5b99e2f056fd98ae8f9f56b888e7a17dc2b757e7" + ], + "version": "==1.4.1" + }, + "typing-extensions": { + "hashes": [ + "sha256:091ecc894d5e908ac75209f10d5b4f118fbdb2eb1ede6a63544054bb1edb41f2", + "sha256:910f4656f54de5993ad9304959ce9bb903f90aadc7c67a0bef07e678014e892d", + "sha256:cf8b63fedea4d89bab840ecbb93e75578af28f76f66c35889bd7065f5af88575" + ], + "version": "==3.7.4.1" + } + }, + "develop": { + "appdirs": { + "hashes": [ + "sha256:9e5896d1372858f8dd3344faf4e5014d21849c756c8d5701f78f8a103b372d92", + "sha256:d8b24664561d0d34ddfaec54636d502d7cea6e29c3eaf68f3df6180863e2166e" + ], + "version": "==1.4.3" + }, + "attrs": { + "hashes": [ + "sha256:08a96c641c3a74e44eb59afb61a24f2cb9f4d7188748e76ba4bb5edfa3cb7d1c", + "sha256:f7b7ce16570fe9965acd6d30101a28f62fb4a7f9e926b3bbc9b61f8b04247e72" + ], + "version": "==19.3.0" + }, + "black": { + "hashes": [ + "sha256:1b30e59be925fafc1ee4565e5e08abef6b03fe455102883820fe5ee2e4734e0b", + "sha256:c2edb73a08e9e0e6f65a0e6af18b059b8b1cdd5bef997d7a0b181df93dc81539" + ], + "index": "pypi", + "version": "==19.10b0" + }, + "click": { + "hashes": [ + "sha256:2335065e6395b9e67ca716de5f7526736bfa6ceead690adf616d925bdc622b13", + "sha256:5b94b49521f6456670fdb30cd82a4eca9412788a93fa6dd6df72c94d5a8ff2d7" + ], + "version": "==7.0" + }, + "decorator": { + "hashes": [ + "sha256:54c38050039232e1db4ad7375cfce6748d7b41c29e95a081c8a6d2c30364a2ce", + "sha256:5d19b92a3c8f7f101c8dd86afd86b0f061a8ce4540ab8cd401fa2542756bce6d" + ], + "version": "==4.4.1" + }, + "entrypoints": { + "hashes": [ + "sha256:589f874b313739ad35be6e0cd7efde2a4e9b6fea91edcc34e58ecbb8dbe56d19", + "sha256:c70dd71abe5a8c85e55e12c19bd91ccfeec11a6e99044204511f9ed547d48451" + ], + "version": "==0.3" + }, + "flake8": { + "hashes": [ + "sha256:45681a117ecc81e870cbf1262835ae4af5e7a8b08e40b944a8a6e6b895914cfb", + "sha256:49356e766643ad15072a789a20915d3c91dc89fd313ccd71802303fd67e4deca" + ], + "index": "pypi", + "version": "==3.7.9" + }, + "importlib-metadata": { + "hashes": [ + "sha256:06f5b3a99029c7134207dd882428a66992a9de2bef7c2b699b5641f9886c3302", + "sha256:b97607a1a18a5100839aec1dc26a1ea17ee0d93b20b0f008d80a5a050afb200b" + ], + "markers": "python_version < '3.8'", + "version": "==1.5.0" + }, + "isort": { + "hashes": [ + "sha256:54da7e92468955c4fceacd0c86bd0ec997b0e1ee80d97f67c35a78b719dccab1", + "sha256:6e811fcb295968434526407adb8796944f1988c5b65e8139058f2014cbe100fd" + ], + "index": "pypi", + "version": "==4.3.21" + }, + "mccabe": { + "hashes": [ + "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42", + "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f" + ], + "version": "==0.6.1" + }, + "more-itertools": { + "hashes": [ + "sha256:5dd8bcf33e5f9513ffa06d5ad33d78f31e1931ac9a18f33d37e77a180d393a7c", + "sha256:b1ddb932186d8a6ac451e1d95844b382f55e12686d51ca0c68b6f61f2ab7a507" + ], + "version": "==8.2.0" + }, + "mypy": { + "hashes": [ + "sha256:0a9a45157e532da06fe56adcfef8a74629566b607fa2c1ac0122d1ff995c748a", + "sha256:2c35cae79ceb20d47facfad51f952df16c2ae9f45db6cb38405a3da1cf8fc0a7", + "sha256:4b9365ade157794cef9685791032521233729cb00ce76b0ddc78749abea463d2", + "sha256:53ea810ae3f83f9c9b452582261ea859828a9ed666f2e1ca840300b69322c474", + "sha256:634aef60b4ff0f650d3e59d4374626ca6153fcaff96ec075b215b568e6ee3cb0", + "sha256:7e396ce53cacd5596ff6d191b47ab0ea18f8e0ec04e15d69728d530e86d4c217", + "sha256:7eadc91af8270455e0d73565b8964da1642fe226665dd5c9560067cd64d56749", + "sha256:7f672d02fffcbace4db2b05369142e0506cdcde20cea0e07c7c2171c4fd11dd6", + "sha256:85baab8d74ec601e86134afe2bcccd87820f79d2f8d5798c889507d1088287bf", + "sha256:87c556fb85d709dacd4b4cb6167eecc5bbb4f0a9864b69136a0d4640fdc76a36", + "sha256:a6bd44efee4dc8c3324c13785a9dc3519b3ee3a92cada42d2b57762b7053b49b", + "sha256:c6d27bd20c3ba60d5b02f20bd28e20091d6286a699174dfad515636cb09b5a72", + "sha256:e2bb577d10d09a2d8822a042a23b8d62bc3b269667c9eb8e60a6edfa000211b1", + "sha256:f97a605d7c8bc2c6d1172c2f0d5a65b24142e11a58de689046e62c2d632ca8c1" + ], + "version": "==0.761" + }, + "mypy-extensions": { + "hashes": [ + "sha256:090fedd75945a69ae91ce1303b5824f428daf5a028d2f6ab8a299250a846f15d", + "sha256:2d82818f5bb3e369420cb3c4060a7970edba416647068eb4c5343488a6c604a8" + ], + "version": "==0.4.3" + }, + "packaging": { + "hashes": [ + "sha256:170748228214b70b672c581a3dd610ee51f733018650740e98c7df862a583f73", + "sha256:e665345f9eef0c621aa0bf2f8d78cf6d21904eef16a93f020240b704a57f1334" + ], + "version": "==20.1" + }, + "pathspec": { + "hashes": [ + "sha256:163b0632d4e31cef212976cf57b43d9fd6b0bac6e67c26015d611a647d5e7424", + "sha256:562aa70af2e0d434367d9790ad37aed893de47f1693e4201fd1d3dca15d19b96" + ], + "version": "==0.7.0" + }, + "pluggy": { + "hashes": [ + "sha256:15b2acde666561e1298d71b523007ed7364de07029219b604cf808bfa1c765b0", + "sha256:966c145cd83c96502c3c3868f50408687b38434af77734af1e9ca461a4081d2d" + ], + "version": "==0.13.1" + }, + "py": { + "hashes": [ + "sha256:5e27081401262157467ad6e7f851b7aa402c5852dbcb3dae06768434de5752aa", + "sha256:c20fdd83a5dbc0af9efd622bee9a5564e278f6380fffcacc43ba6f43db2813b0" + ], + "version": "==1.8.1" + }, + "pycodestyle": { + "hashes": [ + "sha256:95a2219d12372f05704562a14ec30bc76b05a5b297b21a5dfe3f6fac3491ae56", + "sha256:e40a936c9a450ad81df37f549d676d127b1b66000a6c500caa2b085bc0ca976c" + ], + "version": "==2.5.0" + }, + "pyflakes": { + "hashes": [ + "sha256:17dbeb2e3f4d772725c777fabc446d5634d1038f234e77343108ce445ea69ce0", + "sha256:d976835886f8c5b31d47970ed689944a0262b5f3afa00a5a7b4dc81e5449f8a2" + ], + "version": "==2.1.1" + }, + "pyparsing": { + "hashes": [ + "sha256:4c830582a84fb022400b85429791bc551f1f4871c33f23e44f353119e92f969f", + "sha256:c342dccb5250c08d45fd6f8b4a559613ca603b57498511740e65cd11a2e7dcec" + ], + "version": "==2.4.6" + }, + "pytest": { + "hashes": [ + "sha256:0d5fe9189a148acc3c3eb2ac8e1ac0742cb7618c084f3d228baaec0c254b318d", + "sha256:ff615c761e25eb25df19edddc0b970302d2a9091fbce0e7213298d85fb61fef6" + ], + "version": "==5.3.5" + }, + "pytest-mypy-plugins": { + "hashes": [ + "sha256:9012dddb48b27652b432a5b8102b3046d7da36a7a15a9cffa5b0d123484afe68", + "sha256:ca562a5e49ccbc8e46a6281050eae9ad6f10512b9000d36571c0fe78334b8ea3" + ], + "index": "pypi", + "version": "==1.2.0" + }, + "pyyaml": { + "hashes": [ + "sha256:059b2ee3194d718896c0ad077dd8c043e5e909d9180f387ce42012662a4946d6", + "sha256:1cf708e2ac57f3aabc87405f04b86354f66799c8e62c28c5fc5f88b5521b2dbf", + "sha256:24521fa2890642614558b492b473bee0ac1f8057a7263156b02e8b14c88ce6f5", + "sha256:4fee71aa5bc6ed9d5f116327c04273e25ae31a3020386916905767ec4fc5317e", + "sha256:70024e02197337533eef7b85b068212420f950319cc8c580261963aefc75f811", + "sha256:74782fbd4d4f87ff04159e986886931456a1894c61229be9eaf4de6f6e44b99e", + "sha256:940532b111b1952befd7db542c370887a8611660d2b9becff75d39355303d82d", + "sha256:cb1f2f5e426dc9f07a7681419fe39cee823bb74f723f36f70399123f439e9b20", + "sha256:dbbb2379c19ed6042e8f11f2a2c66d39cceb8aeace421bfc29d085d93eda3689", + "sha256:e3a057b7a64f1222b56e47bcff5e4b94c4f61faac04c7c4ecb1985e18caa3994", + "sha256:e9f45bd5b92c7974e59bcd2dcc8631a6b6cc380a904725fce7bc08872e691615" + ], + "version": "==5.3" + }, + "regex": { + "hashes": [ + "sha256:07b39bf943d3d2fe63d46281d8504f8df0ff3fe4c57e13d1656737950e53e525", + "sha256:0932941cdfb3afcbc26cc3bcf7c3f3d73d5a9b9c56955d432dbf8bbc147d4c5b", + "sha256:0e182d2f097ea8549a249040922fa2b92ae28be4be4895933e369a525ba36576", + "sha256:10671601ee06cf4dc1bc0b4805309040bb34c9af423c12c379c83d7895622bb5", + "sha256:23e2c2c0ff50f44877f64780b815b8fd2e003cda9ce817a7fd00dea5600c84a0", + "sha256:26ff99c980f53b3191d8931b199b29d6787c059f2e029b2b0c694343b1708c35", + "sha256:27429b8d74ba683484a06b260b7bb00f312e7c757792628ea251afdbf1434003", + "sha256:3e77409b678b21a056415da3a56abfd7c3ad03da71f3051bbcdb68cf44d3c34d", + "sha256:4e8f02d3d72ca94efc8396f8036c0d3bcc812aefc28ec70f35bb888c74a25161", + "sha256:4eae742636aec40cf7ab98171ab9400393360b97e8f9da67b1867a9ee0889b26", + "sha256:6a6ae17bf8f2d82d1e8858a47757ce389b880083c4ff2498dba17c56e6c103b9", + "sha256:6a6ba91b94427cd49cd27764679024b14a96874e0dc638ae6bdd4b1a3ce97be1", + "sha256:7bcd322935377abcc79bfe5b63c44abd0b29387f267791d566bbb566edfdd146", + "sha256:98b8ed7bb2155e2cbb8b76f627b2fd12cf4b22ab6e14873e8641f266e0fb6d8f", + "sha256:bd25bb7980917e4e70ccccd7e3b5740614f1c408a642c245019cff9d7d1b6149", + "sha256:d0f424328f9822b0323b3b6f2e4b9c90960b24743d220763c7f07071e0778351", + "sha256:d58e4606da2a41659c84baeb3cfa2e4c87a74cec89a1e7c56bee4b956f9d7461", + "sha256:e3cd21cc2840ca67de0bbe4071f79f031c81418deb544ceda93ad75ca1ee9f7b", + "sha256:e6c02171d62ed6972ca8631f6f34fa3281d51db8b326ee397b9c83093a6b7242", + "sha256:e7c7661f7276507bce416eaae22040fd91ca471b5b33c13f8ff21137ed6f248c", + "sha256:ecc6de77df3ef68fee966bb8cb4e067e84d4d1f397d0ef6fce46913663540d77" + ], + "version": "==2020.1.8" + }, + "six": { + "hashes": [ + "sha256:236bdbdce46e6e6a3d61a337c0f8b763ca1e8717c03b369e87a7ec7ce1319c0a", + "sha256:8f3cd2e254d8f793e7f3d6d9df77b92252b52637291d0f0da013c76ea2724b6c" + ], + "version": "==1.14.0" + }, + "toml": { + "hashes": [ + "sha256:229f81c57791a41d65e399fc06bf0848bab550a9dfd5ed66df18ce5f05e73d5c", + "sha256:235682dd292d5899d361a811df37e04a8828a5b1da3115886b73cf81ebc9100e" + ], + "version": "==0.10.0" + }, + "typed-ast": { + "hashes": [ + "sha256:0666aa36131496aed8f7be0410ff974562ab7eeac11ef351def9ea6fa28f6355", + "sha256:0c2c07682d61a629b68433afb159376e24e5b2fd4641d35424e462169c0a7919", + "sha256:249862707802d40f7f29f6e1aad8d84b5aa9e44552d2cc17384b209f091276aa", + "sha256:24995c843eb0ad11a4527b026b4dde3da70e1f2d8806c99b7b4a7cf491612652", + "sha256:269151951236b0f9a6f04015a9004084a5ab0d5f19b57de779f908621e7d8b75", + "sha256:4083861b0aa07990b619bd7ddc365eb7fa4b817e99cf5f8d9cf21a42780f6e01", + "sha256:498b0f36cc7054c1fead3d7fc59d2150f4d5c6c56ba7fb150c013fbc683a8d2d", + "sha256:4e3e5da80ccbebfff202a67bf900d081906c358ccc3d5e3c8aea42fdfdfd51c1", + "sha256:6daac9731f172c2a22ade6ed0c00197ee7cc1221aa84cfdf9c31defeb059a907", + "sha256:715ff2f2df46121071622063fc7543d9b1fd19ebfc4f5c8895af64a77a8c852c", + "sha256:73d785a950fc82dd2a25897d525d003f6378d1cb23ab305578394694202a58c3", + "sha256:8c8aaad94455178e3187ab22c8b01a3837f8ee50e09cf31f1ba129eb293ec30b", + "sha256:8ce678dbaf790dbdb3eba24056d5364fb45944f33553dd5869b7580cdbb83614", + "sha256:aaee9905aee35ba5905cfb3c62f3e83b3bec7b39413f0a7f19be4e547ea01ebb", + "sha256:bcd3b13b56ea479b3650b82cabd6b5343a625b0ced5429e4ccad28a8973f301b", + "sha256:c9e348e02e4d2b4a8b2eedb48210430658df6951fa484e59de33ff773fbd4b41", + "sha256:d205b1b46085271b4e15f670058ce182bd1199e56b317bf2ec004b6a44f911f6", + "sha256:d43943ef777f9a1c42bf4e552ba23ac77a6351de620aa9acf64ad54933ad4d34", + "sha256:d5d33e9e7af3b34a40dc05f498939f0ebf187f07c385fd58d591c533ad8562fe", + "sha256:fc0fea399acb12edbf8a628ba8d2312f583bdbdb3335635db062fa98cf71fca4", + "sha256:fe460b922ec15dd205595c9b5b99e2f056fd98ae8f9f56b888e7a17dc2b757e7" + ], + "version": "==1.4.1" + }, + "typing-extensions": { + "hashes": [ + "sha256:091ecc894d5e908ac75209f10d5b4f118fbdb2eb1ede6a63544054bb1edb41f2", + "sha256:910f4656f54de5993ad9304959ce9bb903f90aadc7c67a0bef07e678014e892d", + "sha256:cf8b63fedea4d89bab840ecbb93e75578af28f76f66c35889bd7065f5af88575" + ], + "version": "==3.7.4.1" + }, + "wcwidth": { + "hashes": [ + "sha256:8fd29383f539be45b20bd4df0dc29c20ba48654a41e661925e612311e9f3c603", + "sha256:f28b3e8a6483e5d49e7f8949ac1a78314e740333ae305b4ba5defd3e74fb37a8" + ], + "version": "==0.1.8" + }, + "zipp": { + "hashes": [ + "sha256:ccc94ed0909b58ffe34430ea5451f07bc0c76467d7081619a454bf5c98b89e28", + "sha256:feae2f18633c32fc71f2de629bfb3bd3c9325cd4419642b1f1da42ee488d9b98" + ], + "version": "==2.1.0" + } + } +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..0fe535b --- /dev/null +++ b/README.md @@ -0,0 +1,12 @@ +# PEP-484 Stubs for django-filter ::: Beta + +[![Build Status](https://travis-ci.org/DavisRayM/django-filter-stubs.svg?branch=master)](https://travis-ci.org/DavisRayM/django-filter-stubs) +[![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/) + +This package contains type subs to provide more precise static types for Django Filters. + +## Installation + +```bash +pip install django-filter-stubs +``` diff --git a/django_filters-stubs/__init__.pyi b/django_filters-stubs/__init__.pyi new file mode 100644 index 0000000..6563a1f --- /dev/null +++ b/django_filters-stubs/__init__.pyi @@ -0,0 +1,9 @@ +from typing import Any + +from . import rest_framework as rest_framework +from .filters import * +from .filterset import FilterSet as FilterSet + +def parse_version(version: Any): ... + +VERSION: Any diff --git a/django_filters-stubs/compat.pyi b/django_filters-stubs/compat.pyi new file mode 100644 index 0000000..fb298ad --- /dev/null +++ b/django_filters-stubs/compat.pyi @@ -0,0 +1 @@ +def is_crispy(): ... diff --git a/django_filters-stubs/conf.pyi b/django_filters-stubs/conf.pyi new file mode 100644 index 0000000..832da5e --- /dev/null +++ b/django_filters-stubs/conf.pyi @@ -0,0 +1,17 @@ +from typing import Any + +from .utils import deprecate as deprecate + +DEFAULTS: Any +DEPRECATED_SETTINGS: Any + +def is_callable(value: Any): ... + +class Settings: + def __getattr__(self, name: Any): ... + def get_setting(self, setting: Any): ... + def change_setting( + self, setting: Any, value: Any, enter: Any, **kwargs: Any + ) -> None: ... + +settings: Any diff --git a/django_filters-stubs/constants.pyi b/django_filters-stubs/constants.pyi new file mode 100644 index 0000000..e7cee31 --- /dev/null +++ b/django_filters-stubs/constants.pyi @@ -0,0 +1,4 @@ +from typing import Any + +ALL_FIELDS: str +EMPTY_VALUES: Any diff --git a/django_filters-stubs/exceptions.pyi b/django_filters-stubs/exceptions.pyi new file mode 100644 index 0000000..fa718be --- /dev/null +++ b/django_filters-stubs/exceptions.pyi @@ -0,0 +1,6 @@ +from typing import Any + +from django.core.exceptions import FieldError + +class FieldLookupError(FieldError): + def __init__(self, model_field: Any, lookup_expr: Any) -> None: ... diff --git a/django_filters-stubs/fields.pyi b/django_filters-stubs/fields.pyi new file mode 100644 index 0000000..410e56a --- /dev/null +++ b/django_filters-stubs/fields.pyi @@ -0,0 +1,95 @@ +from typing import Any, Optional + +from django import forms + +from .conf import settings as settings +from .constants import EMPTY_VALUES as EMPTY_VALUES +from .utils import handle_timezone as handle_timezone +from .widgets import BaseCSVWidget as BaseCSVWidget +from .widgets import CSVWidget as CSVWidget +from .widgets import DateRangeWidget as DateRangeWidget +from .widgets import LookupChoiceWidget as LookupChoiceWidget +from .widgets import RangeWidget as RangeWidget + +class RangeField(forms.MultiValueField): + widget: Any = ... + def __init__( + self, fields: Optional[Any] = ..., *args: Any, **kwargs: Any + ) -> None: ... + def compress(self, data_list: Any): ... + +class DateRangeField(RangeField): + widget: Any = ... + def __init__(self, *args: Any, **kwargs: Any) -> None: ... + def compress(self, data_list: Any): ... + +class DateTimeRangeField(RangeField): + widget: Any = ... + def __init__(self, *args: Any, **kwargs: Any) -> None: ... + +class IsoDateTimeRangeField(RangeField): + widget: Any = ... + def __init__(self, *args: Any, **kwargs: Any) -> None: ... + +class TimeRangeField(RangeField): + widget: Any = ... + def __init__(self, *args: Any, **kwargs: Any) -> None: ... + +class Lookup: + def __new__(cls, value: Any, lookup_expr: Any): ... + +class LookupChoiceField(forms.MultiValueField): + default_error_messages: Any = ... + def __init__( + self, field: Any, lookup_choices: Any, *args: Any, **kwargs: Any + ) -> None: ... + def compress(self, data_list: Any): ... + +class IsoDateTimeField(forms.DateTimeField): + ISO_8601: str = ... + input_formats: Any = ... + def strptime(self, value: Any, format: Any): ... + +class BaseCSVField(forms.Field): + base_widget_class: Any = ... + def __init__(self, *args: Any, **kwargs: Any) -> None: ... + def clean(self, value: Any): ... + +class BaseRangeField(BaseCSVField): + widget: Any = ... + default_error_messages: Any = ... + def clean(self, value: Any): ... + +class ChoiceIterator: + field: Any = ... + choices: Any = ... + def __init__(self, field: Any, choices: Any) -> None: ... + def __iter__(self) -> Any: ... + def __len__(self): ... + +class ModelChoiceIterator(forms.models.ModelChoiceIterator): + def __iter__(self) -> Any: ... + def __len__(self): ... + +class ChoiceIteratorMixin: + null_label: Any = ... + null_value: Any = ... + def __init__(self, *args: Any, **kwargs: Any) -> None: ... + choices: Any = ... + +class ChoiceField(ChoiceIteratorMixin, forms.ChoiceField): + iterator: Any = ... + empty_label: Any = ... + def __init__(self, *args: Any, **kwargs: Any) -> None: ... + +class MultipleChoiceField(ChoiceIteratorMixin, forms.MultipleChoiceField): + iterator: Any = ... + empty_label: Any = ... + def __init__(self, *args: Any, **kwargs: Any) -> None: ... + +class ModelChoiceField(ChoiceIteratorMixin, forms.ModelChoiceField): + iterator: Any = ... + def to_python(self, value: Any): ... + +class ModelMultipleChoiceField(ChoiceIteratorMixin, forms.ModelMultipleChoiceField): + iterator: Any = ... diff --git a/django_filters-stubs/filters.pyi b/django_filters-stubs/filters.pyi new file mode 100644 index 0000000..98039e2 --- /dev/null +++ b/django_filters-stubs/filters.pyi @@ -0,0 +1,182 @@ +from typing import Any, Callable, Optional + +class Filter: + creation_counter: int = ... + field_class: Any = ... + field_name: Any = ... + lookup_expr: Any = ... + distinct: Any = ... + exclude: Any = ... + extra: Any = ... + def __init__( + self, + field_name: Optional[Any] = ..., + lookup_expr: str = ..., + *, + label: Optional[Any] = ..., + method: Optional[Any] = ..., + distinct: bool = ..., + exclude: bool = ..., + **kwargs: Any + ) -> None: ... + def get_method(self, qs: Any): ... + method: Callable = ... + label: Any = ... + @property + def field(self): ... + def filter(self, qs: Any, value: Any): ... + +class CharFilter(Filter): + field_class: Any = ... + +class BooleanFilter(Filter): + field_class: Any = ... + +class ChoiceFilter(Filter): + field_class: Any = ... + null_value: Any = ... + def __init__(self, *args: Any, **kwargs: Any) -> None: ... + def filter(self, qs: Any, value: Any): ... + +class TypedChoiceFilter(Filter): + field_class: Any = ... + +class UUIDFilter(Filter): + field_class: Any = ... + +class MultipleChoiceFilter(Filter): + field_class: Any = ... + always_filter: bool = ... + conjoined: Any = ... + null_value: Any = ... + def __init__(self, *args: Any, **kwargs: Any) -> None: ... + def is_noop(self, qs: Any, value: Any): ... + def filter(self, qs: Any, value: Any): ... + def get_filter_predicate(self, v: Any): ... + +class TypedMultipleChoiceFilter(MultipleChoiceFilter): + field_class: Any = ... + +class DateFilter(Filter): + field_class: Any = ... + +class DateTimeFilter(Filter): + field_class: Any = ... + +class IsoDateTimeFilter(DateTimeFilter): + field_class: Any = ... + +class TimeFilter(Filter): + field_class: Any = ... + +class DurationFilter(Filter): + field_class: Any = ... + +class QuerySetRequestMixin: + queryset: Any = ... + def __init__(self, *args: Any, **kwargs: Any) -> None: ... + def get_request(self): ... + def get_queryset(self, request: Any): ... + @property + def field(self): ... + +class ModelChoiceFilter(QuerySetRequestMixin, ChoiceFilter): + field_class: Any = ... + def __init__(self, *args: Any, **kwargs: Any) -> None: ... + +class ModelMultipleChoiceFilter(QuerySetRequestMixin, MultipleChoiceFilter): + field_class: Any = ... + +class NumberFilter(Filter): + field_class: Any = ... + +class NumericRangeFilter(Filter): + field_class: Any = ... + lookup_expr: str = ... + def filter(self, qs: Any, value: Any): ... + +class RangeFilter(Filter): + field_class: Any = ... + lookup_expr: str = ... + def filter(self, qs: Any, value: Any): ... + +class DateRangeFilter(ChoiceFilter): + choices: Any = ... + filters: Any = ... + def __init__( + self, + choices: Optional[Any] = ..., + filters: Optional[Any] = ..., + *args: Any, + **kwargs: Any + ) -> None: ... + def filter(self, qs: Any, value: Any): ... + +class DateFromToRangeFilter(RangeFilter): + field_class: Any = ... + +class DateTimeFromToRangeFilter(RangeFilter): + field_class: Any = ... + +class IsoDateTimeFromToRangeFilter(RangeFilter): + field_class: Any = ... + +class TimeRangeFilter(RangeFilter): + field_class: Any = ... + +class AllValuesFilter(ChoiceFilter): + @property + def field(self): ... + +class AllValuesMultipleFilter(MultipleChoiceFilter): + @property + def field(self): ... + +class BaseCSVFilter(Filter): + base_field_class: Any = ... + field_class: Any = ... + def __init__(self, *args: Any, **kwargs: Any) -> None: ... + +class BaseInFilter(BaseCSVFilter): + def __init__(self, *args: Any, **kwargs: Any) -> None: ... + +class BaseRangeFilter(BaseCSVFilter): + base_field_class: Any = ... + def __init__(self, *args: Any, **kwargs: Any) -> None: ... + +class LookupChoiceFilter(Filter): + field_class: Any = ... + outer_class: Any = ... + empty_label: Any = ... + lookup_choices: Any = ... + def __init__( + self, + field_name: Optional[Any] = ..., + lookup_choices: Optional[Any] = ..., + field_class: Optional[Any] = ..., + **kwargs: Any + ) -> None: ... + @classmethod + def normalize_lookup(cls, lookup: Any): ... + def get_lookup_choices(self): ... + @property + def field(self): ... + lookup_expr: Any = ... + def filter(self, qs: Any, lookup: Any): ... + +class OrderingFilter(BaseCSVFilter, ChoiceFilter): + descending_fmt: Any = ... + param_map: Any = ... + def __init__(self, *args: Any, **kwargs: Any) -> None: ... + def get_ordering_value(self, param: Any): ... + def filter(self, qs: Any, value: Any): ... + @classmethod + def normalize_fields(cls, fields: Any): ... + def build_choices(self, fields: Any, labels: Any): ... + +class FilterMethod: + f: Any = ... + def __init__(self, filter_instance: Any) -> None: ... + def __call__(self, qs: Any, value: Any): ... + @property + def method(self): ... diff --git a/django_filters-stubs/filterset.pyi b/django_filters-stubs/filterset.pyi new file mode 100644 index 0000000..2484e07 --- /dev/null +++ b/django_filters-stubs/filterset.pyi @@ -0,0 +1,78 @@ +from typing import Any, Optional + +from .conf import settings +from .constants import ALL_FIELDS +from .filters import ( + BaseInFilter, + BaseRangeFilter, + BooleanFilter, + CharFilter, + ChoiceFilter, + DateFilter, + DateTimeFilter, + DurationFilter, + Filter, + ModelChoiceFilter, + ModelMultipleChoiceFilter, + NumberFilter, + TimeFilter, + UUIDFilter, +) +from .utils import get_all_model_fields, get_model_field, resolve_field, try_dbfield + +def remote_queryset(field: Any): ... + +class FilterSetOptions: + model: Any = ... + fields: Any = ... + exclude: Any = ... + filter_overrides: Any = ... + form: Any = ... + def __init__(self, options: Optional[Any] = ...) -> None: ... + +class FilterSetMetaclass(type): + def __new__(cls, name: Any, bases: Any, attrs: Any): ... + @classmethod + def get_declared_filters(cls, bases: Any, attrs: Any): ... + +FILTER_FOR_DBFIELD_DEFAULTS: Any + +class BaseFilterSet: + FILTER_DEFAULTS: Any = ... + is_bound: Any = ... + data: Any = ... + queryset: Any = ... + request: Any = ... + form_prefix: Any = ... + filters: Any = ... + def __init__( + self, + data: Optional[Any] = ..., + queryset: Optional[Any] = ..., + *, + request: Optional[Any] = ..., + prefix: Optional[Any] = ... + ) -> None: ... + def is_valid(self): ... + @property + def errors(self): ... + def filter_queryset(self, queryset: Any): ... + @property + def qs(self): ... + def get_form_class(self): ... + @property + def form(self): ... + @classmethod + def get_fields(cls): ... + @classmethod + def get_filter_name(cls, field_name: Any, lookup_expr: Any): ... + @classmethod + def get_filters(cls): ... + @classmethod + def filter_for_field(cls, field: Any, field_name: Any, lookup_expr: str = ...): ... + @classmethod + def filter_for_lookup(cls, field: Any, lookup_type: Any): ... + +class FilterSet(BaseFilterSet, metaclass=FilterSetMetaclass): ... + +def filterset_factory(model: Any, fields: Any = ...): ... diff --git a/django_filters-stubs/models.pyi b/django_filters-stubs/models.pyi new file mode 100644 index 0000000..e69de29 diff --git a/django_filters-stubs/rest_framework/__init__.pyi b/django_filters-stubs/rest_framework/__init__.pyi new file mode 100644 index 0000000..adb4752 --- /dev/null +++ b/django_filters-stubs/rest_framework/__init__.pyi @@ -0,0 +1,3 @@ +from .backends import DjangoFilterBackend as DjangoFilterBackend +from .filters import * +from .filterset import FilterSet as FilterSet diff --git a/django_filters-stubs/rest_framework/backends.pyi b/django_filters-stubs/rest_framework/backends.pyi new file mode 100644 index 0000000..f90fc30 --- /dev/null +++ b/django_filters-stubs/rest_framework/backends.pyi @@ -0,0 +1,26 @@ +from typing import Any, Optional + +from django.utils.deprecation import RenameMethodsBase + +from .. import compat as compat +from .. import utils as utils +from . import filters as filters +from . import filterset as filterset + +class RenameAttributes(utils.RenameAttributesBase, RenameMethodsBase): + renamed_attributes: Any = ... + renamed_methods: Any = ... + +class DjangoFilterBackend(metaclass=RenameAttributes): + filterset_base: Any = ... + raise_exception: bool = ... + @property + def template(self): ... + def get_filterset(self, request: Any, queryset: Any, view: Any): ... + def get_filterset_class(self, view: Any, queryset: Optional[Any] = ...): ... + def get_filterset_kwargs(self, request: Any, queryset: Any, view: Any): ... + def filter_queryset(self, request: Any, queryset: Any, view: Any): ... + def to_html(self, request: Any, queryset: Any, view: Any): ... + def get_coreschema_field(self, field: Any): ... + def get_schema_fields(self, view: Any): ... + def get_schema_operation_parameters(self, view: Any): ... diff --git a/django_filters-stubs/rest_framework/filters.pyi b/django_filters-stubs/rest_framework/filters.pyi new file mode 100644 index 0000000..0f279b1 --- /dev/null +++ b/django_filters-stubs/rest_framework/filters.pyi @@ -0,0 +1,37 @@ +from typing import Any + +from django_filters import filters + +class BooleanFilter(filters.BooleanFilter): + def __init__(self, *args: Any, **kwargs: Any) -> None: ... + +# Names in __all__ with no definition: +# AllValuesFilter +# AllValuesMultipleFilter +# BaseCSVFilter +# BaseInFilter +# BaseRangeFilter +# CharFilter +# ChoiceFilter +# DateFilter +# DateFromToRangeFilter +# DateRangeFilter +# DateTimeFilter +# DateTimeFromToRangeFilter +# DurationFilter +# Filter +# IsoDateTimeFilter +# IsoDateTimeFromToRangeFilter +# LookupChoiceFilter +# ModelChoiceFilter +# ModelMultipleChoiceFilter +# MultipleChoiceFilter +# NumberFilter +# NumericRangeFilter +# OrderingFilter +# RangeFilter +# TimeFilter +# TimeRangeFilter +# TypedChoiceFilter +# TypedMultipleChoiceFilter +# UUIDFilter diff --git a/django_filters-stubs/rest_framework/filterset.pyi b/django_filters-stubs/rest_framework/filterset.pyi new file mode 100644 index 0000000..cef1f07 --- /dev/null +++ b/django_filters-stubs/rest_framework/filterset.pyi @@ -0,0 +1,10 @@ +from typing import Any + +from django_filters import filterset as filterset + +FILTER_FOR_DBFIELD_DEFAULTS: Any + +class FilterSet(filterset.FilterSet): + FILTER_DEFAULTS: Any = ... + @property + def form(self): ... diff --git a/django_filters-stubs/utils.pyi b/django_filters-stubs/utils.pyi new file mode 100644 index 0000000..618f72d --- /dev/null +++ b/django_filters-stubs/utils.pyi @@ -0,0 +1,29 @@ +from typing import Any, Optional + +from .exceptions import FieldLookupError as FieldLookupError + +def deprecate(msg: Any, level_modifier: int = ...) -> None: ... + +class MigrationNotice(DeprecationWarning): + url: str = ... + def __init__(self, message: Any) -> None: ... + +class RenameAttributesBase(type): + renamed_attributes: Any = ... + def __new__(metacls: Any, name: Any, bases: Any, attrs: Any): ... + def get_name(metacls: Any, name: Any): ... + def __getattr__(metacls: Any, name: Any): ... + def __setattr__(metacls: Any, name: Any, value: Any): ... + +def try_dbfield(fn: Any, field_class: Any): ... +def get_all_model_fields(model: Any): ... +def get_model_field(model: Any, field_name: Any): ... +def get_field_parts(model: Any, field_name: Any): ... +def resolve_field(model_field: Any, lookup_expr: Any): ... +def handle_timezone(value: Any, is_dst: Optional[Any] = ...): ... +def verbose_field_name(model: Any, field_name: Any): ... +def verbose_lookup_expr(lookup_expr: Any): ... +def label_for_filter( + model: Any, field_name: Any, lookup_expr: Any, exclude: bool = ... +): ... +def translate_validation(error_dict: Any): ... diff --git a/django_filters-stubs/views.pyi b/django_filters-stubs/views.pyi new file mode 100644 index 0000000..57c6526 --- /dev/null +++ b/django_filters-stubs/views.pyi @@ -0,0 +1,42 @@ +from typing import Any, Optional + +from django.views.generic import View +from django.views.generic.list import ( + MultipleObjectMixin, + MultipleObjectTemplateResponseMixin, +) + +from .constants import ALL_FIELDS as ALL_FIELDS +from .filterset import filterset_factory as filterset_factory +from .utils import MigrationNotice as MigrationNotice +from .utils import RenameAttributesBase as RenameAttributesBase + +class FilterMixinRenames(RenameAttributesBase): + renamed_attributes: Any = ... + +class FilterMixin(metaclass=FilterMixinRenames): + filterset_class: Any = ... + filterset_fields: Any = ... + strict: bool = ... + def get_filterset_class(self): ... + def get_filterset(self, filterset_class: Any): ... + def get_filterset_kwargs(self, filterset_class: Any): ... + def get_strict(self): ... + +class BaseFilterView(FilterMixin, MultipleObjectMixin, View): + filterset: Any = ... + object_list: Any = ... + def get(self, request: Any, *args: Any, **kwargs: Any): ... + +class FilterView(MultipleObjectTemplateResponseMixin, BaseFilterView): + template_name_suffix: str = ... + +def object_filter( + request: Any, + model: Optional[Any] = ..., + queryset: Optional[Any] = ..., + template_name: Optional[Any] = ..., + extra_context: Optional[Any] = ..., + context_processors: Optional[Any] = ..., + filter_class: Optional[Any] = ..., +): ... diff --git a/django_filters-stubs/widgets.pyi b/django_filters-stubs/widgets.pyi new file mode 100644 index 0000000..a6ff349 --- /dev/null +++ b/django_filters-stubs/widgets.pyi @@ -0,0 +1,75 @@ +from typing import Any, Dict, Optional, Tuple + +from django import forms +from django.forms.renderers import EngineMixin +from django.utils.safestring import SafeText + +_OptAttrs = Dict[str, Any] + +class LinkWidget(forms.Widget): + choices: Any = ... + def __init__(self, attrs: Optional[Any] = ..., choices: Any = ...) -> None: ... + data: Any = ... + def value_from_datadict(self, data: Any, files: Any, name: Any): ... + def render( + self, + name: str, + value: Any, + attrs: Optional[_OptAttrs] = ..., + choices: Tuple = ..., + renderer: Optional[EngineMixin] = ..., + ) -> SafeText: ... + def render_options(self, choices: Any, selected_choices: Any, name: Any): ... + def render_option( + self, name: Any, selected_choices: Any, option_value: Any, option_label: Any + ): ... + def option_string(self): ... + +class SuffixedMultiWidget(forms.MultiWidget): + suffixes: Any = ... + def __init__(self, *args: Any, **kwargs: Any) -> None: ... + def suffixed(self, name: Any, suffix: Any): ... + def get_context(self, name: Any, value: Any, attrs: Any): ... + def value_from_datadict(self, data: Any, files: Any, name: Any): ... + def value_omitted_from_data(self, data: Any, files: Any, name: Any): ... + def replace_name(self, output: Any, index: Any): ... + def decompress(self, value: Any): ... + +class RangeWidget(SuffixedMultiWidget): + template_name: str = ... + suffixes: Any = ... + def __init__(self, attrs: Optional[Any] = ...) -> None: ... + def decompress(self, value: Any): ... + +class DateRangeWidget(RangeWidget): + suffixes: Any = ... + +class LookupChoiceWidget(SuffixedMultiWidget): + suffixes: Any = ... + def decompress(self, value: Any): ... + +class BooleanWidget(forms.Select): + def __init__(self, attrs: Optional[Any] = ...) -> None: ... + def render( + self, + name: Any, + value: Any, + attrs: Optional[Any] = ..., + renderer: Optional[Any] = ..., + ): ... + def value_from_datadict(self, data: Any, files: Any, name: Any): ... + +class BaseCSVWidget(forms.Widget): + def value_from_datadict(self, data: Any, files: Any, name: Any): ... + def render( + self, + name: Any, + value: Any, + attrs: Optional[Any] = ..., + renderer: Optional[Any] = ..., + ): ... + +class CSVWidget(BaseCSVWidget, forms.TextInput): ... + +class QueryArrayWidget(BaseCSVWidget, forms.TextInput): + def value_from_datadict(self, data: Any, files: Any, name: Any): ... diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..82093f9 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,26 @@ +[tool:pytest] +testpaths=./tests +addopts = + --tb=native + --cache-clear + --mypy-ini-file=setup.cfg + +[isort] +multi_line_output = 3 +include_trailing_comma = true +line_length = 88 + +[flake8] +max-line-length=88 +extend-ignore=E203 + +[mypy] +ignore_missing_imports=True +check_untyped_defs=True +plugins= + mypy_django_plugin.main, + mypy_drf_plugin.main +strict_optional=True + +[mypy.plugins.django-stubs] +django_settings_module=tests.django_filters_test_settings \ No newline at end of file diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..eb1da85 --- /dev/null +++ b/setup.py @@ -0,0 +1,41 @@ +import os + +from setuptools import setup + +name = "django-filter-stubs" + + +def find_stub_files(name): + result = [] + for root, dirs, files in os.walk(name): + for f in files: + if f.endswith(".pyi"): + if os.path.sep in root: + sub_root = root.split(os.path.sep, 1)[-1] + f = os.path.join(sub_root, f) + result.append(f) + return result + + +setup( + name="django-filter-stubs", + version="0.1.0", + description="PEP-484 stubs for django-filter", + license="MIT", + url="https://github.com/DavisRayM/django-filter-stubs", + author="Davis Raymond Muro", + author_email="davisraymondmuro@outlook.com", + packages=['django_filters-stubs'], + package_data={"django_filters-stubs": find_stub_files('django_filters-stubs')}, + install_requires=[ + "mypy>=0.750", + "django-stubs>=1.3.0", + "djangorestframework-stubs>=0.4.0" "typing-extensions>=3.7.4", + ], + classifiers=[ + "Development Status :: 1 - Planning", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + ], +) diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/django_filters_test_settings.py b/tests/django_filters_test_settings.py new file mode 100644 index 0000000..029adfd --- /dev/null +++ b/tests/django_filters_test_settings.py @@ -0,0 +1,12 @@ +SECRET_KEY = "Not so secret" +SITE_ID = "1" + +INSTALLED_APPS = [ + "django.contrib.contenttypes", + "django.contrib.sites", + "django.contrib.sessions", + "django.contrib.messages", + "django.contrib.admin.apps.SimpleAdminConfig", + "django.contrib.staticfiles", + "django.contrib.auth", +] diff --git a/tests/test_imports.yml b/tests/test_imports.yml new file mode 100644 index 0000000..5753ddc --- /dev/null +++ b/tests/test_imports.yml @@ -0,0 +1,18 @@ +- case: imports_typecheck + main: | + import django_filters.compat + import django_filters.conf + import django_filters.constants + import django_filters.exceptions + import django_filters.fields + import django_filters.filters + import django_filters.filterset + import django_filters.models + import django_filters.utils + import django_filters.views + import django_filters.widgets + import django_filters.rest_framework.backends + import django_filters.rest_framework.filters + import django_filters.rest_framework.filterset + out: | + ../../home/travis/build/DavisRayM/django-filter-stubs/django_filters-stubs/widgetsi:14: error: Signature of "render" incompatible with supertype "Widget" \ No newline at end of file