question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Python recognized as Makefile

See original GitHub issue

(Originally reported in https://github.com/pdoc3/pdoc/issues/32.)

The following <pre><code> is recognized as Makefile instead of Python (live example).

<!DOCTYPE html>
<html>
<head><meta charset="utf-8">
  
  <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.14.2/styles/default.min.css">
  <script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.14.2/highlight.min.js"></script>
  <script>hljs.initHighlightingOnLoad();</script>
  
</head>
<body>

<pre><code>

#!python
import constraintanalysis as ca
import atmospheres as at
import unitconversions as co

designbrief = {'stloadfactor': 2, 'turnalt_m': 3050, 'turnspeed_ktas': 140}

etap = {'turn': 0.85}

designperformance = {'CLmaxclean': 1.45, 'CDminclean': 0.02541,
                     'etaprop': etap}

designdef = {'aspectratio': 10, 'sweep_le_deg': 2,
             'sweep_mt_deg': 0, 'bpr': -1}

TOW_kg = 1500

designatm = at.Atmosphere()
concept = ca.AircraftConcept(designbrief, designdef,
                             designperformance, designatm)

wingloading_pa = 1000

twreq, _, _ = concept.twrequired_trn(wingloading_pa)

turnspeed_mpstas = co.kts2mps(designbrief['turnspeed_ktas'])

pw_trn_wpn = ca.tw2pw(twreq, turnspeed_mpstas, etap['turn'])
pw_trn_hpkg = co.wn2hpkg(pw_trn_wpn)
p_trn_hp = pw_trn_hpkg * TOW_kg

print(p_trn_hp)

</code></pre>

  </body>
</html>

I believe hanging-indented lines containing spaces instead of tabs (\x09) should exclude Makefile altogether.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:15 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
joshgoebelcommented, Nov 13, 2019

Root cause here is Makefile earned lots of points for simple assignment operations, which is a little silly. PR improves this situation greatly.

1reaction
joshgoebelcommented, Oct 20, 2019

Many of the languages will seem overzealous for given samples… it’s very hard to do magic auto-detection of languages and get it right 100% of the time.

To be clear, I do agree the relevance system can be improved, but it’s far from a simple think to just sit down and “fix it”… 😃 Too many things are equally valued by all languages so as to be almost meaningless (like strings or some types of comment)… they should be scored less.

Some works has happened on this though, such as my recent patch to blacklist certain popular keywords that appear in the english language as well as many programming languages.

It’s hard to fix because we don’t have great measurement tools to know we’re moving the right direction (I’m working on some) and currently ALL the tests have to pass to accept a PR - so that makes it a hard thing to tackle say “one language at a time” like you might tackle other issues.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Creating a Python Makefile - Earthly Blog
Even though Python is regarded as an interpreted language and the files need not be compiled ... The Makefile consists of a set...
Read more >
Getting started with python: Can't run makefile - Stack Overflow
Make files are no python scripts. Jupyter expects python scripts. You probably need to use the makefile from the terminal.
Read more >
How to Write a Makefile - Automating Python Setup ...
Makefile uses the make utility, and if we're to be completely accurate, Makefile is just a file that houses the code that the...
Read more >
Makefile: python: command not found - Ask Ubuntu
Isn't python-is-python3 just creating a symlink from /usr/bin/python to python3? Yes it is. Is it any different from the alias approach I ...
Read more >
Make-fu - Setting up a makefile for a Python project
This post introduces the makefile and gives several examples of how to use makefiles for Python projects.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found