Skip to content

Conversation

@atodorov
Copy link
Contributor

Notes:

  1. The first commit will clash with the latest commit on top of master. I rewrote the commit for a shorter implementation and then realized we had already merged the earlier implementation.

  2. Take a look at the new way we apply transformations. I'm not quite certain this is what we need to be doing here but it fixed couple of failures, namely:
    https://travis-ci.org/PyCQA/pylint-django/builds/405211436
    func_noerror_model_fields and func_noerror_ugettext_lazy_format

@atodorov atodorov requested a review from carlio July 23, 2018 11:12
@atodorov
Copy link
Contributor Author

atodorov commented Jul 23, 2018

More notes:

For the failing test func_noerror_foreignkeys I see:

E           Failed: Wrong results for file "func_noerror_foreignkeys":
E           
E           Unexpected in testdata:
E             27: no-member

If I execute pylint-django only against this file everything seems fine:

$ PYTHONPATH=. pylint --load-plugins=pylint_django pylint_django/tests/input/func_noerror_foreignkeys.py 

--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)

I don't know what is going on here.

Update: this seems to work on Python 3.4 !!!!

@atodorov
Copy link
Contributor Author

Excluding the conflict I now have only 1 failing test. If I apply the following diff:

--- a/pylint_django/tests/test_func.py
+++ b/pylint_django/tests/test_func.py
@@ -43,6 +43,8 @@ def get_tests(input_dir='input', sort=False):
 
     suite = []
     for fname in os.listdir(input_dir):
+        if fname.find('func_noerror_foreign') == -1:
+            continue
         if fname != '__init__.py' and fname.endswith('.py'):
             suite.append(test_functional.FunctionalTestFile(input_dir, fname))

then I get only a subset of the tests executed (including the failing one) and this time it passes. This looks very strange.

@atodorov atodorov requested a review from PCManticore July 23, 2018 21:17
Copy link

@PCManticore PCManticore left a comment

Choose a reason for hiding this comment

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

This change looks sane to me but I don't have enough context on pylint-django to understand more. If you have a particular use case we should look into, let me know!

@atodorov
Copy link
Contributor Author

@PCManticore any idea why I get varying results depending on how I execute one of the tests ?


# TODO: no sure what to do with commented out code! It looks like
# we don't need these transforms anymore

Copy link
Member

Choose a reason for hiding this comment

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

I'd suggest either leave them in or just a comment with a commit hash and an explanation of 'we removed some transforms' in case new issues get opened wanting them back.

@carlio
Copy link
Member

carlio commented Jul 24, 2018

Code seems to make sense to me but we're still getting build failures.

atodorov added 5 commits July 24, 2018 23:55
for checking if a module is named wsgi.py or includes 'migrations'
in its name we take the first element of the list
According to this documentation
http://pylint.pycqa.org/projects/astroid/en/latest/extending.html?highlight=MANAGER#module-extender-transforms

the module transform function doesn't accept any parameters and
returns a new Module node.
after the previous commit these transformation don't seem to be
needed. Maybe the latest pylint/astroid is better at figuring out
the internals of these Django classes.

Additionally things like django_contrib_postgres_fields.py don't
seem to be hooked up anywhere so remove them as well.
previous augmentation was not handling factory objects very well.
This is an ammendment to that. I'm not exactly certain why we
haven't seen other failures before.
@coveralls
Copy link

coveralls commented Jul 24, 2018

Pull Request Test Coverage Report for Build 451

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 87.023%

Totals Coverage Status
Change from base Build 445: 0.0%
Covered Lines: 570
Relevant Lines: 655

💛 - Coveralls

@atodorov
Copy link
Contributor Author

@carlio I vote for merging this change if you don't mind. ATM I am at a total loss how to debug the failing test (IMO this is a flaky test) and I've posted the symptoms to code-quality ML hoping for some hints.

The failing `func_noerror_foreignkeys` was caused by pylint_django
trying to infer a ForeignKey('Author') field by looking at the
astroid cache. In this case there was an Author model already
defined in `func_noerror_duplicate_except_doesnotexist` which
was inferred and of course this model didn't have the `author_name`
field hence we got a no-member error.

This commit tries to restrict where we load these models from
and also takes into account the quirk that Django allows specifying
'appname.Model' instead of 'path.to.python.module.models.Model'.
@atodorov
Copy link
Contributor Author

@carlio sorry for the noise. Finally figured out what was wrong with the test. See the last commit.

I am up for a release tomorrow, any preferences for teh version number ? Should we also do 2.0 or keep it incremental (0.12 then).

@carlio
Copy link
Member

carlio commented Jul 25, 2018

@atodorov Yes I think it's time to have a better version scheme. It just started as I used '0' to mean 'not quite sure this is done yet' and never changed it. I suppose it might as well follow pylint more closely but at least it could get a major version number now I think.

@carlio
Copy link
Member

carlio commented Jul 25, 2018

@atodorov and if that number changes, could probably remove the beta classifier at the same time.

@atodorov atodorov merged commit 7a77887 into master Jul 25, 2018
@atodorov atodorov deleted the pylint20 branch July 25, 2018 06:35
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.

5 participants