class_docstr: Responsible for parsing configuration from files and CLI.
  
  There are 2 types of configurations: Run configurations and Check
  configurations.
  
  Run Configurations:
  ------------------
  Responsible for deciding things that are related to the user interface and
  configuration discovery, e.g. verbosity, debug options, etc.
  All run configurations default to `False` or `None` and are decided only
  by CLI.
  
  Check Configurations:
  --------------------
  Configurations that are related to which files and errors will be checked.
  These are configurable in 2 ways: using the CLI, and using configuration
  files.
  
  Configuration files are nested within the file system, meaning that the
  closer a configuration file is to a checked file, the more relevant it will
  be. For instance, imagine this directory structure:
  
  A
  +-- tox.ini: sets `select=D100`
  +-- B
      +-- foo.py
      +-- tox.ini: sets `add-ignore=D100`
  
  Then `foo.py` will not be checked for `D100`.
  The configuration build algorithm is described in `self._get_config`.
  
  Note: If any of `BASE_ERROR_SELECTION_OPTIONS` was selected in the CLI, all
  configuration files will be ignored and each file will be checked for
  the error codes supplied in the CLI.
class_docstr_tok: ["Responsible","for","parsing","configuration","from","files","and","CLI",".","There","are","2","types","of","configurations",":","Run","configurations","and","Check","configurations",".","Run","Configurations",":","--","--","--","--","--","--","--","--","--","Responsible","for","deciding","things","that","are","related","to","the","user","interface","and","configuration","discovery",",","e.g",".","verbosity",",","debug","options",",","etc",".","All","run","configurations","default","to","`","False","`","or","`","None","`","and","are","decided","only","by","CLI",".","Check","Configurations",":","--","--","--","--","--","--","--","--","--","--","Configurations","that","are","related","to","which","files","and","errors","will","be","checked",".","These","are","configurable","in","2","ways",":","using","the","CLI",",","and","using","configuration","files",".","Configuration","files","are","nested","within","the","file","system",",","meaning","that","the","closer","a","configuration","file","is","to","a","checked","file",",","the","more","relevant","it","will","be",".","For","instance",",","imagine","this","directory","structure",":","A","+","--","tox.ini",":","sets","`","select=D100","`","+","--","B","+","--","foo.py","+","--","tox.ini",":","sets","`","add-ignore=D100","`","Then","`","foo.py","`","will","not","be","checked","for","`","D100","`",".","The","configuration","build","algorithm","is","described","in","`","self._get_config","`",".","Note",":","If","any","of","`","BASE_ERROR_SELECTION_OPTIONS","`","was","selected","in","the","CLI",",","all","configuration","files","will","be","ignored","and","each","file","will","be","checked","for","the","error","codes","supplied","in","the","CLI","."]
docstr: Get and cache the run configuration for `node`.
  
  If no configuration exists (not local and not for the parent node),
  returns and caches a default configuration.
  
  The algorithm:
  -------------
  * If the current directory's configuration exists in
     `self._cache` - return it.
  * If a configuration file does not exist in this directory:
    * If the directory is not a root directory:
      * Cache its configuration as this directory's and return it.
    * Else:
      * Cache a default configuration and return it.
  * Else:
    * Read the configuration file.
    * If a parent directory exists AND the configuration file
      allows inheritance:
      * Read the parent configuration by calling this function with the
        parent directory as `node`.
      * Merge the parent configuration with the current one and
        cache it.
  * If the user has specified one of `BASE_ERROR_SELECTION_OPTIONS` in
    the CLI - return the CLI configuration with the configuration match
    clauses
  * Set the `--add-select` and `--add-ignore` CLI configurations.
docstr_tok: ["Get","and","cache","the","run","configuration","for","`","node","`",".","If","no","configuration","exists","(","not","local","and","not","for","the","parent","node",")",",","returns","and","caches","a","default","configuration",".","The","algorithm",":","--","--","--","--","--","--","-","*","If","the","current","directory","'s","configuration","exists","in","`","self._cache","`","-","return","it",".","*","If","a","configuration","file","does","not","exist","in","this","directory",":","*","If","the","directory","is","not","a","root","directory",":","*","Cache","its","configuration","as","this","directory","'s","and","return","it",".","*","Else",":","*","Cache","a","default","configuration","and","return","it",".","*","Else",":","*","Read","the","configuration","file",".","*","If","a","parent","directory","exists","AND","the","configuration","file","allows","inheritance",":","*","Read","the","parent","configuration","by","calling","this","function","with","the","parent","directory","as","`","node","`",".","*","Merge","the","parent","configuration","with","the","current","one","and","cache","it",".","*","If","the","user","has","specified","one","of","`","BASE_ERROR_SELECTION_OPTIONS","`","in","the","CLI","-","return","the","CLI","configuration","with","the","configuration","match","clauses","*","Set","the","`","--","add-select","`","and","`","--","add-ignore","`","CLI","configurations","."]
code: def _get_config(self, node):
      """Get and cache the run configuration for `node`.
  
      If no configuration exists (not local and not for the parent node),
      returns and caches a default configuration.
  
      The algorithm:
      -------------
      * If the current directory's configuration exists in
         `self._cache` - return it.
      * If a configuration file does not exist in this directory:
        * If the directory is not a root directory:
          * Cache its configuration as this directory's and return it.
        * Else:
          * Cache a default configuration and return it.
      * Else:
        * Read the configuration file.
        * If a parent directory exists AND the configuration file
          allows inheritance:
          * Read the parent configuration by calling this function with the
            parent directory as `node`.
          * Merge the parent configuration with the current one and
            cache it.
      * If the user has specified one of `BASE_ERROR_SELECTION_OPTIONS` in
        the CLI - return the CLI configuration with the configuration match
        clauses
      * Set the `--add-select` and `--add-ignore` CLI configurations.
  
      """
      if self._run_conf.config is None:
          log.debug("No config file specified, discovering.")
          config = self._get_config_by_discovery(node)
      else:
          log.debug("Using config file %r", self._run_conf.config)
          if not os.path.exists(self._run_conf.config):
              raise IllegalConfiguration(
                  "Configuration file {!r} specified "
                  "via --config was not found.".format(
                      self._run_conf.config
                  )
              )
  
          if None in self._cache:
              return self._cache[None]
          options, _ = self._read_configuration_file(
              self._run_conf.config
          )
  
          if options is None:
              log.warning(
                  "Configuration file does not contain a "
                  "pydocstyle section. Using default configuration."
              )
              config = self._create_check_config(self._options)
          else:
              config = self._create_check_config(options)
  
      # Make the CLI always win
      final_config = {}
      for attr in CheckConfiguration._fields:
          cli_val = getattr(self._override_by_cli, attr)
          conf_val = getattr(config, attr)
          final_config[attr] = (
              cli_val if cli_val is not None else conf_val
          )
  
      config = CheckConfiguration(**final_config)
  
      self._set_add_options(config.checked_codes, self._options)
  
      # Handle caching
      if self._run_conf.config is not None:
          self._cache[None] = config
      else:
          self._cache[self._get_node_dir(node)] = config
      return config
  
imports: import copy
  import itertools
  import operator
  import os
  import sys
  from collections import namedtuple
  from collections.abc import Set
  from configparser import NoOptionError, NoSectionError, RawConfigParser
  from functools import reduce
  from re import compile
  from ._version import __version__
  from .utils import log
  from .violations import ErrorRegistry, conventions
label_desc: Use image node_id 7 for calling the ConfigurationParser obj's underlying member method code with example usage: obj._get_config(node) and returns: config, self