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

Fix some Pylint complaints, silence false-positives #140

Merged
merged 1 commit into from
Apr 5, 2022

Conversation

bittner
Copy link
Member

@bittner bittner commented Apr 5, 2022

As we now let Pylint run on GHA, we can identify which complaints are easy to fix. This way, we'll move towards "Pylint conformant" slowly, step by step.

These changes fix the most obvious complaints and silences only those that we really can't do anything about (e.g. because class member names or function parameter names are inherited from / defined by Django).

@bittner bittner requested a review from kingbuzzman April 5, 2022 16:56
tox.ini Outdated Show resolved Hide resolved

def get_url(self, to=None, *args, **kwargs):
def get_url(self, *args, to=None, **kwargs): # pylint: disable=invalid-name
Copy link
Member Author

Choose a reason for hiding this comment

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

This change seems to cause the BDD tests to fail.

@requires-live-http                                                                                                                                                                                                
Feature: URL helpers are available in behave's context # tests/acceptance/features/context-urlhelper.feature:2                                                                                                     
  In order to ensure that url helpers are available as documented                                                                                                                                                  
  As the Maintainer                                                                                                                                                                                                
  I want to test all suggested uses                                                                                                                                                                                
  Scenario: get_url() is an alias for the base_url property  # tests/acceptance/features/context-urlhelper.feature:7                                                                                               
    When I call get_url() without arguments                  # tests/acceptance/steps/context-urlhelper.py:6 0.000s                                                                                                
    Then it returns the value of base_url                    # tests/acceptance/steps/context-urlhelper.py:27 0.000s                                                                                               
                                                                                                                                                                                                                   
  Scenario: The first argument in get_url() is appended to base_url if it is a path  # tests/acceptance/features/context-urlhelper.feature:11                                                                      
    When I call get_url("/path/to/page/") with an absolute path                      # tests/acceptance/steps/context-urlhelper.py:11 0.000s                                                                       
    Then the result is the base_url with "/path/to/page/" appended                   # tests/acceptance/steps/context-urlhelper.py:32 0.000s                                                                       
      Assertion Failed: 'http://localhost:51171' != 'http://localhost:51171/path/to/page/'                                                                                                                         
      - http://localhost:51171                                                                                                                                                                                     
      + http://localhost:51171/path/to/page/                                                                                                                                                                       
      ?                       ++++++++++++++                                                                                                                                                                       
                                                                                                                                                                                                                   
                                                                                                                                                                                                                   
  Scenario: The reversed view path is appended to base_url if the first argument in get_url() is a view name  # tests/acceptance/features/context-urlhelper.feature:15                                             
    When I call get_url("admin:password_change") with a view name                                             # tests/acceptance/steps/context-urlhelper.py:16 0.000s                                              
    Then this returns the same result as get_url(reverse("admin:password_change"))                            # tests/acceptance/steps/context-urlhelper.py:51 0.005s                                              
    And the result is the base_url with reverse("admin:password_change") appended                             # tests/acceptance/steps/context-urlhelper.py:37 0.000s                                              
      Assertion Failed: 'http://localhost:43599' != 'http://localhost:43599/admin/password_change/'                                                                                                                
      - http://localhost:43599                                                                                                                                                                                     
      + http://localhost:43599/admin/password_change/                                                                                                                                                              
                                                                                                                                                                                                                   
                                                                                                                                                                                                                   
  Scenario: The model's absolute_url is appended to base_url if the first argument in get_url() is a model  # tests/acceptance/features/context-urlhelper.feature:20                                               
    When I call get_url(model) with a model instance                                                        # tests/acceptance/steps/context-urlhelper.py:21 0.000s                                                
    Then this returns the same result as get_url(model.get_absolute_url())                                  # tests/acceptance/steps/context-urlhelper.py:57 0.000s                                                
    And the result is the base_url with model.get_absolute_url() appended                                   # tests/acceptance/steps/context-urlhelper.py:44 0.000s                                                
      Assertion Failed: 'http://localhost:37467' != 'http://localhost:37467/behave/test/3/Foo'                                                                                                                     
      - http://localhost:37467                                                                                                                                                                                     
      + http://localhost:37467/behave/test/3/Foo                                                                                                                                                                   
Failing scenarios:
  tests/acceptance/features/context-urlhelper.feature:11  The first argument in get_url() is appended to base_url if it is a path
  tests/acceptance/features/context-urlhelper.feature:15  The reversed view path is appended to base_url if the first argument in get_url() is a view name
  tests/acceptance/features/context-urlhelper.feature:20  The model's absolute_url is appended to base_url if the first argument in get_url() is a model

Copy link
Member Author

Choose a reason for hiding this comment

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

@kingbuzzman I see that we really seem to have a deeper problem with the arguments of the get_url method.

The to argument should correspond to the first positional parameter of the Django shortcut's resolve_url function. Our implementation may break when to is something else than a string.

Specifically, when get_absolute_url() returns a URL containing a protocol and a hostname or IP address then there will be two base_urls in the resulting URL string. 🐞 💣

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see the commit that broke it because you keep squashing :'(

Copy link
Member Author

Choose a reason for hiding this comment

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

The commit is 991672e. I force-pushed to undo the change.

I'll open a dedicated issue to address this problem separately.

Copy link
Member Author

Choose a reason for hiding this comment

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

See #141 for a follow-up.

@bittner bittner force-pushed the fix/pylint-complaints branch from 991672e to e2e6e53 Compare April 5, 2022 18:11
@bittner bittner force-pushed the fix/pylint-complaints branch from e2e6e53 to a4b7d4a Compare April 5, 2022 18:20
@bittner bittner merged commit 1d77260 into main Apr 5, 2022
@bittner bittner deleted the fix/pylint-complaints branch April 5, 2022 19:06
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