Skip to content

Commit aac0e02

Browse files
jerjouJon Wayne Parrott
authored and
Jon Wayne Parrott
committed
Revert & fix "Revert "Lint session should check all changed files. (#… (GoogleCloudPlatform#621)
* Lint session should check all changed files. * Fix lint errors.
1 parent 7193d1e commit aac0e02

File tree

6 files changed

+28
-15
lines changed

6 files changed

+28
-15
lines changed

appengine/flexible/django_cloudsql/mysite/settings.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,9 @@
8686
# In the flexible environment, you connect to CloudSQL using a unix socket.
8787
# Locally, you can use the CloudSQL proxy to proxy a localhost connection
8888
# to the instance
89-
DATABASES['default']['HOST'] = '/cloudsql/<your-cloudsql-connection-string>'
89+
DATABASES['default']['HOST'] = '/cloudsql/<your-cloudsql-connection-string>'
9090
if os.getenv('GAE_APPENGINE_HOSTNAME'):
91+
pass
9192
else:
9293
DATABASES['default']['HOST'] = '127.0.0.1'
9394
# [END dbconfig]

appengine/flexible/django_cloudsql/mysite/urls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
from django.conf import settings
1516
from django.conf.urls import include, url
1617
from django.contrib import admin
1718
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
18-
from django.conf import settings
1919

2020
urlpatterns = [url(r'^', include('polls.urls')),
2121
url(r'^admin/', admin.site.urls)]

appengine/standard/angular/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414

1515
import json
1616

17-
import model
18-
1917
import webapp2
2018

19+
import model
20+
2121

2222
def AsDict(guest):
2323
return {'id': guest.key.id(), 'first': guest.first, 'last': guest.last}

appengine/standard/i18n/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
For more information, see README.md
2121
"""
2222

23-
from i18n_utils import BaseHandler
24-
2523
import webapp2
2624

25+
from i18n_utils import BaseHandler
26+
2727

2828
class MainHandler(BaseHandler):
2929
"""A simple handler with internationalized strings.

container_engine/django_tutorial/polls/migrations/0001_initial.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,29 @@ class Migration(migrations.Migration):
1717
migrations.CreateModel(
1818
name='Choice',
1919
fields=[
20-
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
20+
('id', models.AutoField(
21+
auto_created=True, primary_key=True, serialize=False,
22+
verbose_name='ID')),
2123
('choice_text', models.CharField(max_length=200)),
2224
('votes', models.IntegerField(default=0)),
2325
],
2426
),
2527
migrations.CreateModel(
2628
name='Question',
2729
fields=[
28-
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
30+
('id', models.AutoField(
31+
auto_created=True, primary_key=True, serialize=False,
32+
verbose_name='ID')),
2933
('question_text', models.CharField(max_length=200)),
30-
('pub_date', models.DateTimeField(verbose_name=b'date published')),
34+
('pub_date', models.DateTimeField(
35+
verbose_name=b'date published')),
3136
],
3237
),
3338
migrations.AddField(
3439
model_name='choice',
3540
name='question',
36-
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='polls.Question'),
41+
field=models.ForeignKey(
42+
on_delete=django.db.models.deletion.CASCADE,
43+
to='polls.Question'),
3744
),
3845
]

nox.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ def list_files(folder, pattern):
6161
yield os.path.join(root, filename)
6262

6363

64-
def collect_sample_dirs(start_dir, blacklist=set()):
64+
def collect_sample_dirs(start_dir, blacklist=set(), suffix='_test.py'):
6565
"""Recursively collects a list of dirs that contain tests.
6666
6767
This works by listing the contents of directories and finding
6868
directories that have `*_test.py` files.
6969
"""
7070
# Collect all the directories that have tests in them.
7171
for parent, subdirs, files in os.walk(start_dir):
72-
if any(f for f in files if f[-8:] == '_test.py'):
72+
if any(f for f in files if f.endswith(suffix) and f not in blacklist):
7373
# Don't recurse further, since py.test will do that.
7474
del subdirs[:]
7575
# This dir has tests in it. yield it.
@@ -240,9 +240,14 @@ def session_lint(session):
240240
"""Lints each sample."""
241241
sample_directories = session.posargs
242242
if not sample_directories:
243-
sample_directories = collect_sample_dirs('.')
244-
245-
# On travis, on lint changed samples.
243+
# The top-level dir isn't a sample dir - only its subdirs.
244+
_, subdirs, _ = next(os.walk('.'))
245+
sample_directories = (
246+
sample_dir for subdir in subdirs if not subdir.startswith('.')
247+
for sample_dir in collect_sample_dirs(
248+
subdir, suffix='.py', blacklist='conftest.py'))
249+
250+
# On travis, only lint changed samples.
246251
if ON_TRAVIS:
247252
changed_files = get_changed_files()
248253
sample_directories = filter_samples(

0 commit comments

Comments
 (0)