Skip to content

Commit

Permalink
Preprocess known 3rd party mapping before usage
Browse files Browse the repository at this point in the history
Fixes arkq#10
  • Loading branch information
arkq committed Feb 4, 2020
1 parent d7283e3 commit 8e219e2
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/flake8_requirements/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,16 @@ class Flake8Checker(object):
name = "flake8-requirements"
version = __version__

# Build-in mapping for known 3rd party modules.
known_3rd_parties = {
project2module(k): v
for k, v in KNOWN_3RD_PARTIES.items()
}

# User defined project->modules mapping.
known_modules = {}

# max depth to resolve recursive requirements
# Max depth to resolve recursive requirements.
requirements_max_depth = 1

def __init__(self, tree, filename, lines=None):
Expand Down Expand Up @@ -446,8 +452,8 @@ def get_mods_3rd_party(self):
# Get 3rd party module names based on requirements.
for requirement in self.get_mods_3rd_party_requirements():
modules = [project2module(requirement.project_name)]
if modules[0] in KNOWN_3RD_PARTIES:
modules = KNOWN_3RD_PARTIES[modules[0]]
if modules[0] in self.known_3rd_parties:
modules = self.known_3rd_parties[modules[0]]
if modules[0] in self.known_modules:
modules = self.known_modules[modules[0]]
mods_3rd_party.update(modsplit(x) for x in modules)
Expand Down

0 comments on commit 8e219e2

Please sign in to comment.