Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run ruff on codebase #468

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion conftest.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
collect_ignore = ['integration']
collect_ignore = ["integration"]
43 changes: 18 additions & 25 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,25 @@

# flake8: noqa W191

extensions = [
'sphinx.ext.autodoc',
'jaraco.packaging.sphinx',
'rst.linker',
]
extensions = ["sphinx.ext.autodoc", "jaraco.packaging.sphinx", "rst.linker"]

master_doc = 'index'
master_doc = "index"

link_files = {
'../CHANGES.rst': dict(
using=dict(
GH='https://github.com',
),
replace=[
dict(
pattern=r'(Issue )?#(?P<issue>\d+)',
url='{package_url}/issues/{issue}',
),
dict(
pattern=r'^(?m)((?P<scm_version>v?\d+(\.\d+){1,2}))\n[-=]+\n',
with_scm='{text}\n{rev[timestamp]:%d %b %Y}\n',
),
dict(
pattern=r'PEP[- ](?P<pep_number>\d+)',
url='https://www.python.org/dev/peps/pep-{pep_number:0>4}/',
),
],
),
"../CHANGES.rst": dict(
using=dict(GH="https://github.com"),
replace=[
dict(
pattern=r"(Issue )?#(?P<issue>\d+)", url="{package_url}/issues/{issue}"
),
dict(
pattern=r"^(?m)((?P<scm_version>v?\d+(\.\d+){1,2}))\n[-=]+\n",
with_scm="{text}\n{rev[timestamp]:%d %b %Y}\n",
),
dict(
pattern=r"PEP[- ](?P<pep_number>\d+)",
url="https://www.python.org/dev/peps/pep-{pep_number:0>4}/",
),
],
)
}
120 changes: 52 additions & 68 deletions integration/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,79 +12,64 @@ def setUp(self):
username = os.environ["SCRUNCH_USER"]
password = os.environ["SCRUNCH_PASS"]
self.site = connect(username, password, self.host)
assert (self
.site is not None), "Unable to connect to %s" % self.host
assert self.site is not None, "Unable to connect to %s" % self.host


# These are the categories that multiple response use. Selected and Not Selected
MR_CATS = [
{"id": 1, "name": "Selected", "missing": False, "numeric_value": None, "selected": True},
{"id": 3, "name": "Other Selected", "missing": False, "numeric_value": None, "selected": True},
{"id": 2, "name": "Not selected", "missing": False, "numeric_value": None, "selected": False}
{
"id": 1,
"name": "Selected",
"missing": False,
"numeric_value": None,
"selected": True,
},
{
"id": 3,
"name": "Other Selected",
"missing": False,
"numeric_value": None,
"selected": True,
},
{
"id": 2,
"name": "Not selected",
"missing": False,
"numeric_value": None,
"selected": False,
},
]

NEWS_DATASET = {
"caseid": {
"name": "Case ID",
"type": "numeric"
},
"age": {
"name": "Age",
"type": 'numeric',
},
"caseid": {"name": "Case ID", "type": "numeric"},
"age": {"name": "Age", "type": "numeric"},
"newssource": {
"name": "News source",
"type": "multiple_response",
"categories": MR_CATS,
"subreferences": [{
"name": "Facebook",
"alias": "newssource_1"
}, {
"name": "Twitter",
"alias": "newssource_2"
}, {
"name": "Google news",
"alias": "newssource_3"
}, {
"name": "Reddit",
"alias": "newssource_4"
}, {
"name": "NY Times (Print)",
"alias": "newssource_5"
}, {
"name": "Washington Post (Print)",
"alias": "newssource_6"
}, {
"name": "NBC News",
"alias": "newssource_7"
}, {
"name": "NPR",
"alias": "newssource_8"
}, {
"name": "Fox",
"alias": "newssource_9"
}, {
"name": "Local radio",
"alias": "newssource_10"
}]
"subreferences": [
{"name": "Facebook", "alias": "newssource_1"},
{"name": "Twitter", "alias": "newssource_2"},
{"name": "Google news", "alias": "newssource_3"},
{"name": "Reddit", "alias": "newssource_4"},
{"name": "NY Times (Print)", "alias": "newssource_5"},
{"name": "Washington Post (Print)", "alias": "newssource_6"},
{"name": "NBC News", "alias": "newssource_7"},
{"name": "NPR", "alias": "newssource_8"},
{"name": "Fox", "alias": "newssource_9"},
{"name": "Local radio", "alias": "newssource_10"},
],
},
"socialmedia": {
"name": "Accounts in social media",
"type": "multiple_response",
"categories": MR_CATS,
"subreferences": [{
"name": "Facebook",
"alias": "socialmedia_1"
}, {
"name": "Twitter",
"alias": "socialmedia_2"
}, {
"name": "Google+",
"alias": "socialmedia_3"
}, {
"name": "VK",
"alias": "socialmedia_4"
}]
"subreferences": [
{"name": "Facebook", "alias": "socialmedia_1"},
{"name": "Twitter", "alias": "socialmedia_2"},
{"name": "Google+", "alias": "socialmedia_3"},
{"name": "VK", "alias": "socialmedia_4"},
],
},
"gender": {
"name": "Gender",
Expand All @@ -93,8 +78,8 @@ def setUp(self):
{"id": 1, "name": "Female", "missing": False, "numeric_value": None},
{"id": 2, "name": "Male", "missing": False, "numeric_value": None},
{"id": -1, "name": "No Data", "missing": True, "numeric_value": None},
]
}
],
},
}

RECODES_CSV_OUTPUT = """newssource_1,newssource_2,newssource_3,newssource_4,newssource_5,newssource_6,newssource_7,newssource_8,newssource_9,newssource_10,age,socialmedia_1,socialmedia_2,socialmedia_3,socialmedia_4,caseid,gender,agerange,origintype_1,origintype_2,origintype_3,origintype_4,origintype_copy_1,origintype_copy_2,origintype_copy_3,origintype_copy_4,onlinenewssource_1,onlinenewssource_2,over35
Expand Down Expand Up @@ -122,7 +107,7 @@ def setUp(self):
"socialmedia_2": [1, 2, 1, 1, 2, 1, 2],
"socialmedia_3": [2, 2, 1, 2, 2, 1, 2],
"socialmedia_4": [2, 2, 1, 2, 2, 2, 2],
"gender": [1, 2, 2, 1, 1, 1, 2]
"gender": [1, 2, 2, 1, 1, 1, 2],
}


Expand All @@ -131,14 +116,13 @@ def mr_in(ds, mr_alias, subvars):
Temporary helper until scrunch can parse correctly the expression:
mr.has_any([sv1, sv2...])
"""
variables = ds.resource.variables.by('alias')
variables = ds.resource.variables.by("alias")
mr = variables[mr_alias].entity
subvariables = mr.subvariables.by('alias')
subvariables = mr.subvariables.by("alias")
return {
'function': 'any',
'args': [{
'variable': mr.self
}, {
'column': [subvariables[subvar_alias(mr_alias, sv)].id for sv in subvars]
}]
"function": "any",
"args": [
{"variable": mr.self},
{"column": [subvariables[subvar_alias(mr_alias, sv)].id for sv in subvars]},
],
}
1 change: 0 additions & 1 deletion integration/test_accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@


class TestAccount(BaseIntegrationTestCase):

def test_current_account(self):
act = Account.current_account(self.site)
assert act.resource.self == self.site.account.self
Expand Down
Loading
Loading