Repository: stummjr/flake8-scrapy

Issue:
Failed SCP03 rule check
When starting the fakehaven stage in CI, I received the following error:

```
$ flakeheaven lint --format=grouped --exit-zero --import-order-style pep8 --application-import-names directories
multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/multiprocessing/pool.py", line 121, in worker
    result = (True, func(*args, **kwds))
  File "/usr/local/lib/python3.7/multiprocessing/pool.py", line 44, in mapstar
    return list(map(*args))
  File "/usr/local/lib/python3.7/site-packages/flake8/checker.py", line 687, in _run_checks
    return checker.run_checks()
  File "/usr/local/lib/python3.7/site-packages/flakeheaven/_patched/_checkers.py", line 282, in run_checks
    return super().run_checks()
  File "/usr/local/lib/python3.7/site-packages/flake8/checker.py", line 597, in run_checks
    self.run_ast_checks()
  File "/usr/local/lib/python3.7/site-packages/flake8/checker.py", line 500, in run_ast_checks
    for (line_number, offset, text, _) in runner:
  File "/usr/local/lib/python3.7/site-packages/flake8_scrapy.py", line 55, in run
    finder.visit(self.tree)
  File "/usr/local/lib/python3.7/ast.py", line 271, in visit
    return visitor(node)
  File "/usr/local/lib/python3.7/ast.py", line 279, in generic_visit
    self.visit(item)
  File "/usr/local/lib/python3.7/ast.py", line 271, in visit
    return visitor(node)
  File "/usr/local/lib/python3.7/ast.py", line 279, in generic_visit
    self.visit(item)
  File "/usr/local/lib/python3.7/ast.py", line 271, in visit
    return visitor(node)
  File "/usr/local/lib/python3.7/site-packages/flake8_scrapy.py", line 38, in visit_Assign
    self.find_issues_visitor('Assign', node)
  File "/usr/local/lib/python3.7/site-packages/flake8_scrapy.py", line 35, in find_issues_visitor
    self.generic_visit(node)
  File "/usr/local/lib/python3.7/ast.py", line 281, in generic_visit
    self.visit(value)
  File "/usr/local/lib/python3.7/ast.py", line 271, in visit
    return visitor(node)
  File "/usr/local/lib/python3.7/site-packages/flake8_scrapy.py", line 41, in visit_Call
    self.find_issues_visitor('Call', node)
  File "/usr/local/lib/python3.7/site-packages/flake8_scrapy.py", line 35, in find_issues_visitor
    self.generic_visit(node)
  File "/usr/local/lib/python3.7/ast.py", line 279, in generic_visit
    self.visit(item)
  File "/usr/local/lib/python3.7/ast.py", line 271, in visit
    return visitor(node)
  File "/usr/local/lib/python3.7/ast.py", line 281, in generic_visit
    self.visit(value)
  File "/usr/local/lib/python3.7/ast.py", line 271, in visit
    return visitor(node)
  File "/usr/local/lib/python3.7/site-packages/flake8_scrapy.py", line 41, in visit_Call
    self.find_issues_visitor('Call', node)
  File "/usr/local/lib/python3.7/site-packages/flake8_scrapy.py", line 34, in find_issues_visitor
    self.issues.extend(list(issues))
  File "/usr/local/lib/python3.7/site-packages/finders/oldstyle.py", line 18, in find_issues
    if first_param.value.id == 'response' and first_param.attr == 'url':
AttributeError: 'Attribute' object has no attribute 'id'
"""
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/usr/local/bin/flakeheaven", line 8, in <module>
    sys.exit(entrypoint())
  File "/usr/local/lib/python3.7/site-packages/flakeheaven/_cli.py", line 40, in entrypoint
    exit_code, msg = main(argv)
  File "/usr/local/lib/python3.7/site-packages/flakeheaven/_cli.py", line 32, in main
    return COMMANDS[command_name](argv=argv[1:])
  File "/usr/local/lib/python3.7/site-packages/flakeheaven/commands/_lint.py", line 12, in lint_command
    app.run(argv)
  File "/usr/local/lib/python3.7/site-packages/flake8/main/application.py", line 375, in run
    self._run(argv)
  File "/usr/local/lib/python3.7/site-packages/flake8/main/application.py", line 364, in _run
    self.run_checks()
  File "/usr/local/lib/python3.7/site-packages/flake8/main/application.py", line 271, in run_checks
    self.file_checker_manager.run()
  File "/usr/local/lib/python3.7/site-packages/flake8/checker.py", line 309, in run
    self.run_parallel()
  File "/usr/local/lib/python3.7/site-packages/flake8/checker.py", line 275, in run_parallel
    for ret in pool_map:
  File "/usr/local/lib/python3.7/multiprocessing/pool.py", line 354, in <genexpr>
    return (item for chunk in result for item in chunk)
  File "/usr/local/lib/python3.7/multiprocessing/pool.py", line 748, in next
    raise value
AttributeError: 'Attribute' object has no attribute 'id'
```

The problem occurs in this line:

```python
urljoin(settings.SERVICE_URLS.PD, '/path')
```
Where are the `settings`:

```python
from pydantic import BaseSettings, BaseModel

class ServiceUrlsSchema(BaseModel):
    PD: str

class Settings(BaseSettings):
    SERVICE_URLS: ServiceUrlsSchema
```



Comments:

Patch:
diff --git a/finders/oldstyle.py b/finders/oldstyle.py
index 0910d97..dceef88 100644
--- a/finders/oldstyle.py
+++ b/finders/oldstyle.py
@@ -12,7 +12,7 @@ class UrlJoinIssueFinder(IssueFinder):
             return
 
         first_param = node.args[0]
-        if not isinstance(first_param, ast.Attribute):
+        if not isinstance(first_param, ast.Attribute) or not isinstance(first_param.value, ast.Name):
             return
 
         if first_param.value.id == 'response' and first_param.attr == 'url':
diff --git a/flake8_scrapy.py b/flake8_scrapy.py
index c1198f4..839b2b8 100644
--- a/flake8_scrapy.py
+++ b/flake8_scrapy.py
@@ -6,7 +6,7 @@ from finders.domains import (
 from finders.oldstyle import OldSelectorIssueFinder, UrlJoinIssueFinder
 
 
-__version__ = '0.0.1'
+__version__ = '0.0.2'
 
 
 class ScrapyStyleIssueFinder(ast.NodeVisitor):
diff --git a/setup.py b/setup.py
index 4d058d5..3518539 100644
--- a/setup.py
+++ b/setup.py
@@ -7,7 +7,7 @@ with open('README.md', 'r') as f:
 setuptools.setup(
     name='flake8-scrapy',
     license='MIT',
-    version='0.0.1',
+    version='0.0.2',
     long_description=long_description,
     long_description_content_type='text/markdown',
     author='Valdir Stumm Junior',


Test patch:
diff --git a/tests/test_oldstyle.py b/tests/test_oldstyle.py
index 29e9f50..6dc2d34 100644
--- a/tests/test_oldstyle.py
+++ b/tests/test_oldstyle.py
@@ -17,6 +17,8 @@ def test_finds_old_style_urljoin(code):
 @pytest.mark.parametrize('code', [
     ('response.urljoin("/foo")'),
     ('url = urljoin()'),
+    ('urljoin(x, "/foo")'),
+    ('urljoin(x.y.z, "/foo")'),
 ])
 def test_dont_find_old_style_urljoin(code):
     issues = run_checker(code)