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

Moving to Py3 #550

Merged
merged 18 commits into from
Feb 10, 2020
Merged

Moving to Py3 #550

merged 18 commits into from
Feb 10, 2020

Conversation

iambibhas
Copy link
Contributor

@iambibhas iambibhas commented Dec 6, 2019

Related to hasgeek/hgapp#39

Check the commits for easy review. One commit has only 2to3 changes, rest have changes needed specifically to run under py3.

@iambibhas iambibhas requested a review from jace December 6, 2019 04:02
Copy link
Member

@jace jace left a comment

Choose a reason for hiding this comment

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

  1. We can't replace __ with _. A solution for that has to be found.
  2. Seemingly spurious insertions of list() wrappers. Some are necessary. Others are likely not.

@@ -24,7 +24,7 @@ class CampaignContentForm(forms.Form):
validators=[forms.validators.Optional(), forms.validators.AllUrlsValid()])
banner_image = forms.URLField(__("Banner image URL"), validators=[forms.validators.Optional()], # TODO: Use ImgeeField
description=__("An image to illustrate your campaign"))
banner_location = forms.RadioField(__("Banner location"), choices=BANNER_LOCATION.items(), coerce=int,
banner_location = forms.RadioField(__("Banner location"), choices=list(BANNER_LOCATION.items()), coerce=int,
Copy link
Member

Choose a reason for hiding this comment

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

In this case, list() is necessary as we are replacing a frame object with a list.

@@ -18,7 +18,7 @@ def format_geonameids(geonameids):

def get_currency_choices():
choices = [('', __('None'))]
choices.extend(CURRENCY.items())
choices.extend(list(CURRENCY.items()))
Copy link
Member

Choose a reason for hiding this comment

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

I think this will work without the list().

@@ -6,7 +6,7 @@
from coaster.db import db
from coaster.sqlalchemy import (BaseMixin, BaseNameMixin, TimestampMixin, BaseScopedIdMixin,
BaseScopedNameMixin, CoordinatesMixin, make_timestamp_columns)
from baseframe import __
from baseframe import _
Copy link
Member

Choose a reason for hiding this comment

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

Should remain __.

@@ -8,7 +8,7 @@
from flask import request, Markup
from coaster.utils import LabeledEnum, utcnow
from coaster.sqlalchemy import JsonDict, StateManager, cached
from baseframe import __
from baseframe import _
Copy link
Member

Choose a reason for hiding this comment

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

Should remain __.

@@ -301,7 +301,7 @@ def for_context(cls, position, board=None, user=None, anon_user=None, geonameids
db.or_(CampaignView.dismissed == True, CampaignView.session_count > 2)))) # NOQA

# Filter by user flags
for flag, value in user.flags.items():
for flag, value in list(user.flags.items()):
Copy link
Member

Choose a reason for hiding this comment

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

Should work without list()

@@ -253,7 +254,7 @@ def record_views_and_events(response):
g.event_data['user_geonameids'] = g.user_geonameids

if g.impressions:
g.event_data['impressions'] = g.impressions.values()
g.event_data['impressions'] = list(g.impressions.values())
Copy link
Member

Choose a reason for hiding this comment

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

Required.

@@ -294,7 +295,7 @@ def record_views_and_events(response):
db.session.rollback()

if g.impressions:
save_impressions.queue(g.esession.id, g.impressions.values(), now)
save_impressions.queue(g.esession.id, list(g.impressions.values()), now)
Copy link
Member

Choose a reason for hiding this comment

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

Required.

@@ -317,7 +318,7 @@ def session_jobpost_ab():
in the current event session (impressions or views) as a dictionary of {id: bgroup}
"""
if not g.esession.persistent:
return {key: value[2] for key, value in session.get('impressions', {}).items()}
return {key: value[2] for key, value in list(session.get('impressions', {}).items())}
Copy link
Member

Choose a reason for hiding this comment

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

Not required.

@@ -434,7 +435,7 @@ def load_viewcounts(posts):
values = redis_pipe.execute()
viewcounts_values = values[:-1]
maxcounts_values = values[-1]
g.viewcounts = dict(zip(viewcounts_keys, viewcounts_values))
g.viewcounts = dict(list(zip(viewcounts_keys, viewcounts_values)))
Copy link
Member

Choose a reason for hiding this comment

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

Questionable, but list() is likely not required.

requirements.txt Outdated
@@ -13,7 +13,6 @@ SQLAlchemy>=1.0.0
pytz==2019.3
markdown==3.1.1
tweepy==3.8.0
bitlyapi==0.1.1
Copy link
Member

Choose a reason for hiding this comment

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

Is this unsupported? Remove in a prior PR as it's also unused.

Copy link
Member

@jace jace left a comment

Choose a reason for hiding this comment

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

All enums that went from __ to _ have to be reverted.

hasjob/models/campaign.py Outdated Show resolved Hide resolved
@iambibhas iambibhas merged commit 4ccdff8 into master Feb 10, 2020
@iambibhas iambibhas deleted the py3 branch February 10, 2020 15:14
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.

2 participants