Reputation: 8478
So Pylint
(1.4.3
) is reporting a Cyclic Import and it doesn't make much sense.
First of all, the file that's report has no import statements.
Second of all no files import the reference file. a __init__.py
file loads configuration values from development_config
(file in question) but no files
import said file.
So why is Pylint giving me this warning?
************* Module heart_beat.development_config
R: 1, 0: Cyclic import (heart_beat -> heart_beat.views -> heart_beat.models) (cyclic-import)
R: 1, 0: Cyclic import (heart_beat -> heart_beat.views) (cyclic-import)
development_config
""" -------------------------- DATA BASE CONFINGURATION --------------------"""
SQLALCHEMY_DATABASE_URI = 'sqlite:////tmp/test.db'
SQLALCHEMY_ECHO = False
""" -------------------------- Flask Application Config --------------------"""
THREADS_PER_PAGE = 8
VERSION = "0.1"
__init__.py
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
#from register_assets import register_all
app = Flask(__name__, static_url_path='/static')
# the environment variable LIMBO_SETTINGS is set in runserver, run_unit_tests
# or limbo.wsgi.
def load_configs():
"""Take all configs found in development_config.py."""
app.config.from_pyfile("development_config.py", silent=False)
load_configs()
# global SQLAlchemy configuration
db = SQLAlchemy(app)
#Create and register all static asset bundles.
#register_all(app)
#NOTE: DON'T LISTEN TO YOUR IDE! heart_beat.views is used and required.
import heart_beat.views # views contains all URL routes, Importing sets routes.
def setup_db():
"""Database creation in a file rather then a statement for easier tests."""
db.create_all()
def teardown_db():
"""Database deletion in a file rather then a statement for easier tests."""
db.drop_all()
setup_db()
views.py
from flask import request
from . import app
from . import db
from . import models
from . import exceptions as ex
models.py
import datetime
from . import exceptions
from . import db
from . import app
Upvotes: 5
Views: 4114
Reputation: 1527
I believe this is currently a bug in pylint. Things that require analysis over multiple modules (for example cyclic-import
and duplicate-code
detection) get thrown as refactors into the last-parsed module file. For me, this ended up being an empty __init__.py
file that had both of these dropped into it.
Both of these refactor messages though contain the actual module names which are problematic:
==
The grouping of these is not limited to the print-out of modules, it also effects the summary report % errors / warnings by module
in which that final parsed file gets the counts for the refactors and none of the modules it actually concerns get any counts from them.
Upvotes: 17