Git Product home page Git Product logo

Comments (1)

baileythegreen avatar baileythegreen commented on July 3, 2024

@gvwilson I looked into this. It's because it falls through checks by the linter and is silently dropped by check_glossary.py.

The linter would flag:

- slug:           # nothing here


- slug: an_entry

check_glossary.py would flag:

- slug: entry
    unknown_key:

or

- slug: entry

-                  # missing the slug key

- slug: another_entry

The existing function that could easily catch this is here. My notes inside ** explain why it fails to catch them:

def checkEntry(entry):
    ''' 
    Check structure of individual entries, returning a language-to-set
    dictionary of terms references in the body.
    '''
    keys = set(entry.keys())

** ENTRY_REQUIRED_KEYS is {'slug'} (won't be missing for an entry without a body) **
    missing = [k for k in ENTRY_REQUIRED_KEYS if k not in keys]               
    if missing:
        print(f'Missing required keys for entry {entry}: {missing}')
    slug = entry['slug']
    unknown_keys = keys - ENTRY_KEYS
    if unknown_keys:
        print(f'Unknown keys in {slug}: {unknown_keys}')
    result = {}
    crossrefs = set(entry['ref']) if ('ref' in entry) else set()

** if the entry is empty, it doesn't have any language keys, so it is silently dropped here **
    for lang in ENTRY_LANGUAGE_KEYS:
        if lang in entry:
            label = f'{slug}/{lang}'
            result[lang] = checkLanguageDef(label, crossrefs, entry[lang])
    return result

There are different ways this could be solved. An easy one, and the test I used to determine where the bug lay, is to insert: if keys == {'slug'}: print('Empty entry found') after keys = set(entry.keys()).

However, it is worth clarifying exactly what sort of 'empty entry' is to be avoided and whether there are other checks worth making.

from glosario.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.