Skip to content

Commit 68cfa7c

Browse files
authored
Merge branch 'qat' into ftr/dev-13727-file-c-duckdb
2 parents bcfab0f + 7577cfd commit 68cfa7c

File tree

9 files changed

+1490
-398
lines changed

9 files changed

+1490
-398
lines changed

pyproject.toml

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ readme = 'README.md'
1313
license = "CC0-1.0"
1414
license-files = ["LICENSE"]
1515
requires-python = '>=3.10'
16-
classifiers=[
16+
classifiers = [
1717
"Development Status :: 5 - Production/Stable",
1818
"Programming Language :: Python",
1919
"Programming Language :: Python :: 3",
@@ -137,14 +137,13 @@ DJANGO_SETTINGS_MODULE = "usaspending_api.settings"
137137
addopts = "--cov=usaspending_api"
138138
markers = [
139139
"signal_handling: Mark all tests that import the signal library and invoke signals. This MUST be done on the main thread, and can cause errors if pytest-xdist subordinates parellel test sessions to background threads.",
140-
141140
# These are "auto" marked based on fixture usage. See conftest.py pytest_collection_modifyitems
142141
"spark: Mark all tests using the spark fixture. Can be selected with -m spark or deselected with -m (not spark)",
143142
"database: Mark all integration tests using a database. Can be selected with -m database or deselected with -m (not database)",
144143
"elasticsearch: Mark all integration tests using Elasticsearch. Can be selected with -m database or deselected with -m (not elasticsearch)",
145144
]
146145
pythonpath = [
147-
"."
146+
"."
148147
]
149148

150149
[tool.coverage.run]
@@ -174,25 +173,25 @@ exclude = [
174173
]
175174

176175
select = [
177-
"PLR0913", # max arguments in function
178-
"PLR0904", # max number of public methods
179-
"PLR0911", # max number of return statements
180-
"PLR0916", # max number of boolean expressions
181-
"PLR0915", # max number of lines in a function
182-
"PLR0912", # max number of logical branches in a function
183-
"PLR1702", # max number of nested blocks
184-
"C901", # cognitive complexity (functions)
185-
"I001", # unsorted imports
186-
"B", # flake8 bugbear
187-
"E", # pycodestyle errors
188-
"F", # pyflakes
189-
"W", # pycodestyle warnings
190-
"ANN001", # missing type annotation for function argument
191-
"ANN201", # missing return type annotation for public function or method
192-
"ANN202", # missing return type annotation for private function or method
176+
"PLR0913", # max arguments in function
177+
"PLR0904", # max number of public methods
178+
"PLR0911", # max number of return statements
179+
"PLR0916", # max number of boolean expressions
180+
"PLR0915", # max number of lines in a function
181+
"PLR0912", # max number of logical branches in a function
182+
"PLR1702", # max number of nested blocks
183+
"C901", # cognitive complexity (functions)
184+
"I001", # unsorted imports
185+
"B", # flake8 bugbear
186+
"E", # pycodestyle errors
187+
"F", # pyflakes
188+
"W", # pycodestyle warnings
189+
"ANN001", # missing type annotation for function argument
190+
"ANN201", # missing return type annotation for public function or method
191+
"ANN202", # missing return type annotation for private function or method
193192
]
194193
ignore = [
195-
"E203", # whitespace before punctuation
194+
"E203", # whitespace before punctuation
196195
]
197196

198197
pylint.max-args = 6
@@ -207,16 +206,23 @@ pycodestyle.max-line-length = 120
207206

208207
[tool.ruff.lint.per-file-ignores]
209208
"**/tests/**/test*.py" = [
210-
"ANN001", # missing-type-function-argument; avoid conflict with fixtures
211-
"ANN201", # missing-return-type-undocumented-public-function; avoid conflict with test case return values
212-
"ANN202", # missing-return-type-undocumented-private-function; avoid conflict with test case return values
209+
"ANN001", # missing-type-function-argument; avoid conflict with fixtures
210+
"ANN201", # missing-return-type-undocumented-public-function; avoid conflict with test case return values
211+
"ANN202", # missing-return-type-undocumented-private-function; avoid conflict with test case return values
213212
"PLR0913", # too-many-arguments; avoid conflict with too many fixtures
214-
"PLR0915", # too-many-statements; avoid conflict with long fixtures
213+
"PLR0915", # too-many-statements; avoid conflict with long fixtures
215214
]
216215
"**/conftest*.py" = [
217-
"ANN001", # missing-type-function-argument; avoid conflict with fixtures
218-
"ANN201", # missing-return-type-undocumented-public-function; avoid conflict with test case return values
219-
"ANN202", # missing-return-type-undocumented-private-function; avoid conflict with test case return values
216+
"ANN001", # missing-type-function-argument; avoid conflict with fixtures
217+
"ANN201", # missing-return-type-undocumented-public-function; avoid conflict with test case return values
218+
"ANN202", # missing-return-type-undocumented-private-function; avoid conflict with test case return values
219+
"PLR0913", # too-many-arguments; avoid conflict with too many fixtures
220+
"PLR0915", # too-many-statements; avoid conflict with long fixtures
221+
]
222+
"**/tests/**/data/**.py" = [
223+
"ANN001", # missing-type-function-argument; avoid conflict with fixtures
224+
"ANN201", # missing-return-type-undocumented-public-function; avoid conflict with test case return values
225+
"ANN202", # missing-return-type-undocumented-private-function; avoid conflict with test case return values
220226
"PLR0913", # too-many-arguments; avoid conflict with too many fixtures
221-
"PLR0915", # too-many-statements; avoid conflict with long fixtures
227+
"PLR0915", # too-many-statements; avoid conflict with long fixtures
222228
]

usaspending_api/awards/v2/lookups/lookups.py

Lines changed: 62 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,11 @@
7272
**direct_payment_award_mapping,
7373
**other_award_mapping,
7474
}
75-
non_loan_assistance_award_mapping = {**grant_award_mapping, **direct_payment_award_mapping, **other_award_mapping}
75+
non_loan_assistance_award_mapping = {
76+
**grant_award_mapping,
77+
**direct_payment_award_mapping,
78+
**other_award_mapping,
79+
}
7680

7781
# TODO: include IDV mappings in the award_type_mapping and update award_filter.py
7882
award_type_mapping = {
@@ -105,9 +109,24 @@
105109
# 'F': 'Cooperative Agreement',
106110
# 'G': 'Grant for Research',
107111
# 'S': 'Funded Space Act Agreement',
108-
# 'T': 'Training Grant'
112+
# 'T': 'Training Grant',
113+
"F001": "Grant",
114+
"F002": "Cooperative Agreement",
115+
"F003": "Direct Loan",
116+
"F004": "Loan Guarantee",
117+
"F005": "Indemnity / Insurance (non-loan)",
118+
"F006": "Direct Payment for Specified Use",
119+
"F007": "Direct Payment with Unrestricted Use",
120+
"F008": "Asset Forfeiture / Equitable Sharing",
121+
"F009": "Sale, Exchange, or Donation of Property and Goods",
122+
"F010": "Other Financial Assistance",
123+
}
124+
contract_type_mapping = {
125+
"A": "BPA Call",
126+
"B": "Purchase Order",
127+
"C": "Delivery Order",
128+
"D": "Definitive Contract",
109129
}
110-
contract_type_mapping = {"A": "BPA Call", "B": "Purchase Order", "C": "Delivery Order", "D": "Definitive Contract"}
111130
idv_type_mapping = {
112131
"IDV_A": "GWAC Government Wide Acquisition Contract",
113132
"IDV_B": "IDC Multi-Agency Contract, Other Indefinite Delivery Contract",
@@ -118,18 +137,47 @@
118137
"IDV_D": "BOA Basic Ordering Agreement",
119138
"IDV_E": "BPA Blanket Purchase Agreement",
120139
}
121-
grant_type_mapping = {"02": "Block Grant", "03": "Formula Grant", "04": "Project Grant", "05": "Cooperative Agreement"}
122-
direct_payment_type_mapping = {"06": "Direct Payment for Specified Use", "10": "Direct Payment with Unrestricted Use"}
123-
loan_type_mapping = {"07": "Direct Loan", "08": "Guaranteed/Insured Loan"}
140+
grant_type_mapping = {
141+
"02": "Block Grant",
142+
"03": "Formula Grant",
143+
"04": "Project Grant",
144+
"05": "Cooperative Agreement",
145+
"F001": "Grant",
146+
"F002": "Cooperative Agreement",
147+
}
148+
direct_payment_type_mapping = {
149+
"06": "Direct Payment for Specified Use",
150+
"10": "Direct Payment with Unrestricted Use",
151+
"F006": "Direct Payment for Specified Use",
152+
"F007": "Direct Payment with Unrestricted Use",
153+
}
154+
loan_type_mapping = {
155+
"07": "Direct Loan",
156+
"08": "Guaranteed/Insured Loan",
157+
"F003": "Direct Loan",
158+
"F004": "Loan Guarantee",
159+
}
124160
# -1 is a derived type that we added as a "catch-all" for any invalid `type` values
125-
other_type_mapping = {"09": "Insurance", "11": "Other Financial Assistance", "-1": "Not Specified"}
161+
other_type_mapping = {
162+
"09": "Insurance",
163+
"11": "Other Financial Assistance",
164+
"-1": "Not Specified",
165+
"F005": "Indemnity / Insurance (non-loan)",
166+
"F008": "Asset Forfeiture / Equitable Sharing",
167+
"F009": "Sale, Exchange, or Donation of Property and Goods",
168+
"F010": "Other Financial Assistance",
169+
}
126170
assistance_type_mapping = {
127171
**grant_type_mapping,
128172
**direct_payment_type_mapping,
129173
**loan_type_mapping,
130174
**other_type_mapping,
131175
}
132-
non_loan_assistance_type_mapping = {**grant_type_mapping, **direct_payment_type_mapping, **other_type_mapping}
176+
non_loan_assistance_type_mapping = {
177+
**grant_type_mapping,
178+
**direct_payment_type_mapping,
179+
**other_type_mapping,
180+
}
133181
procurement_type_mapping = {**contract_type_mapping, **idv_type_mapping}
134182
all_award_types_mappings = {
135183
"contracts": list(contract_type_mapping),
@@ -141,9 +189,13 @@
141189
}
142190

143191
all_awards_types_to_category = {
144-
type_code: category for category, type_codes in all_award_types_mappings.items() for type_code in type_codes
192+
type_code: category
193+
for category, type_codes in all_award_types_mappings.items()
194+
for type_code in type_codes
145195
}
146196

147197
all_subaward_types = ["grant", "procurement"]
148198

149-
SUBAWARD_MAPPING_LOOKUP = {key: value.replace(".keyword", "") for key, value in subaward_mapping.items()}
199+
SUBAWARD_MAPPING_LOOKUP = {
200+
key: value.replace(".keyword", "") for key, value in subaward_mapping.items()
201+
}

usaspending_api/disaster/tests/integration/test_cfda_count.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,5 +91,5 @@ def test_invalid_award_type_codes(
9191
assert resp.status_code == status.HTTP_400_BAD_REQUEST
9292
assert (
9393
resp.data["detail"]
94-
== "Field 'filter|award_type_codes' is outside valid values ['-1', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11']"
94+
== "Field 'filter|award_type_codes' is outside valid values ['-1', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', 'F001', 'F002', 'F003', 'F004', 'F005', 'F006', 'F007', 'F008', 'F009', 'F010']" # noqa: E501
9595
)

usaspending_api/disaster/tests/integration/test_cfda_loans.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def test_invalid_award_type_codes(
219219

220220
resp = helpers.post_for_spending_endpoint(client, url, award_type_codes=["ZZ", "08"], def_codes=["L", "M"])
221221
assert resp.status_code == status.HTTP_400_BAD_REQUEST
222-
assert resp.data["detail"] == "Field 'filter|award_type_codes' is outside valid values ['07', '08']"
222+
assert resp.data["detail"] == "Field 'filter|award_type_codes' is outside valid values ['07', '08', 'F003', 'F004']"
223223

224224

225225
@pytest.mark.django_db

0 commit comments

Comments
 (0)