These are chat archives for coala/coala-bears

23rd
Aug 2016
AbdealiJK
@AbdealiJK
Aug 23 2016 17:32
@Adrianzatreanu we should continue our conversation here as it's coala-bears related.
Zatreanu Adrian-Gabriel
@Adrianzatreanu
Aug 23 2016 17:37
Ok
AbdealiJK
@AbdealiJK
Aug 23 2016 17:38
So, once I installed coala, I did pip install PEP8Bear. And I can see the module in my virtualenv. And it is seen in --show-bears:
py35_coala) [ajk@localhost coala]$ coala --show-bears
[WARNING][23:07:59] The default coafile '.coafile' was not found. You can generate a configuration file with your current options by adding the `--save` flag.
[WARNING][23:07:59] coala will not run any analysis. Did you forget to give the `--files` argument?
[WARNING][23:07:59] coala will not run any analysis. Did you forget to give the `--bears` argument?
PEP8Bear
--show-bears --show-details also shows me the details of the PEP8Bear correctly. Including the configs and stuff
Note to self: In the --show-details it would be helpful to note the file path where the bear has been found at.
Zatreanu Adrian-Gabriel
@Adrianzatreanu
Aug 23 2016 17:40
Alright. Till now all is good
Try installing one more bear
Lets say; cppcheckbear
It probably wont show up on --show-bears
AbdealiJK
@AbdealiJK
Aug 23 2016 17:42
Noo, i would like to run unittests for this bear first.
Zatreanu Adrian-Gabriel
@Adrianzatreanu
Aug 23 2016 17:44
Alright
AbdealiJK
@AbdealiJK
Aug 23 2016 17:45
On using PEP8Bear, it says "No bears were found matching 'PEP8Bear'"
@Adrianzatreanu So, when I do coala --show-bears --show-details it shows me the details from PEP8Bear
Zatreanu Adrian-Gabriel
@Adrianzatreanu
Aug 23 2016 17:46
I know :/
AbdealiJK
@AbdealiJK
Aug 23 2016 17:46
But coala -b PEP8Bear --show-details says PEP8Bear not found
(Sorry for the repetition)
AbdealiJK
@AbdealiJK
Aug 23 2016 18:14
@Adrianzatreanu in coalib.collecting.Collectors:122 we are assuming the the name of the file is the same as the name of the bear
we do iglob(os.path.join(bear_dir, bear_glob + '.py')) which is actually iglob(os.path.join('/path/to/PEP8Bear', 'PEP8Bear' + '.py')) for your case
It doesn't understand __init__.
would this fix it? because it doesnt
AbdealiJK
@AbdealiJK
Aug 23 2016 18:17
thinking, 1 moment
it should actually ... testing it out
AbdealiJK
@AbdealiJK
Aug 23 2016 18:22
@Adrianzatreanu when I manually add the __init__.py like you did. It does work
Although it is not the nice way of doing it and breaks a lot of other things ...
Zatreanu Adrian-Gabriel
@Adrianzatreanu
Aug 23 2016 18:23
thats what many people said too..
what other better option do you see here?
AbdealiJK
@AbdealiJK
Aug 23 2016 18:23
For example, the error message No bears were found matching 'PEP8Bear' will appear even though the bear is actually found. As the PEP8Bear glob didn't give the bear out
Zatreanu Adrian-Gabriel
@Adrianzatreanu
Aug 23 2016 18:23
im glad that you are here to help me out, thanks
AbdealiJK
@AbdealiJK
Aug 23 2016 18:24
Hmm. thinking again ^^
Well, the simplest thing is the following
Make your bear creator thingy make the structure:
```
PEP8Bear
| - __init__.py ( Empty file just to make this a python module)
`- PEP8Beat.py (This file contains the bear class)
Zatreanu Adrian-Gabriel
@Adrianzatreanu
Aug 23 2016 18:28
so in the root of the package theres only setup.py and a folder with the bear name?
AbdealiJK
@AbdealiJK
Aug 23 2016 18:28
Yes
Zatreanu Adrian-Gabriel
@Adrianzatreanu
Aug 23 2016 18:28
and in the folder theres init.py and the bear file?
AbdealiJK
@AbdealiJK
Aug 23 2016 18:28
yep
Zatreanu Adrian-Gabriel
@Adrianzatreanu
Aug 23 2016 18:28
thats how ive been doing it for 3 months ;d that was the initial plan ..
it will fail
AbdealiJK
@AbdealiJK
Aug 23 2016 18:28
Oh I see - why will this fail ?
Actually, it would be difficult for you to type it out on phone. Let me test this out myself
Zatreanu Adrian-Gabriel
@Adrianzatreanu
Aug 23 2016 18:29
lasse explained that this is an ancient python problem that we've encountered - having to import from pep8bear import pep8bear will have a conflict with that init.py
the power came back on 5mins ago
im typing on my laptop now
im not even sure myself what the conflict was, but this is how i initially did the packages.
AbdealiJK
@AbdealiJK
Aug 23 2016 18:29
I see
So, if we rename the outer package to a different name it should be OK ?
MyAwesomePEP8Bear
| - __init__.py ( Empty file just to make this a python module)
`-- PEP8Bear.py (This file contains the bear class)
example ^ ?
Zatreanu Adrian-Gabriel
@Adrianzatreanu
Aug 23 2016 18:30
not sure. could try it out.
AbdealiJK
@AbdealiJK
Aug 23 2016 18:31
You do that, I'll try it out myself too
Zatreanu Adrian-Gabriel
@Adrianzatreanu
Aug 23 2016 18:31
maybe i could add a c in front of the package names just to try it out
i can do that fast with 2-3 bears it takes only 2mins
AbdealiJK
@AbdealiJK
Aug 23 2016 18:32
I'm doing all my testing with only 1 bear
Let's get 1 bear to work. Then worry about 2 ?
Zatreanu Adrian-Gabriel
@Adrianzatreanu
Aug 23 2016 18:33
sure
AbdealiJK
@AbdealiJK
Aug 23 2016 18:37
@Adrianzatreanu Found a bug in iglob which may or may not affect you ... coala-analyzer/coala#2664
Zatreanu Adrian-Gabriel
@Adrianzatreanu
Aug 23 2016 18:38
i see
well sorry but its taking a while but im doing this right now the uploading
ill tell you when im done
AbdealiJK
@AbdealiJK
Aug 23 2016 18:39
Uploading ?
Are you uploading to pypi for every test ?
Zatreanu Adrian-Gabriel
@Adrianzatreanu
Aug 23 2016 18:40
yes
AbdealiJK
@AbdealiJK
Aug 23 2016 18:41
It may be easier to just make a small setup.py locally and do pip install -e . or something.
Or atleast upload to test.pypi if you want to specifically test if on pypi
Zatreanu Adrian-Gabriel
@Adrianzatreanu
Aug 23 2016 18:43
its ok all i do is automated but im struggling a little with the file structure right now
im a little confused tho
im not really sure
which name is the problem actually
AbdealiJK
@AbdealiJK
Aug 23 2016 18:45
So, hey
I just tried with both names being the same name and it seems to work
Zatreanu Adrian-Gabriel
@Adrianzatreanu
Aug 23 2016 18:46
really?
ok im doing same name an upload in 2 mins
AbdealiJK
@AbdealiJK
Aug 23 2016 18:47
The reason I believe it works it because our _import_bears() takes the full file_path in. so, there's no confusion. But I still would like to read and analyze if my understanding is correct
the Importer.py has changed significantly since I saw it last.
Zatreanu Adrian-Gabriel
@Adrianzatreanu
Aug 23 2016 18:47
done
cppclean and cppcheck are up
with this structure.
AbdealiJK
@AbdealiJK
Aug 23 2016 18:49
Nice, could you test ?
Zatreanu Adrian-Gabriel
@Adrianzatreanu
Aug 23 2016 18:50
well test what?
by doing the normal coala --show-bears it wont work
thats for sure
AbdealiJK
@AbdealiJK
Aug 23 2016 18:51
Oh.
Er, give me a moment again then
Zatreanu Adrian-Gabriel
@Adrianzatreanu
Aug 23 2016 18:51
sure
AbdealiJK
@AbdealiJK
Aug 23 2016 19:03
So, to keep you awake: It does work correctly for me in the python shell. But not when i run coala ...
Zatreanu Adrian-Gabriel
@Adrianzatreanu
Aug 23 2016 19:03
i know, right?!
thats hwat happens to me too
i tried debugging it
and it collects all cool
and so on
i cant find the problem
AbdealiJK
@AbdealiJK
Aug 23 2016 19:05
I believe the issue is somewhere in Importers.py
In _import_module() we seem to be adding to the sys.path, but we're not removing it anywhere ... maybe that's the issue ?
Still digging.
AbdealiJK
@AbdealiJK
Aug 23 2016 19:27
@Adrianzatreanu I think we need to revamp the _import_module() function
@sils1297 I think we had a discussion about this once and python 3.2 was the issue we didn't use this
Is my memory correct ?
Lasse Schuirmann
@sils
Aug 23 2016 19:28
possibly, this is also related to us playing around with the python path upon import which we don't really want to do but ATM it doesn't work if we don't do it
AbdealiJK
@AbdealiJK
Aug 23 2016 19:29
Exactly. That's the reason we had brought up the issue last time
Zatreanu Adrian-Gabriel
@Adrianzatreanu
Aug 23 2016 19:55
well what do we do then :(
?
Zatreanu Adrian-Gabriel
@Adrianzatreanu
Aug 23 2016 19:59
should i do it? im afraid it might take a while but i can try if nobody else wants :smile:
AbdealiJK
@AbdealiJK
Aug 23 2016 20:00
Its actually pretty simple. But it seems like there's some issue with inspect.
Zatreanu Adrian-Gabriel
@Adrianzatreanu
Aug 23 2016 20:01
what issue?\
AbdealiJK
@AbdealiJK
Aug 23 2016 20:02
http://pastebin.com/WcX74zUV is the changed function
The issue is that we have a function object_defined_in() which uses inspect. Now, when I use PEP8Bear.PEP8Bear with inspect.getfile, it says the class is defined in PEP8Bear/__init__.py and not PEP8Bear/PEP8Bear.py
Seems like a bug in inspect ... (?)
Zatreanu Adrian-Gabriel
@Adrianzatreanu
Aug 23 2016 20:05
thats because it is
for pep8bear the class is in init
the only packages i changed to be in package/package.py are for cppcheck and cppclean
i didnt update all bears, just 2 as i said
AbdealiJK
@AbdealiJK
Aug 23 2016 20:06
No ... I'm using a modified package where PEP8Bear is in PEP8Bear/PEP8Bear.py
and __init__ is empty
Zatreanu Adrian-Gabriel
@Adrianzatreanu
Aug 23 2016 20:06
oh
then no idea :/
AbdealiJK
@AbdealiJK
Aug 23 2016 20:07
Have you seen the code at object_defined_in() ?
Zatreanu Adrian-Gabriel
@Adrianzatreanu
Aug 23 2016 20:08
no, i dont know what that is or where
AbdealiJK
@AbdealiJK
Aug 23 2016 20:08
git grep object_defined_in
Zatreanu Adrian-Gabriel
@Adrianzatreanu
Aug 23 2016 20:09
i did i did
lets see
AbdealiJK
@AbdealiJK
Aug 23 2016 20:09
So, essentially I think the solution is the following:
Fix Importer to import specific Bear files rather than doing the current hacky way of meddling with sys.path files
To do this, we need the new method of importing shown at http://pastebin.com/WcX74zUV and need to get everything to work with this
The only thing that doesnt work with this method is object_defined_in() so we need to figure out how to get it to work / find an alternative way to do what it does
--
AbdealiJK
@AbdealiJK
Aug 23 2016 20:16
@Adrianzatreanu following ?
Zatreanu Adrian-Gabriel
@Adrianzatreanu
Aug 23 2016 20:16
yes im reading
Zatreanu Adrian-Gabriel
@Adrianzatreanu
Aug 23 2016 20:23
i dont think i can fix that stuff though
AbdealiJK
@AbdealiJK
Aug 23 2016 20:25
The inspect ?
Zatreanu Adrian-Gabriel
@Adrianzatreanu
Aug 23 2016 20:26
i meant anything :D
AbdealiJK
@AbdealiJK
Aug 23 2016 20:27
Well ... the alternative is to have the top level module name different as compared to the inner module name
so...
ROOT (/) or repo
| - setup.py
`-- PEP8CoalaBear
    | - __init__.py
    `-- PEP8Bear.py
Note the difference in name (ABCCoalaBear vs ABCBear)
Zatreanu Adrian-Gabriel
@Adrianzatreanu
Aug 23 2016 20:29
sorry, is that uppercase C?
AbdealiJK
@AbdealiJK
Aug 23 2016 20:29
>_> I see @sils1297 has trained you well
Zatreanu Adrian-Gabriel
@Adrianzatreanu
Aug 23 2016 20:29
he gave me chocolate :smile:
AbdealiJK
@AbdealiJK
Aug 23 2016 20:30
Well, you can think of a better name if you like ...
Zatreanu Adrian-Gabriel
@Adrianzatreanu
Aug 23 2016 20:30
surely i can do that
but will coala import it correctly?
how will it know to import it with that name?
AbdealiJK
@AbdealiJK
Aug 23 2016 20:30
Yep
I tested it
Zatreanu Adrian-Gabriel
@Adrianzatreanu
Aug 23 2016 20:30
you sure?
ok
ill do it then
does the package name matter too?
or just the folder?
if its just the folder it takes me 1min
AbdealiJK
@AbdealiJK
Aug 23 2016 20:30
So, in the setup.py the entrypoint would be PEP8CoalaBear
Zatreanu Adrian-Gabriel
@Adrianzatreanu
Aug 23 2016 20:31
not coalabears??
i thought thats how coala recognizes bears
AbdealiJK
@AbdealiJK
Aug 23 2016 20:31
Not the "coalabears" side
there's another side right ?
Zatreanu Adrian-Gabriel
@Adrianzatreanu
Aug 23 2016 20:31
really? i dont know
ok so noted: folder has coala and entrypoint too
working on it
AbdealiJK
@AbdealiJK
Aug 23 2016 20:32
Note that the folder can be named anything. Literally anything. it doesnt matter
Zatreanu Adrian-Gabriel
@Adrianzatreanu
Aug 23 2016 20:32
im naming it coalaBearName
AbdealiJK
@AbdealiJK
Aug 23 2016 20:32
:+1:
Also, generally pypi package name are the same as the toplevel module name ... but not always
For example, python-opencv's module name is cv2 or scikit-learn's module name is sklearn
So, Ill let you decide that ...
Zatreanu Adrian-Gabriel
@Adrianzatreanu
Aug 23 2016 20:37
entry_points={"coalaAlexBear": ["AlexBear = AlexBear"]},
this is the entrypoint
is it okay?
for alexbear
AbdealiJK
@AbdealiJK
Aug 23 2016 20:37
noo
{"coalabears": ["AlexBear = coalaAlexBear"]},
Zatreanu Adrian-Gabriel
@Adrianzatreanu
Aug 23 2016 20:38
ok
oh*
ok
AbdealiJK
@AbdealiJK
Aug 23 2016 20:38
That's what I meant by the other side (the right side) :P
Zatreanu Adrian-Gabriel
@Adrianzatreanu
Aug 23 2016 20:39
oh
i see now
ok uploading the first 2 bears now
and checking
omfg it worked
AbdealiJK
@AbdealiJK
Aug 23 2016 20:41
:D
But it's not nice :( ...
Well, anyway
Zatreanu Adrian-Gabriel
@Adrianzatreanu
Aug 23 2016 20:41
what command should i try now?
[WARNING][23:41:43] The bear CPPCheckBear does not fulfill all requirements. 'cppcheck' is not installed.
i reached this
AbdealiJK
@AbdealiJK
Aug 23 2016 20:42
Ahhh
Zatreanu Adrian-Gabriel
@Adrianzatreanu
Aug 23 2016 20:42
i think its ok cuz this means it got the bear correctly
AbdealiJK
@AbdealiJK
Aug 23 2016 20:42
Well, why not try it properly ?
Just do pytest -k CPPCheck in coala-bears
Zatreanu Adrian-Gabriel
@Adrianzatreanu
Aug 23 2016 20:43
but wouldnt that run the local cppcheckbear?
AbdealiJK
@AbdealiJK
Aug 23 2016 20:43
Test it out properly ... we don't have Continuous Integration for this I'm guessing ?
Zatreanu Adrian-Gabriel
@Adrianzatreanu
Aug 23 2016 20:43
i want to check with mine, right?
the installed one
AbdealiJK
@AbdealiJK
Aug 23 2016 20:43
@Adrianzatreanu Would it ? If it does, then copy the test file elsewhere and run it
Ah yes. Sorry
No, ignore me. I was wrong
Zatreanu Adrian-Gabriel
@Adrianzatreanu
Aug 23 2016 20:44
(venv) 192-168-0-102:coala-bears adrianzatreanu$ pytest -k CPPCheckBear
============================= test session starts ==============================
platform darwin -- Python 3.5.2, pytest-3.0.0, py-1.4.31, pluggy-0.3.1
rootdir: /Users/adrianzatreanu/coala-bears, inifile: setup.cfg
collected 410 items 

tests/c_languages/CPPCheckBearTest.py ssss

============================ pytest-warning summary ============================
WC1 None [pytest] section in setup.cfg files is deprecated, use [tool:pytest] instead.
WC1 /Users/adrianzatreanu/coala-bears/tests/natural_language/LanguageToolBearTest.py cannot collect test class 'SkipTest' because it has a __init__ constructor
============================= 406 tests deselected =============================
========= 4 skipped, 406 deselected, 2 pytest-warnings in 1.04 seconds =========
anyway
im confused btw, what are you trying to say? which is wrong and which is right?
AbdealiJK
@AbdealiJK
Aug 23 2016 20:45
Don't use pytest - it will always use coala-bears
Zatreanu Adrian-Gabriel
@Adrianzatreanu
Aug 23 2016 20:45
i guessed so
well
i still think its working fine :D
im trying to install autopep8 and run it then
lets see
AbdealiJK
@AbdealiJK
Aug 23 2016 20:45
Make a demo.cpp file and try parsing it
Yep
ok, so cool.
I shall be going to sleep then
Zatreanu Adrian-Gabriel
@Adrianzatreanu
Aug 23 2016 20:46
ah wait i did upload that one yet
AbdealiJK
@AbdealiJK
Aug 23 2016 20:46
alright, waiting
Zatreanu Adrian-Gabriel
@Adrianzatreanu
Aug 23 2016 20:46
ill upload all of them
nono go to sleep
im 90% sure you fixed it with this
ill test it and let you know tomorrow
AbdealiJK
@AbdealiJK
Aug 23 2016 20:46
XD alrighto
Sounds good
Zatreanu Adrian-Gabriel
@Adrianzatreanu
Aug 23 2016 20:47
thanks a lot for your help
@sils1297 i think we solved it!
Lasse Schuirmann
@sils
Aug 23 2016 20:55
oh really @Adrianzatreanu ? what was it?
Zatreanu Adrian-Gabriel
@Adrianzatreanu
Aug 23 2016 20:56
i guess different names to folder and not holding the data in a init.py
not sure 100% what was the problem but it is solved i think