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

Sourcery refactored master branch #2758

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Sourcery refactored master branch #2758

wants to merge 3 commits into from

Conversation

sourcery-ai[bot]
Copy link
Contributor

@sourcery-ai sourcery-ai bot commented Sep 24, 2023

Branch master refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the master branch, then run:

git fetch origin sourcery/master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from ihongda September 24, 2023 07:55
Comment on lines -89 to +90
if __name__ == '__main__':
bottle.run(addr=args.addr, port=args.port)
if __name__ == '__main__':
bottle.run(addr=args.addr, port=args.port)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 89-90 refactored with the following changes:

server/api-tester/run-tests.py Show resolved Hide resolved
key = os.environ.get('PUBLISHABLE_KEY')
if key:
if key := os.environ.get('PUBLISHABLE_KEY'):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function StripePublicKey.get refactored with the following changes:

Comment on lines -1232 to +1231
hits = db.aql.execute(
if hits := db.aql.execute(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Redirect.get refactored with the following changes:

Comment on lines -96 to +90
if (
num_start <= doc['num_end']
and num_end >= doc['num_start']
or doc['num_start'] <= num_end
and doc['num_end'] >= num_start
):
if num_start <= doc['num_end'] and num_end >= doc['num_start']:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function UidMatcher.range_query refactored with the following changes:

Comment on lines -149 to +150
if lang['lang'] == original_lang:
result = '11111' # So that root language is always first.
else:
result = lang['lang']
if lang['segmented']:
result += '_0'
else:
result += '_1'
result = '11111' if lang['lang'] == original_lang else lang['lang']
result += '_0' if lang['segmented'] else '_1'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function language_sort refactored with the following changes:

This removes the following comments ( why? ):

# So that root language is always first.

Comment on lines -175 to +169
if x['type'] == 'full' and x['resembling']:
p_type = 'resembling'
else:
p_type = x['type']
p_type = 'resembling' if x['type'] == 'full' and x['resembling'] else x['type']
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function sort_parallels_type_key refactored with the following changes:

Comment on lines -191 to +182
r = list(itertools.islice(iterator, 0, chunk_size))
if r:
if r := list(itertools.islice(iterator, 0, chunk_size)):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function chunks refactored with the following changes:

(f'dn', 'an', 'sa', 'sa-2'),
('dn', 'an', 'sa', 'sa-2'),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 34-34 refactored with the following changes:

m = regex.search('[0-9]+$', from_uid)
if m:
from_nr = int(m[0])
else:
from_nr = 0
from_nr = int(m[0]) if (m := regex.search('[0-9]+$', from_uid)) else 0
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function generate_relationship_edges refactored with the following changes:

Comment on lines -12 to +20
name_data = []
for entry in data:
name_data.append(
{
'name': entry.pop('name'),
'symbol': entry['symbol'],
'lang': 'en',
'_key': f'{entry["symbol"]}_en',
}
)
name_data = [
{
'name': entry.pop('name'),
'symbol': entry['symbol'],
'lang': 'en',
'_key': f'{entry["symbol"]}_en',
}
for entry in data
]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function load_currencies refactored with the following changes:

Comment on lines -20 to +28
for item in content:
docs.append({
docs.extend(
{
'from': from_lang,
'to': to_lang,
'dictname': dict_name,
**item,
})

}
for item in content
)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function load_simple_dictionaries refactored with the following changes:

if lang == 'en':
return 'a', uid
else:
return lang, uid
return ('a', uid) if lang == 'en' else (lang, uid)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function sort_key refactored with the following changes:

Comment on lines -37 to +47

updates = []
num_en = num_strings_by_lang['en']

for iso_code, count in num_strings_by_lang.items():
updates.append(
{
'_key': iso_code,
'localized': True,
'localized_percent': int(100 * count / num_en),
}
)
num_en = num_strings_by_lang['en']

updates = [
{
'_key': iso_code,
'localized': True,
'localized_percent': int(100 * count / num_en),
}
for iso_code, count in num_strings_by_lang.items()
]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _update_languages refactored with the following changes:

Comment on lines -158 to +147
e = root.select_one('.publication-date')
if e:
if e := root.select_one('.publication-date'):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function TextInfoModel._get_publication_date refactored with the following changes:

Comment on lines -179 to +167
return right_side.text_content() + ' (' + left_side.text_content() + ')'
return f'{right_side.text_content()} ({left_side.text_content()})'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function TextInfoModel._get_name refactored with the following changes:

Comment on lines -192 to +180
return '{}'.format(e.attrib['id']).replace('t', 'T ')
return f"{e.attrib['id']}".replace('t', 'T ')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function TextInfoModel._get_volpage refactored with the following changes:

Comment on lines -335 to +337
match = regex.fullmatch(r'ms(\d+[A-Z][a-z]*\d*)_(\d+)', ref)
if match:
if match := regex.fullmatch(r'ms(\d+[A-Z][a-z]*\d*)_(\d+)', ref):
msbook, msnum = match.groups()
ms.append((msbook.lower(), int(msnum)))
continue

match = regex.fullmatch(r'(pts-vp-pli(?:[12]ed)?)(?:(\d+)\.)?(\d+)', ref)
if match:
if match := regex.fullmatch(
r'(pts-vp-pli(?:[12]ed)?)(?:(\d+)\.)?(\d+)', ref
):
pts_edition, vol, page = match.groups()
if pts_edition == 'pts-vp-pli':
pts_edition = 'pts-vp-pli1ed'
pts.append((pts_edition, vol, int(page)))
continue

match = regex.fullmatch(r'vnp(\d+)', ref)
if match:
if match := regex.fullmatch(r'vnp(\d+)', ref):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function PaliPageNumbinator.load refactored with the following changes:

Comment on lines -54 to -60
# filter out base class from results and get class object
migration_class = [
return [
migration_cls
for migration_cls in migration_classes
if migration_cls[0] != 'Migration'
][0][1]
return migration_class
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _import_migration_class refactored with the following changes:

This removes the following comments ( why? ):

# filter out base class from results and get class object

assert len(paths) != 0
assert paths
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_run_migrations_and_class_import refactored with the following changes:

Comment on lines 994 to 995
result = []
sentence_list = re.split(r'[.!?...]+', input_string)
for sentence in sentence_list:
if keyword in sentence:
result.append(sentence.strip())

return result
return [sentence.strip() for sentence in sentence_list if keyword in sentence]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function find_sentences_with_keyword refactored with the following changes:

Comment on lines 1051 to 1056
possible_uids = []
name_exclude_sutta = name
if 'sutta' in name:
name_exclude_sutta = name.replace('sutta', '').strip()

possible_uids.extend(list(db.aql.execute(POSSIBLE_SUTTA_BY_NAME, bind_vars={'name': name_exclude_sutta})))
possible_uids = list(
list(
db.aql.execute(
POSSIBLE_SUTTA_BY_NAME, bind_vars={'name': name_exclude_sutta}
)
)
)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function fetch_suttaplexs_by_name refactored with the following changes:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant