-
Notifications
You must be signed in to change notification settings - Fork 5
Conversation
@@ -2,6 +2,8 @@ ARG python_base_image_tag | |||
FROM python:${python_base_image_tag} | |||
RUN pip install --no-cache-dir --only-binary --upgrade pipenv | |||
|
|||
RUN apk --no-cache add linux-headers g++ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to check whether that can be reduced more
project_tests.sh
Outdated
|
||
set -e | ||
|
||
pylint content_store/api/*.py |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be more generic (but pylint content_store
doesn't work because of it not containing an __init__.py
file)
|
||
[BASIC] | ||
good-names= | ||
id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if id
is actually a good name, given that it's also a built-in function
.pylintrc
Outdated
@@ -0,0 +1,14 @@ | |||
[MESSAGES CONTROL] | |||
disable= | |||
fixme, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might remove fixme
later - we have a TODO in there; probably should not keep TODOs in the code
.pylintrc
Outdated
[MESSAGES CONTROL] | ||
disable= | ||
fixme, | ||
missing-docstring, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better to structure the code in a read-able way and add high-level documentation
.pylintrc
Outdated
disable= | ||
fixme, | ||
missing-docstring, | ||
too-few-public-methods |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better to separate code logically, even if one module ends up having only one public method for now
@@ -0,0 +1 @@ | |||
# for pylint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm proposing to just add the __init__.py
files rather than messing around with an untidy pylint workaround.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
|
||
# TODO : add migrations | ||
# database setup (will use migration in the future) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reworded to not require fixme
pylint exception
|
||
# could move to blueprint | ||
@app.route("/ping") | ||
def ping(): | ||
def _ping(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with the underscore pylint won't complain about the function not being used (seems to be a common pattern)
project_tests.sh
Outdated
@@ -0,0 +1,6 @@ | |||
#!/bin/sh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm using the project_tests.sh
file also directly (without docker); it's faster than waiting for the docker build and then run the tests within it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naming format, want to uniform to project-tests.sh
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed (didn't realise you did adopt the hyphen in the end)
@@ -2,6 +2,8 @@ ARG python_base_image_tag | |||
FROM python:${python_base_image_tag} | |||
RUN pip install --no-cache-dir --only-binary --upgrade pipenv | |||
|
|||
RUN apk --no-cache add linux-headers g++ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pylint (or one of its dependencies) requires a C++ compiler for the Python package to be installed? At least it doesn't need to be carried over to the main image
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've seen pylint-dev/pylint#1423 for example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I encountered it in typed_ast
(ast27/Parser/acceler.c
). I guess it kind of makes sense that dependencies use native code to make bottlenecks faster.
project_tests.sh
Outdated
|
||
set -e | ||
|
||
pytest && \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
python -m pytest
is usually different from pytest
as it adds .
to PYTHONPATH
. In the container this is probably not that useful as we can set that env variable in the Dockerfile; what about on the host?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not know that. Where do you see that it's different? For me the script is just calling pytest.main, as seem to be the case when when running it as a module too. So not sure where it is adding it to the path.
Although I did see a difference when calling pytest
without the __init__.py
in tests
then it failing to find content_store
, but it seems to work with python -m pyest
. Its working with both commands if there is a __init__.py
file in tests
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Long story at https://docs.pytest.org/en/latest/pythonpath.html but if it works, good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will try this out after the schema meeting
Pipfile
Outdated
@@ -5,6 +5,7 @@ name = "pypi" | |||
|
|||
[dev-packages] | |||
pytest = "~=3.7.1" | |||
pylint = "*" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Specify at least the major version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, added. Even though it doesn't seem to be common practise for pipenv.
Apparently that is coming out of pipenv:
We recommend updating your Pipfile to specify the "*" version, instead.
The documentation isn't as clear about it apart from assuming that fixed versions come from the requirements.txt.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The lock file deals with the exact version separately, but a major version here (can't see it at the moment?) should be handy as if we run an upgrade we don't want to end up with an hypothetical future Pylint 3 that has introduced backward-incompatible changes like a different format for .pylintrc
, etc.
I understand that people importing a requirements.txt
will end up with things like 1.2.3.4rc2_0ubuntu1
which is brittle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I accidentally put it on the wrong dependency (fixed).
I understand reasons for add a major version.
But we should be aware that it does seem to be against the advice of pipenv
.
@@ -1,2 +1,3 @@ | |||
from flask_sqlalchemy import SQLAlchemy | |||
db = SQLAlchemy() | |||
|
|||
DB = SQLAlchemy() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct, module-level constant needs to be uppercase
project-tests.sh
Outdated
|
||
set -e | ||
|
||
export PYTHONOPTIMIZE= |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs a comment on why it's disabled. Related to creation of .pyc
/.pyo
files? Strips comments that Pylint needs?
.gitignore
Outdated
@@ -124,3 +124,6 @@ pip-selfcheck.json | |||
|
|||
|
|||
# End of https://www.gitignore.io/api/python | |||
|
|||
# IDEs | |||
.vscode/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be better suited to a global .gitignore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments on versioning, documentation. The changes enforced by Pylint look benign so far. Needs a merge of master
if not done recently.
Still up-to-date with master. Would be good to get this merged. |
@@ -0,0 +1,2 @@ | |||
**/*.pyc | |||
**/*.pyo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I always have to lookup this format, it works
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice if they could just use the .gitignore
format, and perhaps by default also use .gitignore
(but I am sure there are many reasons against that idea).
Pipfile
Outdated
@@ -5,6 +5,7 @@ name = "pypi" | |||
|
|||
[dev-packages] | |||
pytest = "~=3.7.1" | |||
pylint = "2.*" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pkg_resources.extern.packaging.requirements.InvalidRequirement: Invalid requirement, parse error at "'.*'"
I think you need to use ~=2.1
which means >= 2.1, < 3.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, should have run pipenv lock
as the docker build is ignoring the file. That's fixed now as well. (also updated the lock)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only missing the correction to the pylint version, then we can merge
Issue: libero/publisher#35
There are some pylint issues with implicit namespace packages:
I'm proposing to just add the
__init__.py
files for now.I am planning to create separate PRs for other code checking tools.